Skip to content

Commit c8c112a

Browse files
authored
Initial check-in (#1)
1 parent 0d7c3a8 commit c8c112a

File tree

132 files changed

+16060
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+16060
-1
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
target
2+
.*.swp
3+
.*.swo
4+
*.iml
5+
.idea

LICENSE.txt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Cadence Java Client
2+
Copyright (c) 2017 Uber Technologies, Inc. All Rights Reserved
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
4+
file except in compliance with the License. You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software distributed under
9+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
specific language governing permissions and limitations under the License.
12+
13+
Cadence Java Client uses the following projects:
14+
15+
AWS Simple Workflow Flow Library
16+
Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved
17+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
18+
file except in compliance with the License. You may obtain a copy of the License at
19+
20+
http://www.apache.org/licenses/LICENSE-2.0
21+
22+
Unless required by applicable law or agreed to in writing, software distributed under
23+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
24+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
25+
specific language governing permissions and limitations under the License.

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
# cadence-client
1+
# Java framework for Cadence [![Build Status](https://travis-ci.org/uber-java/cadence-client.svg?branch=master)](https://travis-ci.org/uber-java/cadence-client) [![Coverage Status](https://coveralls.io/repos/uber-java/cadence-client/badge.svg?branch=master&service=github)](https://coveralls.io/github/uber-java/cadence-client?branch=master)
2+
[Cadence](https://github.com/uber/cadence) is a distributed, scalable, durable, and highly available orchestration engine we developed at Uber Engineering to execute asynchronous long-running business logic in a scalable and resilient way.
3+
4+
`cadence-client` is the framework for authoring workflows and activities.

license-header.txt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
3+
Modifications copyright (C) 2017 Uber Technologies, Inc.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License"). You may not
6+
use this file except in compliance with the License. A copy of the License is
7+
located at
8+
9+
http://aws.amazon.com/apache2.0
10+
11+
or in the "license" file accompanying this file. This file is distributed on
12+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13+
express or implied. See the License for the specific language governing
14+
permissions and limitations under the License.

pom.xml

+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
<?xml version="1.0"?>
2+
<project
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
4+
xmlns="http://maven.apache.org/POM/4.0.0"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
6+
<modelVersion>4.0.0</modelVersion>
7+
<groupId>com.uber</groupId>
8+
<artifactId>cadence-client</artifactId>
9+
<version>1.0.0</version>
10+
<packaging>jar</packaging>
11+
<name>Uber Cadence Java Client</name>
12+
<description>Library used to author Cadence workflows and activities in Java.
13+
</description>
14+
<url>https://github.com/uber-java/cadence-client</url>
15+
<licenses>
16+
<license>
17+
<name>Apache License, Version 2.0</name>
18+
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
19+
<distribution>repo</distribution>
20+
</license>
21+
</licenses>
22+
23+
<developers>
24+
<developer>
25+
<id>amazonwebservices</id>
26+
<organization>Amazon Web Services</organization>
27+
<organizationUrl>https://aws.amazon.com</organizationUrl>
28+
<roles>
29+
<role>swf-framework-java-developer</role>
30+
</roles>
31+
</developer>
32+
<developer>
33+
<id>uber</id>
34+
<organization>Uber</organization>
35+
<organizationUrl>https://uber.com</organizationUrl>
36+
<roles>
37+
<role>developer</role>
38+
</roles>
39+
</developer>
40+
41+
</developers>
42+
<scm>
43+
<url>https://github.com/uber-java/cadence-client.git</url>
44+
</scm>
45+
<properties>
46+
<java.version>1.8</java.version>
47+
<maven.compiler.source>1.8</maven.compiler.source>
48+
<maven.compiler.target>1.8</maven.compiler.target>
49+
</properties>
50+
51+
<dependencies>
52+
<dependency>
53+
<groupId>com.uber.tchannel</groupId>
54+
<artifactId>tchannel-core</artifactId>
55+
<version>0.7.6</version>
56+
</dependency>
57+
<dependency>
58+
<groupId>commons-logging</groupId>
59+
<artifactId>commons-logging</artifactId>
60+
<version>1.2</version>
61+
</dependency>
62+
<dependency>
63+
<groupId>org.apache.thrift</groupId>
64+
<artifactId>libthrift</artifactId>
65+
<version>0.10.0</version>
66+
<exclusions>
67+
<exclusion>
68+
<groupId>commons-logging</groupId>
69+
<artifactId>commons-logging</artifactId>
70+
</exclusion>
71+
</exclusions>
72+
</dependency>
73+
<dependency>
74+
<groupId>com.fasterxml.jackson.core</groupId>
75+
<artifactId>jackson-databind</artifactId>
76+
<version>2.9.2</version>
77+
</dependency>
78+
<!-- JUnit is needed to compile the support classes for the workflow service -->
79+
<dependency>
80+
<groupId>junit</groupId>
81+
<artifactId>junit</artifactId>
82+
<version>4.12</version>
83+
<scope>test</scope>
84+
</dependency>
85+
<dependency>
86+
<groupId>log4j</groupId>
87+
<artifactId>log4j</artifactId>
88+
<version>1.2.17</version>
89+
<scope>test</scope>
90+
</dependency>
91+
</dependencies>
92+
93+
<build>
94+
<plugins>
95+
<plugin><!-- newer official org.apache.thrift:thrift-maven-plugin:0.9.3 is broken -->
96+
<groupId>org.apache.thrift.tools</groupId>
97+
<artifactId>maven-thrift-plugin</artifactId>
98+
<version>0.1.11</version>
99+
<configuration>
100+
<generator>java:private-members</generator>
101+
</configuration>
102+
<executions>
103+
<execution>
104+
<goals>
105+
<goal>compile</goal>
106+
</goals>
107+
</execution>
108+
</executions>
109+
</plugin>
110+
<plugin>
111+
<groupId>org.apache.maven.plugins</groupId>
112+
<artifactId>maven-compiler-plugin</artifactId>
113+
<version>3.2</version>
114+
<configuration>
115+
<compilerVersion>${java.version}</compilerVersion>
116+
<source>${java.version}</source>
117+
<target>${java.version}</target>
118+
</configuration>
119+
</plugin>
120+
<plugin>
121+
<groupId>org.apache.maven.plugins</groupId>
122+
<artifactId>maven-javadoc-plugin</artifactId>
123+
<version>2.9.1</version>
124+
<configuration>
125+
<excludePackageNames>*.internal:*.transform</excludePackageNames>
126+
<minmemory>128m</minmemory>
127+
<maxmemory>1024m</maxmemory>
128+
</configuration>
129+
</plugin>
130+
<plugin>
131+
<groupId>com.mycila</groupId>
132+
<artifactId>license-maven-plugin</artifactId>
133+
<version>3.0</version>
134+
<configuration>
135+
<header>license-header.txt</header>
136+
<mapping>
137+
<java>SLASHSTAR_STYLE</java>
138+
</mapping>
139+
<excludes>
140+
<exclude>*</exclude>
141+
<exclude>src/test/resources/**</exclude>
142+
<exclude>src/main/resources/**</exclude>
143+
<exclude>src/main/thrift/**</exclude>
144+
</excludes>
145+
<errorMessage>Some files do not have the expected license header. Run "mvn license:format" to add.</errorMessage>
146+
</configuration>
147+
<executions>
148+
<execution>
149+
<phase>compile</phase>
150+
<goals>
151+
<goal>check</goal>
152+
</goals>
153+
</execution>
154+
</executions>
155+
</plugin>
156+
157+
</plugins>
158+
</build>
159+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Modifications copyright (C) 2017 Uber Technologies, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
7+
* use this file except in compliance with the License. A copy of the License is
8+
* located at
9+
*
10+
* http://aws.amazon.com/apache2.0
11+
*
12+
* or in the "license" file accompanying this file. This file is distributed on
13+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14+
* express or implied. See the License for the specific language governing
15+
* permissions and limitations under the License.
16+
*/
17+
package com.uber.cadence;
18+
19+
import com.uber.cadence.generic.ActivityImplementation;
20+
import com.uber.cadence.WorkflowService.Iface;
21+
22+
import java.util.concurrent.CancellationException;
23+
24+
/**
25+
* Context object passed to an activity implementation.
26+
*
27+
* @see ActivityImplementation
28+
*
29+
* @author fateev
30+
*/
31+
public abstract class ActivityExecutionContext {
32+
33+
/**
34+
* @return task token that is required to report task completion when
35+
* manual activity completion is used.
36+
*/
37+
public abstract byte[] getTaskToken();
38+
39+
/**
40+
* @return workfow execution that requested the activity execution
41+
*/
42+
public abstract com.uber.cadence.WorkflowExecution getWorkflowExecution();
43+
44+
/**
45+
* @return task that caused activity execution
46+
*/
47+
public abstract ActivityTask getTask();
48+
49+
/**
50+
* Use to notify Simple Workflow that activity execution is alive.
51+
*
52+
* @param details
53+
* In case of activity timeout details are returned as a field of
54+
* the exception thrown.
55+
* @throws CancellationException
56+
* Indicates that activity cancellation was requested by the
57+
* workflow.Should be rethrown from activity implementation to
58+
* indicate successful cancellation.
59+
*/
60+
public abstract void recordActivityHeartbeat(byte[] details)
61+
throws CancellationException;
62+
63+
/**
64+
* @return an instance of the Simple Workflow Java client that is the same
65+
* used by the invoked activity worker.
66+
*/
67+
public abstract Iface getService();
68+
69+
public String getDomain() {
70+
// Throwing implementation is provided to not break existing subclasses
71+
throw new UnsupportedOperationException();
72+
}
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Modifications copyright (C) 2017 Uber Technologies, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
7+
* use this file except in compliance with the License. A copy of the License is
8+
* located at
9+
*
10+
* http://aws.amazon.com/apache2.0
11+
*
12+
* or in the "license" file accompanying this file. This file is distributed on
13+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14+
* express or implied. See the License for the specific language governing
15+
* permissions and limitations under the License.
16+
*/
17+
package com.uber.cadence;
18+
19+
/**
20+
* Used to access execution context of the currently executed activity. An
21+
* implementation might rely on thread local storage. So it is guaranteed to
22+
* return current context only in the thread that invoked the activity
23+
* implementation. If activity implementation needs to pass its execution
24+
* context to other threads it has to do it explicitly.
25+
*
26+
* @author fateev
27+
*/
28+
public interface ActivityExecutionContextProvider {
29+
30+
public ActivityExecutionContext getActivityExecutionContext();
31+
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Modifications copyright (C) 2017 Uber Technologies, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
7+
* use this file except in compliance with the License. A copy of the License is
8+
* located at
9+
*
10+
* http://aws.amazon.com/apache2.0
11+
*
12+
* or in the "license" file accompanying this file. This file is distributed on
13+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14+
* express or implied. See the License for the specific language governing
15+
* permissions and limitations under the License.
16+
*/
17+
package com.uber.cadence;
18+
19+
import com.uber.cadence.worker.CurrentActivityExecutionContext;
20+
21+
/**
22+
* The default implementation of the ActivityExecutionContextProvider. Can be
23+
* shared across any number of activity implementation instances.
24+
*
25+
* @author fateev
26+
*/
27+
public class ActivityExecutionContextProviderImpl implements ActivityExecutionContextProvider {
28+
29+
@Override
30+
public ActivityExecutionContext getActivityExecutionContext() {
31+
return CurrentActivityExecutionContext.get();
32+
}
33+
34+
}

0 commit comments

Comments
 (0)