File tree Expand file tree Collapse file tree 4 files changed +72
-0
lines changed
main/java/com/uber/cadence
test/java/com/uber/cadence/common Expand file tree Collapse file tree 4 files changed +72
-0
lines changed Original file line number Diff line number Diff line change
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
+
18
+ package com .uber .cadence .common ;
19
+
20
+ public final class BinaryChecksum {
21
+
22
+ private static String binaryChecksum ;
23
+
24
+ private BinaryChecksum () {}
25
+
26
+ public static String getBinaryChecksum () {
27
+ // TODO: should set the binaryChecksum to some auto generated value if it's empty
28
+ return binaryChecksum ;
29
+ }
30
+
31
+ public static synchronized void setBinaryChecksum (String checksum ) {
32
+ if (binaryChecksum != null || checksum == null || checksum .isEmpty ()) {
33
+ return ;
34
+ }
35
+ binaryChecksum = checksum ;
36
+ }
37
+ }
Original file line number Diff line number Diff line change 22
22
import com .uber .cadence .PollForDecisionTaskResponse ;
23
23
import com .uber .cadence .ServiceBusyError ;
24
24
import com .uber .cadence .TaskList ;
25
+ import com .uber .cadence .common .BinaryChecksum ;
25
26
import com .uber .cadence .internal .metrics .MetricsTag ;
26
27
import com .uber .cadence .internal .metrics .MetricsType ;
27
28
import com .uber .cadence .serviceclient .IWorkflowService ;
@@ -64,6 +65,7 @@ public PollForDecisionTaskResponse poll() throws TException {
64
65
PollForDecisionTaskRequest pollRequest = new PollForDecisionTaskRequest ();
65
66
pollRequest .setDomain (domain );
66
67
pollRequest .setIdentity (identity );
68
+ pollRequest .setBinaryChecksum (BinaryChecksum .getBinaryChecksum ());
67
69
68
70
TaskList tl = new TaskList ();
69
71
tl .setName (taskList );
Original file line number Diff line number Diff line change 33
33
import com .uber .cadence .WorkflowExecutionStartedEventAttributes ;
34
34
import com .uber .cadence .WorkflowQuery ;
35
35
import com .uber .cadence .WorkflowType ;
36
+ import com .uber .cadence .common .BinaryChecksum ;
36
37
import com .uber .cadence .common .WorkflowExecutionHistory ;
37
38
import com .uber .cadence .internal .common .RpcRetryer ;
38
39
import com .uber .cadence .internal .common .WorkflowExecutionUtils ;
@@ -248,6 +249,7 @@ private void sendReply(
248
249
if (taskCompleted != null ) {
249
250
taskCompleted .setIdentity (options .getIdentity ());
250
251
taskCompleted .setTaskToken (task .getTaskToken ());
252
+ taskCompleted .setBinaryChecksum (BinaryChecksum .getBinaryChecksum ());
251
253
RpcRetryer .retry (
252
254
() -> {
253
255
RespondDecisionTaskCompletedResponse taskCompletedResponse = null ;
@@ -321,6 +323,7 @@ private void sendReply(
321
323
if (taskFailed != null ) {
322
324
taskFailed .setIdentity (options .getIdentity ());
323
325
taskFailed .setTaskToken (task .getTaskToken ());
326
+ taskFailed .setBinaryChecksum (BinaryChecksum .getBinaryChecksum ());
324
327
RpcRetryer .retry (() -> service .RespondDecisionTaskFailed (taskFailed ));
325
328
} else {
326
329
RespondQueryTaskCompletedRequest queryCompleted = response .getQueryCompleted ();
Original file line number Diff line number Diff line change
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
+
18
+ package com .uber .cadence .common ;
19
+
20
+ import org .junit .Assert ;
21
+ import org .junit .Test ;
22
+
23
+ public class BinaryChecksumTest {
24
+ @ Test
25
+ public void testSetBinaryChecksum () {
26
+ BinaryChecksum .setBinaryChecksum ("123" );
27
+ BinaryChecksum .setBinaryChecksum ("456" );
28
+ Assert .assertEquals ("123" , BinaryChecksum .getBinaryChecksum ());
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments