Skip to content

Update sample file headers #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 53 additions & 38 deletions src/main/java/com/uber/cadence/samples/shadowing/ShadowTraffic.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
/*
* 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.samples.shadowing;

import static com.uber.cadence.samples.common.SampleConstants.DOMAIN;

import com.google.common.collect.Lists;
import com.uber.cadence.client.WorkflowClient;
import com.uber.cadence.client.WorkflowClientOptions;
Expand All @@ -12,48 +31,44 @@
import com.uber.cadence.worker.ShadowingWorker;
import com.uber.cadence.worker.WorkerOptions;
import com.uber.cadence.worker.WorkflowStatus;

import java.util.concurrent.CountDownLatch;

import static com.uber.cadence.samples.common.SampleConstants.DOMAIN;

public class ShadowTraffic {
public static void main(String[] args) throws InterruptedException {
// Get a new client
// NOTE: to set a different options, you can do like this:
// ClientOptions.newBuilder().setRpcTimeout(5 * 1000).build();
WorkflowClient workflowClient =
WorkflowClient.newInstance(
new WorkflowServiceTChannel(ClientOptions.defaultInstance()),
WorkflowClientOptions.newBuilder().setDomain(DOMAIN).build());
ShadowingOptions options = ShadowingOptions
.newBuilder()
.setDomain(DOMAIN)
.setShadowMode(Mode.Normal)
.setWorkflowTypes(Lists.newArrayList("GreetingWorkflow::getGreeting"))
.setWorkflowStatuses(Lists.newArrayList(WorkflowStatus.OPEN, WorkflowStatus.CLOSED))
.setExitCondition(new ExitCondition().setExpirationIntervalInSeconds(60))
.build();
public static void main(String[] args) throws InterruptedException {
// Get a new client
// NOTE: to set a different options, you can do like this:
// ClientOptions.newBuilder().setRpcTimeout(5 * 1000).build();
WorkflowClient workflowClient =
WorkflowClient.newInstance(
new WorkflowServiceTChannel(ClientOptions.defaultInstance()),
WorkflowClientOptions.newBuilder().setDomain(DOMAIN).build());
ShadowingOptions options =
ShadowingOptions.newBuilder()
.setDomain(DOMAIN)
.setShadowMode(Mode.Normal)
.setWorkflowTypes(Lists.newArrayList("GreetingWorkflow::getGreeting"))
.setWorkflowStatuses(Lists.newArrayList(WorkflowStatus.OPEN, WorkflowStatus.CLOSED))
.setExitCondition(new ExitCondition().setExpirationIntervalInSeconds(60))
.build();

ShadowingWorker shadowingWorker = new ShadowingWorker(
workflowClient,
"HelloActivity",
WorkerOptions.defaultInstance(),
options);
shadowingWorker.registerWorkflowImplementationTypes(HelloActivity.GreetingWorkflowImpl.class);
ShadowingWorker shadowingWorker =
new ShadowingWorker(
workflowClient, "HelloActivity", WorkerOptions.defaultInstance(), options);
shadowingWorker.registerWorkflowImplementationTypes(HelloActivity.GreetingWorkflowImpl.class);

CountDownLatch latch = new CountDownLatch(1);
// Execute a workflow waiting for it to complete.
Runnable runnable = () -> {
try {
shadowingWorker.start();
} catch (Exception e) {
System.out.println("Failed to start shadowing workflow");
System.out.println(e);
latch.countDown();
}
CountDownLatch latch = new CountDownLatch(1);
// Execute a workflow waiting for it to complete.
Runnable runnable =
() -> {
try {
shadowingWorker.start();
} catch (Exception e) {
System.out.println("Failed to start shadowing workflow");
System.out.println(e);
latch.countDown();
}
};
runnable.run();
latch.await();
}
runnable.run();
latch.await();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Modifications copyright (C) 2017-2021 Uber Technologies, Inc.
* 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
Expand All @@ -17,6 +17,9 @@

package com.uber.cadence.samples.hello;

import static com.uber.cadence.samples.common.SampleConstants.DOMAIN;
import static com.uber.cadence.samples.hello.HelloActivity.TASK_LIST;

import com.google.common.collect.Lists;
import com.uber.cadence.serviceclient.ClientOptions;
import com.uber.cadence.serviceclient.IWorkflowService;
Expand All @@ -26,18 +29,17 @@
import com.uber.cadence.testing.WorkflowShadower;
import com.uber.cadence.worker.ShadowingOptions;
import com.uber.cadence.worker.WorkflowStatus;
import org.junit.Ignore;
import org.junit.Test;

import static com.uber.cadence.samples.common.SampleConstants.DOMAIN;
import static com.uber.cadence.samples.hello.HelloActivity.TASK_LIST;

public class HelloWorkflowShadowingTest {
@Ignore
@Test
public void testShadowing() throws Throwable {
IWorkflowService service = new WorkflowServiceTChannel(ClientOptions.defaultInstance());

ShadowingOptions options = ShadowingOptions
.newBuilder()
ShadowingOptions options =
ShadowingOptions.newBuilder()
.setDomain(DOMAIN)
.setShadowMode(Mode.Normal)
.setWorkflowTypes(Lists.newArrayList("GreetingWorkflow::getGreeting"))
Expand Down