Skip to content

Commit

Permalink
Addition of MigrationClient (MigrationIWorkflowService & MigrationInt…
Browse files Browse the repository at this point in the history
…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
abhishekj720 authored Aug 25, 2023
1 parent 1c43c43 commit fe2bdb5
Show file tree
Hide file tree
Showing 11 changed files with 2,993 additions and 202 deletions.
31 changes: 31 additions & 0 deletions src/main/java/com/uber/cadence/migration/MigrationActivities.java
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);
}
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);
}
}
}
Loading

0 comments on commit fe2bdb5

Please sign in to comment.