Skip to content

Commit 42e570d

Browse files
authored
Added implementation of ResetWorkflowExecution service method (#448)
1 parent 6545adb commit 42e570d

File tree

2 files changed

+116
-4
lines changed

2 files changed

+116
-4
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public class ServiceMethod {
7171
MetricsType.CADENCE_METRICS_PREFIX + "RespondDecisionTaskFailed";
7272
public static final String SIGNAL_WORKFLOW_EXECUTION =
7373
MetricsType.CADENCE_METRICS_PREFIX + "SignalWorkflowExecution";
74+
public static final String RESET_WORKFLOW_EXECUTION =
75+
MetricsType.CADENCE_METRICS_PREFIX + "ResetWorkflowExecution";
7476
public static final String SIGNAL_WITH_START_WORKFLOW_EXECUTION =
7577
MetricsType.CADENCE_METRICS_PREFIX + "SignalWithStartWorkflowExecution";
7678
public static final String START_WORKFLOW_EXECUTION =

src/main/java/com/uber/cadence/serviceclient/WorkflowServiceTChannel.java

Lines changed: 114 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,9 @@ private PollForDecisionTaskResponse pollForDecisionTask(PollForDecisionTaskReque
905905
if (result.isSetEntityNotExistError()) {
906906
throw result.getEntityNotExistError();
907907
}
908+
if (result.isSetClientVersionNotSupportedError()) {
909+
throw result.getClientVersionNotSupportedError();
910+
}
908911
throw new TException("PollForDecisionTask failed with unknown error:" + result);
909912
} finally {
910913
if (response != null) {
@@ -950,6 +953,9 @@ private RespondDecisionTaskCompletedResponse respondDecisionTaskCompleted(
950953
if (result.isSetEntityNotExistError()) {
951954
throw result.getEntityNotExistError();
952955
}
956+
if (result.isSetClientVersionNotSupportedError()) {
957+
throw result.getClientVersionNotSupportedError();
958+
}
953959
throw new TException("RespondDecisionTaskCompleted failed with unknown error:" + result);
954960
} finally {
955961
if (response != null) {
@@ -997,6 +1003,9 @@ private void respondDecisionTaskFailed(RespondDecisionTaskFailedRequest failedRe
9971003
if (result.isSetEntityNotExistError()) {
9981004
throw result.getEntityNotExistError();
9991005
}
1006+
if (result.isSetClientVersionNotSupportedError()) {
1007+
throw result.getClientVersionNotSupportedError();
1008+
}
10001009
throw new TException("RespondDecisionTaskFailed failed with unknown error:" + result);
10011010
} finally {
10021011
if (response != null) {
@@ -1042,6 +1051,9 @@ private PollForActivityTaskResponse pollForActivityTask(PollForActivityTaskReque
10421051
if (result.isSetLimitExceededError()) {
10431052
throw result.getLimitExceededError();
10441053
}
1054+
if (result.isSetClientVersionNotSupportedError()) {
1055+
throw result.getClientVersionNotSupportedError();
1056+
}
10451057
throw new TException("PollForActivityTask failed with unknown error:" + result);
10461058
} finally {
10471059
if (response != null) {
@@ -1086,6 +1098,9 @@ private RecordActivityTaskHeartbeatResponse recordActivityTaskHeartbeat(
10861098
if (result.isSetLimitExceededError()) {
10871099
throw result.getLimitExceededError();
10881100
}
1101+
if (result.isSetClientVersionNotSupportedError()) {
1102+
throw result.getClientVersionNotSupportedError();
1103+
}
10891104
throw new TException("RecordActivityTaskHeartbeat failed with unknown error:" + result);
10901105
} finally {
10911106
if (response != null) {
@@ -1133,6 +1148,9 @@ private RecordActivityTaskHeartbeatResponse recordActivityTaskHeartbeatByID(
11331148
if (result.isSetLimitExceededError()) {
11341149
throw result.getLimitExceededError();
11351150
}
1151+
if (result.isSetClientVersionNotSupportedError()) {
1152+
throw result.getClientVersionNotSupportedError();
1153+
}
11361154
throw new TException("RecordActivityTaskHeartbeatByID failed with unknown error:" + result);
11371155
} finally {
11381156
if (response != null) {
@@ -1177,6 +1195,9 @@ private void respondActivityTaskCompleted(RespondActivityTaskCompletedRequest co
11771195
if (result.isSetLimitExceededError()) {
11781196
throw result.getLimitExceededError();
11791197
}
1198+
if (result.isSetClientVersionNotSupportedError()) {
1199+
throw result.getClientVersionNotSupportedError();
1200+
}
11801201
throw new TException("RespondActivityTaskCompleted failed with unknown error:" + result);
11811202
} finally {
11821203
if (response != null) {
@@ -1222,6 +1243,9 @@ private void respondActivityTaskCompletedByID(
12221243
if (result.isSetLimitExceededError()) {
12231244
throw result.getLimitExceededError();
12241245
}
1246+
if (result.isSetClientVersionNotSupportedError()) {
1247+
throw result.getClientVersionNotSupportedError();
1248+
}
12251249
throw new TException("RespondActivityTaskCompletedByID failed with unknown error:" + result);
12261250
} finally {
12271251
if (response != null) {
@@ -1266,6 +1290,9 @@ private void respondActivityTaskFailed(RespondActivityTaskFailedRequest failRequ
12661290
if (result.isSetLimitExceededError()) {
12671291
throw result.getLimitExceededError();
12681292
}
1293+
if (result.isSetClientVersionNotSupportedError()) {
1294+
throw result.getClientVersionNotSupportedError();
1295+
}
12691296
throw new TException("RespondActivityTaskFailed failed with unknown error:" + result);
12701297
} finally {
12711298
if (response != null) {
@@ -1311,6 +1338,9 @@ private void respondActivityTaskFailedByID(RespondActivityTaskFailedByIDRequest
13111338
if (result.isSetLimitExceededError()) {
13121339
throw result.getLimitExceededError();
13131340
}
1341+
if (result.isSetClientVersionNotSupportedError()) {
1342+
throw result.getClientVersionNotSupportedError();
1343+
}
13141344
throw new TException("RespondActivityTaskFailedByID failedByID with unknown error:" + result);
13151345
} finally {
13161346
if (response != null) {
@@ -1355,6 +1385,9 @@ private void respondActivityTaskCanceled(RespondActivityTaskCanceledRequest canc
13551385
if (result.isSetLimitExceededError()) {
13561386
throw result.getLimitExceededError();
13571387
}
1388+
if (result.isSetClientVersionNotSupportedError()) {
1389+
throw result.getClientVersionNotSupportedError();
1390+
}
13581391
throw new TException("RespondActivityTaskCanceled failed with unknown error:" + result);
13591392
} finally {
13601393
if (response != null) {
@@ -1400,6 +1433,9 @@ private void respondActivityTaskCanceledByID(
14001433
if (result.isSetLimitExceededError()) {
14011434
throw result.getLimitExceededError();
14021435
}
1436+
if (result.isSetClientVersionNotSupportedError()) {
1437+
throw result.getClientVersionNotSupportedError();
1438+
}
14031439
throw new TException("RespondActivityTaskCanceledByID failed with unknown error:" + result);
14041440
} finally {
14051441
if (response != null) {
@@ -1449,6 +1485,9 @@ private void requestCancelWorkflowExecution(RequestCancelWorkflowExecutionReques
14491485
if (result.isSetLimitExceededError()) {
14501486
throw result.getLimitExceededError();
14511487
}
1488+
if (result.isSetClientVersionNotSupportedError()) {
1489+
throw result.getClientVersionNotSupportedError();
1490+
}
14521491
throw new TException("RequestCancelWorkflowExecution failed with unknown error:" + result);
14531492
} finally {
14541493
if (response != null) {
@@ -1492,6 +1531,9 @@ private void signalWorkflowExecution(SignalWorkflowExecutionRequest signalReques
14921531
if (result.isSetLimitExceededError()) {
14931532
throw result.getLimitExceededError();
14941533
}
1534+
if (result.isSetClientVersionNotSupportedError()) {
1535+
throw result.getClientVersionNotSupportedError();
1536+
}
14951537
throw new TException("SignalWorkflowExecution failed with unknown error:" + result);
14961538
} finally {
14971539
if (response != null) {
@@ -1508,13 +1550,53 @@ public StartWorkflowExecutionResponse SignalWithStartWorkflowExecution(
15081550
() -> signalWithStartWorkflowExecution(signalWithStartRequest));
15091551
}
15101552

1511-
// TODO: https://github.com/uber/cadence-java-client/issues/359
15121553
@Override
15131554
public ResetWorkflowExecutionResponse ResetWorkflowExecution(
15141555
ResetWorkflowExecutionRequest resetRequest)
15151556
throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
15161557
DomainNotActiveError, LimitExceededError, ClientVersionNotSupportedError, TException {
1517-
return null;
1558+
return measureRemoteCall(
1559+
ServiceMethod.RESET_WORKFLOW_EXECUTION, () -> resetWorkflowExecution(resetRequest));
1560+
}
1561+
1562+
private ResetWorkflowExecutionResponse resetWorkflowExecution(
1563+
ResetWorkflowExecutionRequest resetRequest) throws TException {
1564+
ThriftResponse<WorkflowService.ResetWorkflowExecution_result> response = null;
1565+
try {
1566+
ThriftRequest<WorkflowService.ResetWorkflowExecution_args> request =
1567+
buildThriftRequest(
1568+
"ResetWorkflowExecution",
1569+
new WorkflowService.ResetWorkflowExecution_args(resetRequest));
1570+
response = doRemoteCall(request);
1571+
WorkflowService.ResetWorkflowExecution_result result =
1572+
response.getBody(WorkflowService.ResetWorkflowExecution_result.class);
1573+
if (response.getResponseCode() == ResponseCode.OK) {
1574+
return result.getSuccess();
1575+
}
1576+
if (result.isSetBadRequestError()) {
1577+
throw result.getBadRequestError();
1578+
}
1579+
if (result.isSetEntityNotExistError()) {
1580+
throw result.getEntityNotExistError();
1581+
}
1582+
if (result.isSetServiceBusyError()) {
1583+
throw result.getServiceBusyError();
1584+
}
1585+
if (result.isSetDomainNotActiveError()) {
1586+
throw result.getDomainNotActiveError();
1587+
}
1588+
if (result.isSetLimitExceededError()) {
1589+
throw result.getLimitExceededError();
1590+
}
1591+
if (result.isSetClientVersionNotSupportedError()) {
1592+
throw result.getClientVersionNotSupportedError();
1593+
}
1594+
throw new TException("ResetWorkflowExecution failed with unknown error:" + result);
1595+
} finally {
1596+
if (response != null) {
1597+
response.release();
1598+
}
1599+
}
15181600
}
15191601

15201602
private StartWorkflowExecutionResponse signalWithStartWorkflowExecution(
@@ -1550,6 +1632,9 @@ private StartWorkflowExecutionResponse signalWithStartWorkflowExecution(
15501632
if (result.isSetDomainNotActiveError()) {
15511633
throw result.getDomainNotActiveError();
15521634
}
1635+
if (result.isSetClientVersionNotSupportedError()) {
1636+
throw result.getClientVersionNotSupportedError();
1637+
}
15531638
throw new TException("SignalWithStartWorkflowExecution failed with unknown error:" + result);
15541639
} finally {
15551640
if (response != null) {
@@ -1594,6 +1679,9 @@ private void terminateWorkflowExecution(TerminateWorkflowExecutionRequest termin
15941679
if (result.isSetLimitExceededError()) {
15951680
throw result.getLimitExceededError();
15961681
}
1682+
if (result.isSetClientVersionNotSupportedError()) {
1683+
throw result.getClientVersionNotSupportedError();
1684+
}
15971685
throw new TException("TerminateWorkflowExecution failed with unknown error:" + result);
15981686
} finally {
15991687
if (response != null) {
@@ -1635,6 +1723,9 @@ private ListOpenWorkflowExecutionsResponse listOpenWorkflowExecutions(
16351723
if (result.isSetLimitExceededError()) {
16361724
throw result.getLimitExceededError();
16371725
}
1726+
if (result.isSetClientVersionNotSupportedError()) {
1727+
throw result.getClientVersionNotSupportedError();
1728+
}
16381729
throw new TException("ListOpenWorkflowExecutions failed with unknown error:" + result);
16391730
} finally {
16401731
if (response != null) {
@@ -1673,6 +1764,9 @@ private ListClosedWorkflowExecutionsResponse listClosedWorkflowExecutions(
16731764
if (result.isSetServiceBusyError()) {
16741765
throw result.getServiceBusyError();
16751766
}
1767+
if (result.isSetClientVersionNotSupportedError()) {
1768+
throw result.getClientVersionNotSupportedError();
1769+
}
16761770
throw new TException("ListClosedWorkflowExecutions failed with unknown error:" + result);
16771771
} finally {
16781772
if (response != null) {
@@ -1922,6 +2016,9 @@ private void respondQueryTaskCompleted(RespondQueryTaskCompletedRequest complete
19222016
if (result.isSetLimitExceededError()) {
19232017
throw result.getLimitExceededError();
19242018
}
2019+
if (result.isSetClientVersionNotSupportedError()) {
2020+
throw result.getClientVersionNotSupportedError();
2021+
}
19252022
throw new TException("RespondQueryTaskCompleted failed with unknown error:" + result);
19262023
} finally {
19272024
if (response != null) {
@@ -1958,7 +2055,9 @@ private QueryWorkflowResponse queryWorkflow(QueryWorkflowRequest queryRequest) t
19582055
if (result.isSetQueryFailedError()) {
19592056
throw result.getQueryFailedError();
19602057
}
1961-
2058+
if (result.isSetClientVersionNotSupportedError()) {
2059+
throw result.getClientVersionNotSupportedError();
2060+
}
19622061
throw new TException("QueryWorkflow failed with unknown error:" + result);
19632062
} finally {
19642063
if (response != null) {
@@ -2005,6 +2104,9 @@ private ResetStickyTaskListResponse resetStickyTaskList(ResetStickyTaskListReque
20052104
if (result.isSetLimitExceededError()) {
20062105
throw result.getLimitExceededError();
20072106
}
2107+
if (result.isSetClientVersionNotSupportedError()) {
2108+
throw result.getClientVersionNotSupportedError();
2109+
}
20082110
throw new TException("ResetStickyTaskList failed with unknown error:" + result);
20092111
} finally {
20102112
if (response != null) {
@@ -2046,6 +2148,9 @@ private DescribeWorkflowExecutionResponse describeWorkflowExecution(
20462148
if (result.isSetLimitExceededError()) {
20472149
throw result.getLimitExceededError();
20482150
}
2151+
if (result.isSetClientVersionNotSupportedError()) {
2152+
throw result.getClientVersionNotSupportedError();
2153+
}
20492154
throw new TException("DescribeWorkflowExecution failed with unknown error:" + result);
20502155
} finally {
20512156
if (response != null) {
@@ -2085,6 +2190,9 @@ private DescribeTaskListResponse describeTaskList(DescribeTaskListRequest descri
20852190
if (result.isSetLimitExceededError()) {
20862191
throw result.getLimitExceededError();
20872192
}
2193+
if (result.isSetClientVersionNotSupportedError()) {
2194+
throw result.getClientVersionNotSupportedError();
2195+
}
20882196
throw new TException("DescribeTaskList failed with unknown error:" + result);
20892197
} finally {
20902198
if (response != null) {
@@ -2332,7 +2440,9 @@ public void SignalWithStartWorkflowExecution(
23322440
@Override
23332441
public void ResetWorkflowExecution(
23342442
ResetWorkflowExecutionRequest resetRequest, AsyncMethodCallback resultHandler)
2335-
throws TException {}
2443+
throws TException {
2444+
throw new UnsupportedOperationException("not implemented");
2445+
}
23362446

23372447
@Override
23382448
public void TerminateWorkflowExecution(

0 commit comments

Comments
 (0)