Skip to content

Commit 4d2510e

Browse files
authored
Merge branch 'master' into CDNC-3071
2 parents c7e2b69 + fdddfbc commit 4d2510e

File tree

61 files changed

+3762
-325
lines changed

Some content is hidden

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

61 files changed

+3762
-325
lines changed

.buildkite/pipeline.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ steps:
44
queue: "init"
55
docker: "*"
66
command: ".buildkite/scripts/fossa.sh"
7+
- label: "Lint Check"
8+
agents:
9+
queue: "init"
10+
docker: "*"
11+
command: ".buildkite/scripts/lint.sh"
12+
plugins:
13+
- docker-compose#v3.0.0:
14+
run: unit-test-test-service
15+
config: docker/buildkite/docker-compose.yaml
716
- label: ":java: Unit test with test services"
817
agents:
918
queue: "workers"

.buildkite/scripts/lint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
./gradlew goJF
6+
7+
if [ -n "$(git status --porcelain)" ]; then
8+
echo "There are changes after linting (used goJF) cmd: ./gradlew goJF"
9+
echo "Please rerun the command and commit the changes"
10+
git status --porcelain
11+
exit 1
12+
fi

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,34 @@
11
# Changelog
2+
3+
## 3.10.1
4+
- Fixed the bug: workflow already started for migration
5+
- Populate tasklistkind in poll request
6+
7+
## 3.10.0
8+
- Added migrationIWorkflowService
9+
- Added migrationInterceptor
10+
- Moved out TracingInterceptor from WorkflowTest to a separate package
11+
12+
## 3.9.1
13+
- Added initialization of contextPropagators from passed options
14+
- Updated rpc-caller header of grpc
15+
16+
## 3.9.0
17+
### Added
18+
- Add ability to override activity options
19+
- Add executeWorkflow method to WorkflowInterceptor
20+
- Add isolation group to service client options so that requests are populated with isolation group header
21+
- Add cause tag for transient poll failures
22+
- Add workflow start event and data converter to workflow info
23+
### Changed
24+
- Update dependencies
25+
- Remove unused code
26+
- Remove reflective objects exception due to failing builds
27+
- Fix the gradle project for M1 macs
28+
- Add cronschedule to history start event and fix isCron check of listworkflow for test env
29+
30+
## 3.8.1
31+
- remove opentelemetry-bom dependency.
232
## 3.8.0
333
- Graceful shutdown based on sigterm handler
434
- Adding cross domain signal/child workflow creation support

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ Add *cadence-client* as a dependency to your *pom.xml*:
3131
<dependency>
3232
<groupId>com.uber.cadence</groupId>
3333
<artifactId>cadence-client</artifactId>
34-
<version>3.0.0</version>
34+
<version>V.V.V</version>
3535
</dependency>
3636

3737
or to *build.gradle*:
3838

39-
compile group: 'com.uber.cadence', name: 'cadence-client', version: '3.0.0'
39+
compile group: 'com.uber.cadence', name: 'cadence-client', version: 'V.V.V'
4040

4141
## Documentation
4242

