Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

25 changes: 11 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,18 @@ This doc is intended for contributors to `cadence-java-client` (hopefully that's
## Development Environment

* Java 11 (currently, we use Java 11 to compile Java 8 code).
* Thrift 0.9.3 (use [homebrew](https://formulae.brew.sh/formula/thrift@0.9) or [distribution](https://downloads.apache.org/thrift/0.9.3/)). Alternatively you can install with `scripts/install-thrift-locally-osx.sh`.
* Gradle build tool [6.x](https://github.com/uber/cadence-java-client/blob/master/gradle/wrapper/gradle-wrapper.properties)
* Docker

:warning: Note 1: You must install the 0.9.x version of Thrift. Otherwise compiling would fail at error `error: package org.apache.thrift.annotation does not exist`

:warning: Note 2: It's currently compatible with Java 8 compiler but no guarantee in the future.
:warning: Note 1: It's currently compatible with Java 8 compiler but no guarantee in the future.

## IntelliJ IDE integration (Optional)

* Make sure you set the gradle path with the right version ([currently 6.x](https://github.com/uber/cadence-java-client/blob/master/gradle/wrapper/gradle-wrapper.properties))

![IntelliJ](https://user-images.githubusercontent.com/4523955/135696878-81c1e62e-eb04-45e6-9bcb-785ac38b6607.png)

* Then all the below `gradlew` command can be replaced with the Gradle plugin operation
* Then all the below `gradlew` command can be replaced with the Gradle plugin operation
![Gradle](https://user-images.githubusercontent.com/4523955/135696922-d43bc36d-18a4-4b7b-adee-0fe8300bf855.png)

## Licence headers
Expand Down Expand Up @@ -61,24 +58,24 @@ Comment out the first section in `publications` ( line 160 to line 191 in [this
2. Change the [version](https://github.com/uber/cadence-java-client/blob/c9ec6786aa9f866b0310292ea3ee5df63adc8799/build.gradle#L43) to add a `local` suffix. E.g.
```
version = '3.3.0'
````
to
````
to
```
version = '3.3.0-local'
```
```
Then run the command
```bash
./gradlew publishToMavenLocal
```
Now you have the local cadence-java-client in your machine using veriosn `3.3.0-local`

3. To test with Cadence Java Samples, [change](https://github.com/uber/cadence-java-samples/blob/master/build.gradle#L32) `mavenCentral()` to `mavenLocal()`
and also change the [version](https://github.com/uber/cadence-java-samples/blob/a79d8d6e5860cf9986bf549fc1f96badecb09f8f/build.gradle#L38) with your suffix.
and also change the [version](https://github.com/uber/cadence-java-samples/blob/a79d8d6e5860cf9986bf549fc1f96badecb09f8f/build.gradle#L38) with your suffix.

Then `./gradlew build` and refer to the sample repo for how to run the code(it needs to run with a [Cadence server](https://github.com/uber/cadence)).
Then `./gradlew build` and refer to the sample repo for how to run the code(it needs to run with a [Cadence server](https://github.com/uber/cadence)).

:warning: If you run into problem with `version.properties` [creation task](https://github.com/uber/cadence-java-client/blob/c9ec6786aa9f866b0310292ea3ee5df63adc8799/build.gradle#L109), you can comment the task out. It's okay for local testing.
The property file is being used by [Version class](https://github.com/uber/cadence-java-client/blob/master/src/main/java/com/uber/cadence/internal/Version.java#L39)to report the library version for logging/metrics.
:warning: If you run into problem with `version.properties` [creation task](https://github.com/uber/cadence-java-client/blob/c9ec6786aa9f866b0310292ea3ee5df63adc8799/build.gradle#L109), you can comment the task out. It's okay for local testing.
The property file is being used by [Version class](https://github.com/uber/cadence-java-client/blob/master/src/main/java/com/uber/cadence/internal/Version.java#L39)to report the library version for logging/metrics.

## Unit & Integration Test

Expand All @@ -92,10 +89,10 @@ The test by default will run with TestEnvironment without Cadence service. If yo
```bash
USE_DOCKER_SERVICE=true ./gradlew test
```
And sometimes it's important to test the non-sticky mode
And sometimes it's important to test the non-sticky mode
```bash
STICKY_OFF=true USE_DOCKER_SERVICE=true ./gradlew test
```

Also, if there is any Github Actions test failure that you cannot reproduce locally,
Also, if there is any Github Actions test failure that you cannot reproduce locally,
follow [github action docker-compose](./docker/github_actions/README.md) instructions to run the tests.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ dependencies {
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
errorprone('com.google.errorprone:error_prone_core:2.3.4')

compile group: 'com.uber.tchannel', name: 'tchannel-core', version: '0.8.30'
compile group: 'io.opentracing', name: 'opentracing-api', version: '0.33.0'
compile group: 'io.opentracing', name: 'opentracing-util', version: '0.33.0'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.36'
compile group: 'com.google.code.gson', name: 'gson', version: '2.10'
compile group: 'com.uber.m3', name: 'tally-core', version: '0.11.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,17 @@ private StartWorkflowExecutionRequest getStartRequest(
if (!Strings.isNullOrEmpty(startParameters.getCronSchedule())) {
request.setCronSchedule(startParameters.getCronSchedule());
}
request.setMemo(toMemoThrift(startParameters.getMemo()));
request.setSearchAttributes(toSearchAttributesThrift(startParameters.getSearchAttributes()));
request.setHeader(toHeaderThrift(startParameters.getContext()));
request.setMemo(toMemo(startParameters.getMemo()));
request.setSearchAttributes(toSearchAttributes(startParameters.getSearchAttributes()));
request.setHeader(toHeader(startParameters.getContext()));
if (startParameters.getDelayStart() != null) {
request.setDelayStartSeconds((int) startParameters.getDelayStart().getSeconds());
}

return request;
}

private Memo toMemoThrift(Map<String, byte[]> memo) {
private Memo toMemo(Map<String, byte[]> memo) {
if (memo == null || memo.isEmpty()) {
return null;
}
Expand All @@ -274,12 +274,12 @@ private Memo toMemoThrift(Map<String, byte[]> memo) {
for (Map.Entry<String, byte[]> item : memo.entrySet()) {
fields.put(item.getKey(), item.getValue());
}
Memo memoThrift = new Memo();
memoThrift.setFields(fields);
return memoThrift;
Memo memoEntity = new Memo();
memoEntity.setFields(fields);
return memoEntity;
}

private SearchAttributes toSearchAttributesThrift(Map<String, byte[]> searchAttributes) {
private SearchAttributes toSearchAttributes(Map<String, byte[]> searchAttributes) {
if (searchAttributes == null || searchAttributes.isEmpty()) {
return null;
}
Expand All @@ -288,22 +288,22 @@ private SearchAttributes toSearchAttributesThrift(Map<String, byte[]> searchAttr
for (Map.Entry<String, byte[]> item : searchAttributes.entrySet()) {
fields.put(item.getKey(), item.getValue());
}
SearchAttributes searchAttrThrift = new SearchAttributes();
searchAttrThrift.setIndexedFields(fields);
return searchAttrThrift;
SearchAttributes searchAttrEntity = new SearchAttributes();
searchAttrEntity.setIndexedFields(fields);
return searchAttrEntity;
}

private Header toHeaderThrift(Map<String, byte[]> headers) {
private Header toHeader(Map<String, byte[]> headers) {
if (headers == null || headers.isEmpty()) {
return null;
}
Map<String, byte[]> fields = new HashMap<>();
for (Map.Entry<String, byte[]> item : headers.entrySet()) {
fields.put(item.getKey(), item.getValue());
}
Header headerThrift = new Header();
headerThrift.setFields(fields);
return headerThrift;
Header headerEntity = new Header();
headerEntity.setFields(fields);
return headerEntity;
}

private RetryPolicy toRetryPolicy(RetryParameters retryParameters) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Consumer<Exception> scheduleActivityTask(
attributes.setRetryPolicy(retryParameters.toRetryPolicy());
}

attributes.setHeader(toHeaderThrift(parameters.getContext()));
attributes.setHeader(toHeader(parameters.getContext()));

long scheduledEventId = decisions.scheduleActivityTask(attributes);
context.setCompletionHandle(callback);
Expand Down Expand Up @@ -200,16 +200,16 @@ void handleActivityTaskTimedOut(HistoryEvent event) {
}
}

private Header toHeaderThrift(Map<String, byte[]> headers) {
private Header toHeader(Map<String, byte[]> headers) {
if (headers == null || headers.isEmpty()) {
return null;
}
Map<String, byte[]> fields = new HashMap<>();
for (Map.Entry<String, byte[]> item : headers.entrySet()) {
fields.put(item.getKey(), item.getValue());
}
Header headerThrift = new Header();
headerThrift.setFields(fields);
return headerThrift;
Header headerEntity = new Header();
headerEntity.setFields(fields);
return headerEntity;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Consumer<Exception> startChildWorkflow(
attributes.setCronSchedule(parameters.getCronSchedule());
}

attributes.setHeader(toHeaderThrift(parameters.getContext()));
attributes.setHeader(toHeader(parameters.getContext()));

ParentClosePolicy parentClosePolicy = parameters.getParentClosePolicy();
if (parentClosePolicy != null) {
Expand All @@ -172,17 +172,17 @@ Consumer<Exception> startChildWorkflow(
return new ChildWorkflowCancellationHandler(initiatedEventId, attributes.getWorkflowId());
}

private Header toHeaderThrift(Map<String, byte[]> headers) {
private Header toHeader(Map<String, byte[]> headers) {
if (headers == null || headers.isEmpty()) {
return null;
}
Map<String, byte[]> fields = new HashMap<>();
for (Map.Entry<String, byte[]> item : headers.entrySet()) {
fields.put(item.getKey(), item.getValue());
}
Header headerThrift = new Header();
headerThrift.setFields(fields);
return headerThrift;
Header headerEntity = new Header();
headerEntity.setFields(fields);
return headerEntity;
}

boolean isChildWorkflowExecutionStartedWithRetryOptions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ protected WorkflowExecutionHistory getFullHistory(String domain, WorkflowExecuti
RpcRetryer.DEFAULT_RPC_RETRY_OPTIONS,
() ->
WorkflowExecutionUtils.getHistoryPage(
nextPageToken, this.serviceClient, domain, execution.toThrift()));
nextPageToken, this.serviceClient, domain, execution.toEntity()));
pageToken = resp.getNextPageToken();

// TODO support raw history feature once server removes default Thrift encoding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void setRunId(String runId) {
this.runId = runId;
}

public com.uber.cadence.WorkflowExecution toThrift() {
public com.uber.cadence.WorkflowExecution toEntity() {
return new com.uber.cadence.WorkflowExecution().setWorkflowId(workflowId).setRunId(runId);
}

Expand Down
22 changes: 11 additions & 11 deletions src/main/java/com/uber/cadence/serviceclient/ClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ClientOptions {

private static final String DEFAULT_CLIENT_APP_NAME = "cadence-client";

/** Name of the Cadence service front end as required by TChannel. */
/** Name of the Cadence service front end. */
private static final String DEFAULT_SERVICE_NAME = "cadence-frontend";

private static final ClientOptions DEFAULT_INSTANCE;
Expand All @@ -59,23 +59,23 @@ public class ClientOptions {
private final String host;
private final int port;
private final ManagedChannel gRPCChannel;
/** The tChannel timeout in milliseconds */
/** The timeout in milliseconds */
private final long rpcTimeoutMillis;
/** The tChannel timeout for long poll calls in milliseconds */
/** The ttimeout for long poll calls in milliseconds */
private final long rpcLongPollTimeoutMillis;
/** The tChannel timeout for query workflow call in milliseconds */
/** The timeout for query workflow call in milliseconds */
private final long rpcQueryTimeoutMillis;
/** The tChannel timeout for list archived workflow call in milliseconds */
/** The timeout for list archived workflow call in milliseconds */
private final long rpcListArchivedWorkflowTimeoutMillis;
/** TChannel service name that the Cadence service was started with. */
/** Grpc Service name that the Cadence service was started with. */
private final String serviceName;
/** Name of the service using the cadence-client. */
private final String clientAppName;
/** Client for metrics reporting. */
private final Scope metricsScope;
/** Optional TChannel transport headers */
/** Optional transport headers */
private final Map<String, String> transportHeaders;
/** Optional TChannel headers */
/** Optional headers */
private final Map<String, String> headers;
/** Optional authorization provider */
private final IAuthorizationProvider authProvider;
Expand Down Expand Up @@ -320,8 +320,8 @@ public Builder setFeatureFlags(FeatureFlags featureFlags) {
/**
* Sets the client application name.
*
* <p>This name will be used as the tchannel client service name. It will also be reported as a
* tag along with metrics emitted to m3.
* <p>This name will be used as the client service name. It will also be reported as a tag along
* with metrics emitted to m3.
*
* @param clientAppName String representing the client application name.
* @return Builder for ClentOptions
Expand Down Expand Up @@ -354,7 +354,7 @@ public Builder setMetricsScope(Scope metricsScope) {
}

/**
* Sets additional transport headers for tchannel client.
* Sets additional transport headers for client.
*
* @param transportHeaders Map with additional transport headers
* @return Builder for ClentOptions
Expand Down
Loading