Skip to content

Commit 0341953

Browse files
author
Maxim Fateev
committed
Switched to slf4j and logback. Fixed README
1 parent 6a337cd commit 0341953

18 files changed

+85
-74
lines changed

README.md

Lines changed: 52 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,47 @@ These are some samples to demonstrate various capabilities of Java Cadence clien
44
* Java Cadence Client: https://github.com/uber-java/cadence-client
55
* Go Cadence Client: https://github.com/uber-go/cadence-client
66

7-
## Prerequisite
8-
Run Cadence Server
9-
10-
See instructions for running the Cadence Server: https://github.com/uber/cadence/blob/master/README.md
11-
12-
## Build Samples
13-
14-
We are working on getting [cadence-client library](https://github.com/uber-java/cadence-client) into a public Maven repository.
15-
In the meantime before running samples it has to be build to get it into the local maven cache.
16-
See instructions from the Cadence Client README for the instructions.
17-
18-
After cadence-client library is available just run
19-
20-
./gradlew build`
21-
22-
to build the samples. Verify that they actually can run:
23-
24-
./gradlew execute -PmainClass=com.uber.cadence.samples.hello.HelloActivity
25-
267
## Overview of the Samples
278

28-
* **HelloWorld** -- obligatory single activity workflow.
29-
30-
* **PeriodicWorkflow** -- shows how to create a workflow that periodically executes an activity which name
31-
and arguments are specified at runtime.
32-
The workflow can run for extended periods and hence it uses the _continue as new execution_ feature.
9+
* **HelloWorld Samples**
10+
* _HelloActivity_ is a sample of a single activity workflow
11+
* _HelloActivityRetry_ demonstrates how to retry an activity
12+
* _HelloAsync_ is a sample of how to call activities asynchronously and wait for them using Promises.
13+
* _HelloAsyncLambda_ is a sample of how to run a part of a workflow asynchronously in a separate task (thread).
14+
* _HelloAsyncActivityCompletion_ is a sample of an asynchronous activity implementation.
15+
* _HelloChild_ is a sample of a child workflow
16+
* _HelloException_ demonstrates exception propagation and wrapping
17+
* HelloQuery is a sample of a query
18+
* HelloSignal is a sample of sending and handling a signal.
19+
* HelloPeriodic is a sample workflow that executes an activity periodically forever.
3320

3421
* **FileProcessing** -- shows a workflow for media processing use case. The sample workflow
3522
downloads a file from an Amazon S3 bucket, creates a zip file and uploads that zip file back to
36-
S3. The sample uses the task routing feature.
23+
S3. The sample uses the task routing feature. Requires AWS credentials.
3724

3825
* **SplitMerge** -- the workflow in this sample processes a large data set by splitting it up into
3926
smaller data sets. The sample calculates the average of a large set of numbers stored in a file in
4027
S3. The smaller data sets are assigned to workers and the results of processing are merged to
41-
produce the final result.
28+
produce the final result. Requires S3 credentials.
29+
30+
## Build Samples
31+
32+
We are working on getting [cadence-client library](https://github.com/uber-java/cadence-client) into a public Maven repository.
33+
In the meantime before running samples it has to be build to get it into the local maven cache.
34+
See instructions from the Cadence Client README for the instructions.
35+
36+
After cadence-client library is available just run
37+
38+
./gradlew build`
39+
40+
to build the samples. Verify that they actually can run:
4241

42+
./gradlew -q execute -PmainClass=com.uber.cadence.samples.hello.HelloActivity
43+
44+
4345
## Configuring Service and S3 Access Keys
4446

45-
If you are running local container the HelloWorld and PeriodicWorkflow samples do not need any additional configuration.
47+
If you are running local container the HelloWorld samples do not need any additional configuration.
4648

4749
The steps for configuring and building other samples for Java Cadence Client are:
4850

@@ -75,11 +77,19 @@ The steps for configuring and building other samples for Java Cadence Client are
7577

7678
set AWS_SWF_SAMPLES_CONFIG=<Your SDK Directory>
7779

80+
## Prerequisite
81+
Run Cadence Server
82+
83+
curl -O https://raw.githubusercontent.com/uber/cadence/master/docker/docker-compose.yml
84+
docker-compose up
85+
86+
If it does not work see instructions for running the Cadence Server at https://github.com/uber/cadence/blob/master/README.md
87+
7888
## Registering Domain
7989

8090
Run it once before running any samples to register domain.
8191

82-
./gradlew execute -PmainClass=com.uber.cadence.samples.common.RegisterDomain
92+
./gradlew -q execute -PmainClass=com.uber.cadence.samples.common.RegisterDomain
8393

8494
## Running the samples
8595

@@ -90,7 +100,16 @@ you've built them using the preceding instructions.
90100

91101
To run hello world:
92102

93-
./gradlew execute -PmainClass=com.uber.cadence.samples.hello.HelloActivity
103+
./gradlew -q execute -PmainClass=com.uber.cadence.samples.hello.HelloActivity
104+
./gradlew -q execute -PmainClass=com.uber.cadence.samples.hello.HelloActivityRetry
105+
./gradlew -q execute -PmainClass=com.uber.cadence.samples.hello.HelloAsync
106+
./gradlew -q execute -PmainClass=com.uber.cadence.samples.hello.HelloAsyncActivityCompletion
107+
./gradlew -q execute -PmainClass=com.uber.cadence.samples.hello.HelloAsyncLambda
108+
./gradlew -q execute -PmainClass=com.uber.cadence.samples.hello.HelloChild
109+
./gradlew -q execute -PmainClass=com.uber.cadence.samples.hello.HelloException
110+
./gradlew -q execute -PmainClass=com.uber.cadence.samples.hello.HelloPeriodic
111+
./gradlew -q execute -PmainClass=com.uber.cadence.samples.hello.HelloQuery
112+
./gradlew -q execute -PmainClass=com.uber.cadence.samples.hello.HelloSignal
94113

95114
### File Processing
96115

@@ -107,16 +126,16 @@ bucket that you want the sample to use:
107126
The sample has two executables. You should run each command in a separate terminal window. The first one
108127
is the worker that hosts workflow and activities implementation:
109128

110-
./gradlew execute -PmainClass=com.uber.cadence.samples.fileprocessing.FileProcessingWorker
129+
./gradlew -q execute -PmainClass=com.uber.cadence.samples.fileprocessing.FileProcessingWorker
111130

112131
The second is responsible for starting workflows:
113132

114-
./gradlew execute -PmainClass=com.uber.cadence.samples.fileprocessing.FileProcessingStarter
133+
./gradlew -q execute -PmainClass=com.uber.cadence.samples.fileprocessing.FileProcessingStarter
115134

116135
### Split Merge
117136

118137
The sample has two executables. You should run each command in a separate terminal window.
119138

120-
./gradlew execute -PmainClass=com.uber.cadence.samples.splitmerge.SplitMergeWorker
121-
./gradlew execute -PmainClass=com.uber.cadence.samples.splitmerge.SplitMergeStarter
139+
./gradlew -q execute -PmainClass=com.uber.cadence.samples.splitmerge.SplitMergeWorker
140+
./gradlew -q execute -PmainClass=com.uber.cadence.samples.splitmerge.SplitMergeStarter
122141

build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies {
2828
compile group: 'com.uber', name: 'cadence-client', version: '0.2.0-SNAPSHOT'
2929
compile group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: '1.11.274'
3030
compile group: 'commons-configuration', name: 'commons-configuration', version: '1.9'
31-
compile group: 'log4j', name: 'log4j', version: '1.2.17'
31+
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
3232
}
3333

3434
task execute(type: JavaExec) {
@@ -41,5 +41,4 @@ license {
4141
mapping {
4242
java = 'SLASHSTAR_STYLE'
4343
}
44-
strictCheck true
4544
}

src/main/java/com/uber/cadence/samples/common/ConfigHelper.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
import com.amazonaws.services.s3.AmazonS3Client;
2323
import com.uber.cadence.WorkflowService;
2424
import com.uber.cadence.serviceclient.WorkflowServiceTChannel;
25-
import org.apache.log4j.BasicConfigurator;
26-
import org.apache.log4j.Level;
27-
import org.apache.log4j.Logger;
2825

2926
import java.io.File;
3027
import java.io.FileInputStream;
@@ -87,11 +84,6 @@ private void loadProperties(File propertiesFile) throws IOException {
8784
}
8885

8986
public static ConfigHelper createConfig() throws IOException, IllegalArgumentException {
90-
91-
BasicConfigurator.configure();
92-
Logger.getRootLogger().setLevel(Level.DEBUG);
93-
94-
Logger.getLogger("io.netty").setLevel(Level.INFO);
9587
// Uncomment to see decisions sent to the Cadence
9688
// Logger.getLogger(DecisionTaskPoller.class.getName() + ".decisions").setLevel(Level.TRACE);
9789

src/main/java/com/uber/cadence/samples/common/QueryWorkflowExecution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
import com.uber.cadence.WorkflowExecution;
2020
import com.uber.cadence.WorkflowService;
21-
import com.uber.cadence.client.WorkflowClient;
2221
import com.uber.cadence.client.UntypedWorkflowStub;
22+
import com.uber.cadence.client.WorkflowClient;
2323

2424
/**
2525
* Simple example utility to query workflow execution using Cadence query API.

src/main/java/com/uber/cadence/samples/common/RegisterDomain.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
import com.uber.cadence.DomainConfiguration;
2121
import com.uber.cadence.RegisterDomainRequest;
2222
import com.uber.cadence.UpdateDomainRequest;
23-
import com.uber.cadence.WorkflowExecution;
2423
import com.uber.cadence.WorkflowService;
25-
import com.uber.cadence.internal.common.WorkflowExecutionUtils;
2624
import org.apache.thrift.TException;
2725

2826
import java.io.IOException;

src/main/java/com/uber/cadence/samples/fileprocessing/FileProcessingStarter.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
*/
1717
package com.uber.cadence.samples.fileprocessing;
1818

19-
import com.uber.cadence.WorkflowExecution;
2019
import com.uber.cadence.WorkflowService;
2120
import com.uber.cadence.client.WorkflowClient;
22-
import com.uber.cadence.client.WorkflowOptions;
2321
import com.uber.cadence.samples.common.ConfigHelper;
2422

2523
/**

src/main/java/com/uber/cadence/samples/fileprocessing/FileProcessingWorker.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.net.InetAddress;
2727
import java.net.UnknownHostException;
2828
import java.time.Duration;
29-
import java.util.concurrent.TimeUnit;
3029

3130
/**
3231
* This is the process which hosts all workflows and activities in this sample

src/main/java/com/uber/cadence/samples/fileprocessing/FileProcessingWorkflow.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@
1616
*/
1717
package com.uber.cadence.samples.fileprocessing;
1818

19-
import com.uber.cadence.workflow.QueryMethod;
20-
import com.uber.cadence.workflow.SignalMethod;
2119
import com.uber.cadence.workflow.WorkflowMethod;
2220

23-
import java.util.List;
24-
2521
/**
2622
* Contract for file processing workflow
2723
*/

src/main/java/com/uber/cadence/samples/hello/HelloActivity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.uber.cadence.worker.Worker;
2222
import com.uber.cadence.workflow.Workflow;
2323
import com.uber.cadence.workflow.WorkflowMethod;
24-
import org.apache.log4j.BasicConfigurator;
2524

2625
import static com.uber.cadence.samples.common.SampleConstants.DOMAIN;
2726

src/main/java/com/uber/cadence/samples/hello/HelloActivityRetry.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import com.uber.cadence.workflow.Functions;
2525
import com.uber.cadence.workflow.Workflow;
2626
import com.uber.cadence.workflow.WorkflowMethod;
27-
import org.apache.log4j.BasicConfigurator;
2827

2928
import java.time.Duration;
3029

0 commit comments

Comments
 (0)