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 2222import com .uber .cadence .PollForDecisionTaskResponse ;
2323import com .uber .cadence .ServiceBusyError ;
2424import com .uber .cadence .TaskList ;
25+ import com .uber .cadence .common .BinaryChecksum ;
2526import com .uber .cadence .internal .metrics .MetricsTag ;
2627import com .uber .cadence .internal .metrics .MetricsType ;
2728import com .uber .cadence .serviceclient .IWorkflowService ;
@@ -64,6 +65,7 @@ public PollForDecisionTaskResponse poll() throws TException {
6465 PollForDecisionTaskRequest pollRequest = new PollForDecisionTaskRequest ();
6566 pollRequest .setDomain (domain );
6667 pollRequest .setIdentity (identity );
68+ pollRequest .setBinaryChecksum (BinaryChecksum .getBinaryChecksum ());
6769
6870 TaskList tl = new TaskList ();
6971 tl .setName (taskList );
Original file line number Diff line number Diff line change 3333import com .uber .cadence .WorkflowExecutionStartedEventAttributes ;
3434import com .uber .cadence .WorkflowQuery ;
3535import com .uber .cadence .WorkflowType ;
36+ import com .uber .cadence .common .BinaryChecksum ;
3637import com .uber .cadence .common .WorkflowExecutionHistory ;
3738import com .uber .cadence .internal .common .RpcRetryer ;
3839import com .uber .cadence .internal .common .WorkflowExecutionUtils ;
@@ -248,6 +249,7 @@ private void sendReply(
248249 if (taskCompleted != null ) {
249250 taskCompleted .setIdentity (options .getIdentity ());
250251 taskCompleted .setTaskToken (task .getTaskToken ());
252+ taskCompleted .setBinaryChecksum (BinaryChecksum .getBinaryChecksum ());
251253 RpcRetryer .retry (
252254 () -> {
253255 RespondDecisionTaskCompletedResponse taskCompletedResponse = null ;
@@ -321,6 +323,7 @@ private void sendReply(
321323 if (taskFailed != null ) {
322324 taskFailed .setIdentity (options .getIdentity ());
323325 taskFailed .setTaskToken (task .getTaskToken ());
326+ taskFailed .setBinaryChecksum (BinaryChecksum .getBinaryChecksum ());
324327 RpcRetryer .retry (() -> service .RespondDecisionTaskFailed (taskFailed ));
325328 } else {
326329 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