use of com.uber.cadence.internal.replay.DeciderCache in project cadence-client by uber-java.
the class StickyWorkerTest method whenCacheIsEvictedTheWorkerCanRecover.
@Test
public void whenCacheIsEvictedTheWorkerCanRecover() throws Exception {
// Arrange
String taskListName = "evictedStickyTest";
TestEnvironmentWrapper wrapper = new TestEnvironmentWrapper(WorkerFactoryOptions.newBuilder().setDisableStickyExecution(false).build(), NoopScope.getInstance());
WorkerFactory factory = wrapper.getWorkerFactory();
Worker worker = factory.newWorker(taskListName);
worker.registerWorkflowImplementationTypes(GreetingSignalWorkflowImpl.class);
factory.start();
WorkflowOptions workflowOptions = new WorkflowOptions.Builder().setTaskList(taskListName).setExecutionStartToCloseTimeout(Duration.ofDays(30)).setTaskStartToCloseTimeout(Duration.ofSeconds(30)).build();
GreetingSignalWorkflow workflow = wrapper.getWorkflowClient().newWorkflowStub(GreetingSignalWorkflow.class, workflowOptions);
// Act
WorkflowClient.start(workflow::getGreeting);
// Wait for workflow to start
Thread.sleep(200);
DeciderCache cache = factory.getCache();
assertNotNull(cache);
assertEquals(1, cache.size());
cache.invalidateAll();
assertEquals(0, cache.size());
workflow.waitForName("World");
String greeting = workflow.getGreeting();
// Assert
assertEquals("Hello World!", greeting);
wrapper.close();
}
use of com.uber.cadence.internal.replay.DeciderCache in project cadence-client by uber-java.
the class StickyWorkerTest method workflowsCanBeQueried.
@Test
public void workflowsCanBeQueried() throws Exception {
// Arrange
String taskListName = "queryStickyTest";
TestEnvironmentWrapper wrapper = new TestEnvironmentWrapper(WorkerFactoryOptions.newBuilder().setDisableStickyExecution(false).build(), NoopScope.getInstance());
WorkerFactory factory = wrapper.getWorkerFactory();
Worker worker = factory.newWorker(taskListName);
worker.registerWorkflowImplementationTypes(GreetingSignalWorkflowImpl.class);
factory.start();
WorkflowOptions workflowOptions = new WorkflowOptions.Builder().setTaskList(taskListName).setExecutionStartToCloseTimeout(Duration.ofDays(30)).setTaskStartToCloseTimeout(Duration.ofSeconds(30)).build();
GreetingSignalWorkflow workflow = wrapper.getWorkflowClient().newWorkflowStub(GreetingSignalWorkflow.class, workflowOptions);
// Act
WorkflowClient.start(workflow::getGreeting);
// Wait for workflow to start
Thread.sleep(200);
DeciderCache cache = factory.getCache();
assertNotNull(cache);
assertEquals(1, cache.size());
// Assert
assertEquals(workflow.getProgress(), GreetingSignalWorkflow.Status.WAITING_FOR_NAME);
workflow.waitForName("World");
String greeting = workflow.getGreeting();
assertEquals("Hello World!", greeting);
assertEquals(workflow.getProgress(), GreetingSignalWorkflow.Status.GREETING_GENERATED);
wrapper.close();
}
Aggregations