-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addition of MigrationClient (MigrationIWorkflowService & MigrationInt…
…erceptor) (#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.
- Loading branch information
1 parent
1c43c43
commit fe2bdb5
Showing
11 changed files
with
2,993 additions
and
202 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/main/java/com/uber/cadence/migration/MigrationActivities.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Modifications copyright (C) 2017 Uber Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not | ||
* use this file except in compliance with the License. A copy of the License is | ||
* located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.uber.cadence.migration; | ||
|
||
import com.uber.cadence.RequestCancelWorkflowExecutionRequest; | ||
import com.uber.cadence.StartWorkflowExecutionRequest; | ||
import com.uber.cadence.StartWorkflowExecutionResponse; | ||
import com.uber.cadence.activity.ActivityMethod; | ||
|
||
public interface MigrationActivities { | ||
@ActivityMethod | ||
StartWorkflowExecutionResponse startWorkflowInNewDomain(StartWorkflowExecutionRequest request); | ||
|
||
@ActivityMethod | ||
void cancelWorkflowInCurrentDomain(RequestCancelWorkflowExecutionRequest request); | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/com/uber/cadence/migration/MigrationActivitiesImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Modifications copyright (C) 2017 Uber Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not | ||
* use this file except in compliance with the License. A copy of the License is | ||
* located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.uber.cadence.migration; | ||
|
||
import com.uber.cadence.RequestCancelWorkflowExecutionRequest; | ||
import com.uber.cadence.StartWorkflowExecutionRequest; | ||
import com.uber.cadence.StartWorkflowExecutionResponse; | ||
import com.uber.cadence.client.WorkflowClient; | ||
import com.uber.cadence.workflow.Workflow; | ||
|
||
public class MigrationActivitiesImpl implements MigrationActivities { | ||
private final WorkflowClient clientInCurrDomain, clientInNewDomain; | ||
|
||
public MigrationActivitiesImpl( | ||
WorkflowClient clientInCurrDomain, WorkflowClient clientInNewDomain) { | ||
this.clientInCurrDomain = clientInCurrDomain; | ||
this.clientInNewDomain = clientInNewDomain; | ||
} | ||
|
||
@Override | ||
public StartWorkflowExecutionResponse startWorkflowInNewDomain( | ||
StartWorkflowExecutionRequest request) { | ||
try { | ||
return clientInNewDomain.getService().StartWorkflowExecution(request); | ||
} catch (Exception e) { | ||
throw Workflow.wrap(e); | ||
} | ||
} | ||
|
||
@Override | ||
public void cancelWorkflowInCurrentDomain(RequestCancelWorkflowExecutionRequest request) { | ||
try { | ||
clientInCurrDomain.getService().RequestCancelWorkflowExecution(request); | ||
} catch (Exception e) { | ||
throw Workflow.wrap(e); | ||
} | ||
} | ||
} |
Oops, something went wrong.