Skip to content

Commit fe2bdb5

Browse files
authored
Addition of MigrationClient (MigrationIWorkflowService & MigrationInterceptor) (#844)
Why Thin layer on client/worker to migrate workflows from one domain to another. Logic Before Migration: Current domain worker is polling tasks from the current domain. Current client is querying / canceling / listing / terminating workflows from the current domain. During Migration: Current domain worker is polling tasks from the current domain. To migrate cron workflows or continue-as-new workflows, migrationInterceptor needs to be added to the current domain worker. New domain worker is polling tasks from the new domain. MigrationClient needs to be used to querying / canceling / listing / terminating workflows, so it coordinates across the new and current domain. After Migration: Only new Worker is started. Changes Added migrationIWorkflowService Added migrationInterceptor Moved out TracingInterceptor from WorkflowTest to a separate package Test Unit test for MigrationIWorkflowService. Integration test for MigrationInterceptor.
1 parent 1c43c43 commit fe2bdb5

11 files changed

+2993
-202
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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.migration;
19+
20+
import com.uber.cadence.RequestCancelWorkflowExecutionRequest;
21+
import com.uber.cadence.StartWorkflowExecutionRequest;
22+
import com.uber.cadence.StartWorkflowExecutionResponse;
23+
import com.uber.cadence.activity.ActivityMethod;
24+
25+
public interface MigrationActivities {
26+
@ActivityMethod
27+
StartWorkflowExecutionResponse startWorkflowInNewDomain(StartWorkflowExecutionRequest request);
28+
29+
@ActivityMethod
30+
void cancelWorkflowInCurrentDomain(RequestCancelWorkflowExecutionRequest request);
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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.migration;
19+
20+
import com.uber.cadence.RequestCancelWorkflowExecutionRequest;
21+
import com.uber.cadence.StartWorkflowExecutionRequest;
22+
import com.uber.cadence.StartWorkflowExecutionResponse;
23+
import com.uber.cadence.client.WorkflowClient;
24+
import com.uber.cadence.workflow.Workflow;
25+
26+
public class MigrationActivitiesImpl implements MigrationActivities {
27+
private final WorkflowClient clientInCurrDomain, clientInNewDomain;
28+
29+
public MigrationActivitiesImpl(
30+
WorkflowClient clientInCurrDomain, WorkflowClient clientInNewDomain) {
31+
this.clientInCurrDomain = clientInCurrDomain;
32+
this.clientInNewDomain = clientInNewDomain;
33+
}
34+
35+
@Override
36+
public StartWorkflowExecutionResponse startWorkflowInNewDomain(
37+
StartWorkflowExecutionRequest request) {
38+
try {
39+
return clientInNewDomain.getService().StartWorkflowExecution(request);
40+
} catch (Exception e) {
41+
throw Workflow.wrap(e);
42+
}
43+
}
44+
45+
@Override
46+
public void cancelWorkflowInCurrentDomain(RequestCancelWorkflowExecutionRequest request) {
47+
try {
48+
clientInCurrDomain.getService().RequestCancelWorkflowExecution(request);
49+
} catch (Exception e) {
50+
throw Workflow.wrap(e);
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)