build.gradle

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ buildscript {
77

88
plugins {
99
id "com.github.hierynomus.license" version"0.15.0"
10-
id 'com.github.nbaztec.coveralls-jacoco' version '1.2.11'
11-
id 'com.github.sherter.google-java-format' version '0.8'
10+
id 'com.github.nbaztec.coveralls-jacoco' version '1.2.15'
11+
id 'com.github.sherter.google-java-format' version '0.9'
1212
id 'net.ltgt.errorprone' version '1.1.1'
1313
id 'java-library'
1414
id 'jacoco'
@@ -44,7 +44,7 @@ googleJavaFormat {
4444
}
4545

4646
group = 'com.uber.cadence'
47-
version = '3.8.0'
47+
version = '3.10.1-fix'
4848

4949
description = '''Uber Cadence Java Client'''
5050

@@ -58,26 +58,25 @@ dependencies {
5858
errorprone('com.google.errorprone:error_prone_core:2.3.4')
5959

6060
compile group: 'com.uber.tchannel', name: 'tchannel-core', version: '0.8.30'
61-
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
61+
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.36'
6262
compile group: 'org.apache.thrift', name: 'libthrift', version: '0.9.3'
63-
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
64-
compile group: 'com.uber.m3', name: 'tally-core', version: '0.4.0'
65-
compile group: 'com.google.guava', name: 'guava', version: '28.1-jre'
66-
compile group: 'com.cronutils', name: 'cron-utils', version: '9.0.0'
67-
compile group: 'io.micrometer', name: 'micrometer-core', version: '1.1.2'
63+
compile group: 'com.google.code.gson', name: 'gson', version: '2.10'
64+
compile group: 'com.uber.m3', name: 'tally-core', version: '0.11.1'
65+
compile group: 'com.google.guava', name: 'guava', version: '31.1-jre'
66+
compile group: 'com.cronutils', name: 'cron-utils', version: '9.2.0'
67+
compile group: 'io.micrometer', name: 'micrometer-core', version: '1.10.2'
6868
compile group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'
6969
compile group: 'com.auth0', name: 'java-jwt', version:'3.10.2'
70-
compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.8.0'
71-
compile group: 'com.google.api.grpc', name: 'proto-google-common-protos', version: '1.17.0'
72-
compile group: 'io.grpc', name: 'grpc-testing', version: '1.28.0'
73-
compile group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.21.1'
70+
compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.21.9'
71+
compile group: 'com.google.api.grpc', name: 'proto-google-common-protos', version: '2.10.0'
72+
compile group: 'io.grpc', name: 'grpc-testing', version: '1.51.0'
73+
compile group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.21.9'
7474

7575
implementation 'io.grpc:grpc-netty-shaded:1.28.0'
7676
implementation 'io.grpc:grpc-protobuf:1.28.0'
7777
implementation 'io.grpc:grpc-stub:1.28.0'
7878

79-
compile(platform("io.opentelemetry:opentelemetry-bom:1.19.0"))
80-
compile("io.opentelemetry:opentelemetry-api")
79+
compile("io.opentelemetry:opentelemetry-api:1.19.0")
8180

8281
testCompile group: 'junit', name: 'junit', version: '4.12'
8382
testCompile group: 'com.googlecode.junit-toolbox', name: 'junit-toolbox', version: '2.4'
@@ -120,11 +119,19 @@ sourceSets {
120119

121120
protobuf {
122121
protoc {
123-
artifact = 'com.google.protobuf:protoc:3.11.0'
122+
if (osdetector.os == "osx") {
123+
artifact = 'com.google.protobuf:protoc:3.11.0:osx-x86_64' // no arm version available
124+
} else {
125+
artifact = 'com.google.protobuf:protoc:3.11.0'
126+
}
124127
}
125128
plugins {
126129
grpc {
127-
artifact = 'io.grpc:protoc-gen-grpc-java:1.28.0'
130+
if (osdetector.os == "osx") {
131+
artifact = 'io.grpc:protoc-gen-grpc-java:1.28.0:osx-x86_64' // no arm version available
132+
} else {
133+
artifact = 'io.grpc:protoc-gen-grpc-java:1.28.0'
134+
}
128135
}
129136
}
130137
generateProtoTasks {

src/main/java/com/uber/cadence/activity/Activity.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,20 @@
163163
* }
164164
* </code></pre>
165165
*
166+
* <p>Caution: since using this sometimes implies "long" timeouts, activity-worker losses prior to
167+
* recording the {@link Activity#getTaskToken()} in an external system (or prior to another thread
168+
* calling it) may not be noticed until the "long" timeout occurs. This can be resolved by having
169+
* another system call {@link com.uber.cadence.client.ActivityCompletionClient#heartbeat(byte[],
170+
* Object)} while that external action is running, but there is currently no way to mitigate this
171+
* issue without these heartbeats. For in-process-only async completion, relying on heartbeating is
172+
* safe and reliable because these heartbeats should occur as long as the process / background
173+
* thread is still running.
174+
*
175+
* <p>If you cannot heartbeat and cannot tolerate this kind of delayed-activity-loss detection,
176+
* consider emulating a long activity via a signal channel instead: you can start a short-lived
177+
* activity and wait for a "saved to external system" signal, retrying as necessary, and then wait
178+
* for an "external system finished" signal containing the final result.
179+
*
166180
* <h3>Activity Heartbeating</h3>
167181
*
168182
* <p>Some activities are long running. To react to their crashes quickly, use a heartbeat
@@ -201,9 +215,23 @@
201215
public final class Activity {
202216

203217
/**
204-
* If this method is called during an activity execution then activity is not going to complete
205-
* when its method returns. It is expected to be completed asynchronously using {@link
218+
* If this method is called during an activity execution then activity will not complete when its
219+
* method returns. It is expected to be completed asynchronously using {@link
206220
* com.uber.cadence.client.ActivityCompletionClient}.
221+
*
222+
* <p>Caution: since using this sometimes implies "long" timeouts, activity-worker losses prior to
223+
* recording the {@link Activity#getTaskToken()} in an external system (or prior to another thread
224+
* calling it) may not be noticed until the "long" timeout occurs. This can be resolved by having
225+
* another system call {@link com.uber.cadence.client.ActivityCompletionClient#heartbeat(byte[],
226+
* Object)} while that external action is running, but there is currently no way to mitigate this
227+
* issue without these heartbeats. For in-process-only async completion, relying on heartbeating
228+
* is safe and reliable because these heartbeats should occur as long as the process / background
229+
* thread is still running.
230+
*
231+
* <p>If you cannot heartbeat and cannot tolerate this kind of delayed-activity-loss detection,
232+
* consider emulating a long activity via a signal channel instead: you can start a short-lived
233+
* activity and wait for a "saved to external system" signal, retrying as necessary, and then wait
234+
* for an "external system finished" signal containing the final result.
207235
*/
208236
public static void doNotCompleteOnReturn() {
209237
ActivityInternal.doNotCompleteOnReturn();

src/main/java/com/uber/cadence/client/WorkflowClientOptions.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static final class Builder {
5959
private DataConverter dataConverter = JsonDataConverter.getInstance();
6060
private WorkflowClientInterceptor[] interceptors = EMPTY_INTERCEPTOR_ARRAY;
6161
private Scope metricsScope = NoopScope.getInstance();
62-
private String identity = ManagementFactory.getRuntimeMXBean().getName();;
62+
private String identity = ManagementFactory.getRuntimeMXBean().getName();
6363
private List<ContextPropagator> contextPropagators = EMPTY_CONTEXT_PROPAGATORS;
6464
private QueryRejectCondition queryRejectCondition;
6565

@@ -71,6 +71,7 @@ private Builder(WorkflowClientOptions options) {
7171
interceptors = options.getInterceptors();
7272
metricsScope = options.getMetricsScope();
7373
identity = options.getIdentity();
74+
contextPropagators = options.getContextPropagators();
7475
queryRejectCondition = options.getQueryRejectCondition();
7576
}
7677

src/main/java/com/uber/cadence/internal/compatibility/proto/serviceclient/GrpcServiceStubs.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.uber.cadence.internal.compatibility.proto.serviceclient;
1717

18+
import com.google.common.base.Strings;
1819
import com.uber.cadence.api.v1.DomainAPIGrpc;
1920
import com.uber.cadence.api.v1.MetaAPIGrpc;
2021
import com.uber.cadence.api.v1.MetaAPIGrpc.MetaAPIBlockingStub;
@@ -61,6 +62,8 @@ final class GrpcServiceStubs implements IGrpcServiceStubs {
6162
Metadata.Key.of("cadence-client-feature-version", Metadata.ASCII_STRING_MARSHALLER);
6263
private static final Metadata.Key<String> CLIENT_IMPL_HEADER_KEY =
6364
Metadata.Key.of("cadence-client-name", Metadata.ASCII_STRING_MARSHALLER);
65+
private static final Metadata.Key<String> ISOLATION_GROUP_HEADER_KEY =
66+
Metadata.Key.of("cadence-client-isolation-group", Metadata.ASCII_STRING_MARSHALLER);
6467
private static final Metadata.Key<String> RPC_SERVICE_NAME_HEADER_KEY =
6568
Metadata.Key.of("rpc-service", Metadata.ASCII_STRING_MARSHALLER);
6669
private static final Metadata.Key<String> RPC_CALLER_NAME_HEADER_KEY =
@@ -103,8 +106,11 @@ final class GrpcServiceStubs implements IGrpcServiceStubs {
103106
headers.put(FEATURE_VERSION_HEADER_KEY, Version.FEATURE_VERSION);
104107
headers.put(CLIENT_IMPL_HEADER_KEY, CLIENT_IMPL_HEADER_VALUE);
105108
headers.put(RPC_SERVICE_NAME_HEADER_KEY, options.getServiceName());
106-
headers.put(RPC_CALLER_NAME_HEADER_KEY, CLIENT_IMPL_HEADER_VALUE);
109+
headers.put(RPC_CALLER_NAME_HEADER_KEY, options.getClientAppName());
107110
headers.put(RPC_ENCODING_HEADER_KEY, "proto");
111+
if (!Strings.isNullOrEmpty(options.getIsolationGroup())) {
112+
headers.put(ISOLATION_GROUP_HEADER_KEY, options.getIsolationGroup());
113+
}
108114
Channel interceptedChannel =
109115
ClientInterceptors.intercept(
110116
channel,

src/main/java/com/uber/cadence/internal/compatibility/thrift/EnumMapper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import com.uber.cadence.TimeoutType;
3636
import com.uber.cadence.WorkflowExecutionCloseStatus;
3737
import com.uber.cadence.WorkflowIdReusePolicy;
38-
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
3938

4039
class EnumMapper {
4140

@@ -270,7 +269,7 @@ public static EncodingType encodingType(com.uber.cadence.api.v1.EncodingType t)
270269
case ENCODING_TYPE_JSON:
271270
return EncodingType.JSON;
272271
case ENCODING_TYPE_PROTO3:
273-
throw new NotImplementedException();
272+
throw new UnsupportedOperationException();
274273
}
275274
throw new IllegalArgumentException("unexpected enum value");
276275
}

src/main/java/com/uber/cadence/internal/logging/LoggerTag.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,8 @@ public class LoggerTag {
2121
public static final String ACTIVITY_ID = "ActivityID";
2222
public static final String ACTIVITY_TYPE = "ActivityType";
2323
public static final String DOMAIN = "Domain";
24-
public static final String EVENT_ID = "EventID";
25-
public static final String EVENT_TYPE = "EventType";
2624
public static final String RUN_ID = "RunID";
2725
public static final String TASK_LIST = "TaskList";
28-
public static final String TIMER_ID = "TimerID";
2926
public static final String WORKFLOW_ID = "WorkflowID";
3027
public static final String WORKFLOW_TYPE = "WorkflowType";
31-
public static final String WORKER_ID = "WorkerID";
32-
public static final String WORKER_TYPE = "WorkerType";
33-
public static final String SIDE_EFFECT_ID = "SideEffectID";
34-
public static final String CHILD_WORKFLOW_ID = "ChildWorkflowID";
3528
}

src/main/java/com/uber/cadence/internal/metrics/MetricsTag.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,11 @@
1818
package com.uber.cadence.internal.metrics;
1919

2020
public class MetricsTag {
21-
public static final String ACTIVITY_ID = "ActivityID";
2221
public static final String ACTIVITY_TYPE = "ActivityType";
2322
public static final String DOMAIN = "Domain";
24-
public static final String EVENT_ID = "EventID";
25-
public static final String EVENT_TYPE = "EventType";
26-
public static final String RUN_ID = "RunID";
2723
public static final String TASK_LIST = "TaskList";
28-
public static final String TIMER_ID = "TimerID";
29-
public static final String WORKFLOW_ID = "WorkflowID";
3024
public static final String WORKFLOW_TYPE = "WorkflowType";
31-
public static final String WORKER_ID = "WorkerID";
32-
public static final String WORKER_TYPE = "WorkerType";
33-
public static final String SIDE_EFFECT_ID = "SideEffectID";
34-
public static final String CHILD_WORKFLOW_ID = "ChildWorkflowID";
3525
public static final String REQUEST_TYPE = "RequestType";
3626
public static final String VERSION = "Version";
27+
public static final String CAUSE = "Cause";
3728
}

src/main/java/com/uber/cadence/internal/metrics/MetricsTagValue.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@
2020
public class MetricsTagValue {
2121
public static final String REQUEST_TYPE_NORMAL = "normal";
2222
public static final String REQUEST_TYPE_LONG_POLL = "long-poll";
23+
public static final String SERVICE_BUSY = "serviceBusy";
24+
public static final String INTERNAL_SERVICE_ERROR = "internalServiceError";
2325
}

src/main/java/com/uber/cadence/internal/metrics/MetricsType.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public class MetricsType {
4141
CADENCE_METRICS_PREFIX + "workflow-get-history-latency";
4242
public static final String WORKFLOW_SIGNAL_WITH_START_COUNTER =
4343
CADENCE_METRICS_PREFIX + "workflow-signal-with-start";
44-
public static final String DECISION_TIMEOUT_COUNTER = CADENCE_METRICS_PREFIX + "decision-timeout";
4544

4645
public static final String DECISION_POLL_COUNTER = CADENCE_METRICS_PREFIX + "decision-poll-total";
4746
public static final String DECISION_POLL_FAILED_COUNTER =
@@ -60,8 +59,6 @@ public class MetricsType {
6059
CADENCE_METRICS_PREFIX + "decision-execution-failed";
6160
public static final String DECISION_EXECUTION_LATENCY =
6261
CADENCE_METRICS_PREFIX + "decision-execution-latency";
63-
public static final String DECISION_RESPONSE_FAILED_COUNTER =
64-
CADENCE_METRICS_PREFIX + "decision-response-failed";
6562
public static final String DECISION_RESPONSE_LATENCY =
6663
CADENCE_METRICS_PREFIX + "decision-response-latency";
6764
public static final String DECISION_TASK_ERROR_COUNTER =
@@ -90,8 +87,6 @@ public class MetricsType {
9087
CADENCE_METRICS_PREFIX + "activity-execution-latency";
9188
public static final String ACTIVITY_RESP_LATENCY =
9289
CADENCE_METRICS_PREFIX + "activity-response-latency";
93-
public static final String ACTIVITY_RESPONSE_FAILED_COUNTER =
94-
CADENCE_METRICS_PREFIX + "activity-response-failed";
9590
public static final String ACTIVITY_E2E_LATENCY =
9691
CADENCE_METRICS_PREFIX + "activity-endtoend-latency";
9792
public static final String ACTIVITY_TASK_ERROR_COUNTER =
@@ -110,8 +105,6 @@ public class MetricsType {
110105
CADENCE_METRICS_PREFIX + "activity-task-canceled-by-id";
111106
public static final String LOCAL_ACTIVITY_TOTAL_COUNTER =
112107
CADENCE_METRICS_PREFIX + "local-activity-total";
113-
public static final String LOCAL_ACTIVITY_TIMEOUT_COUNTER =
114-
CADENCE_METRICS_PREFIX + "local-activity-timeout";
115108
public static final String LOCAL_ACTIVITY_CANCELED_COUNTER =
116109
CADENCE_METRICS_PREFIX + "local-activity-canceled";
117110
public static final String LOCAL_ACTIVITY_FAILED_COUNTER =
@@ -120,8 +113,6 @@ public class MetricsType {
120113
CADENCE_METRICS_PREFIX + "local-activity-panic";
121114
public static final String LOCAL_ACTIVITY_EXECUTION_LATENCY =
122115
CADENCE_METRICS_PREFIX + "local-activity-execution-latency";
123-
public static final String LOCALLY_DISPATCHED_ACTIVITY_POLL_TOTAL_COUNTER =
124-
CADENCE_METRICS_PREFIX + "locally-dispatched-activity-poll-total";
125116
public static final String LOCALLY_DISPATCHED_ACTIVITY_POLL_NO_TASK_COUNTER =
126117
CADENCE_METRICS_PREFIX + "locally-dispatched-activity-poll-no-task";
127118
public static final String LOCALLY_DISPATCHED_ACTIVITY_POLL_SUCCEED_COUNTER =
@@ -130,17 +121,11 @@ public class MetricsType {
130121
CADENCE_METRICS_PREFIX + "activity-local-dispatch-failed";
131122
public static final String ACTIVITY_LOCAL_DISPATCH_SUCCEED_COUNTER =
132123
CADENCE_METRICS_PREFIX + "activity-local-dispatch-succeed";
133-
public static final String WORKER_PANIC_COUNTER = CADENCE_METRICS_PREFIX + "worker-panic";
134124
public static final String LOCAL_ACTIVITY_ACTIVE_THREAD_COUNT =
135125
CADENCE_METRICS_PREFIX + "local_activity_active_thread_count";
136126
public static final String ACTIVITY_ACTIVE_THREAD_COUNT =
137127
CADENCE_METRICS_PREFIX + "activity_active_thread_count";
138128

139-
public static final String TASK_LIST_QUEUE_LATENCY =
140-
CADENCE_METRICS_PREFIX + "tasklist-queue-latency";
141-
142-
public static final String UNHANDLED_SIGNALS_COUNTER =
143-
CADENCE_METRICS_PREFIX + "unhandled-signals";
144129
public static final String CORRUPTED_SIGNALS_COUNTER =
145130
CADENCE_METRICS_PREFIX + "corrupted-signals";
146131

@@ -158,7 +143,6 @@ public class MetricsType {
158143
CADENCE_METRICS_PREFIX + "sticky-cache-total-forced-eviction";
159144
public static final String STICKY_CACHE_THREAD_FORCED_EVICTION =
160145
CADENCE_METRICS_PREFIX + "sticky-cache-thread-forced-eviction";
161-
public static final String STICKY_CACHE_STALL = CADENCE_METRICS_PREFIX + "sticky-cache-stall";
162146
public static final String STICKY_CACHE_SIZE = CADENCE_METRICS_PREFIX + "sticky-cache-size";
163147
public static final String WORKFLOW_ACTIVE_THREAD_COUNT =
164148
CADENCE_METRICS_PREFIX + "workflow_active_thread_count";

0 commit comments

Comments
 (0)