use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.
the class StateMachines method startChildWorkflowFailed.
private static void startChildWorkflowFailed(RequestContext ctx, ChildWorkflowData data, StartChildWorkflowExecutionFailedEventAttributes a, long notUsed) {
HistoryEvent event = new HistoryEvent().setEventType(EventType.StartChildWorkflowExecutionFailed).setStartChildWorkflowExecutionFailedEventAttributes(a);
ctx.addEvent(event);
}
use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.
the class TestWorkflowMutableStateImpl method addExecutionSignaledByExternalEvent.
private void addExecutionSignaledByExternalEvent(RequestContext ctx, SignalExternalWorkflowExecutionDecisionAttributes d) {
WorkflowExecutionSignaledEventAttributes a = new WorkflowExecutionSignaledEventAttributes().setInput(startRequest.getInput()).setInput(d.getInput()).setSignalName(d.getSignalName());
HistoryEvent executionSignaled = new HistoryEvent().setEventType(EventType.WorkflowExecutionSignaled).setWorkflowExecutionSignaledEventAttributes(a);
ctx.addEvent(executionSignaled);
}
use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.
the class TestWorkflowMutableStateImpl method addExecutionSignaledEvent.
private void addExecutionSignaledEvent(RequestContext ctx, SignalWorkflowExecutionRequest signalRequest) {
WorkflowExecutionSignaledEventAttributes a = new WorkflowExecutionSignaledEventAttributes().setInput(startRequest.getInput()).setIdentity(signalRequest.getIdentity()).setInput(signalRequest.getInput()).setSignalName(signalRequest.getSignalName());
HistoryEvent executionSignaled = new HistoryEvent().setEventType(EventType.WorkflowExecutionSignaled).setWorkflowExecutionSignaledEventAttributes(a);
ctx.addEvent(executionSignaled);
}
use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.
the class TestWorkflowStoreImpl method save.
@Override
public long save(RequestContext ctx) throws InternalServiceError, EntityNotExistsError {
long result;
lock.lock();
boolean historiesEmpty = histories.isEmpty();
try {
ExecutionId executionId = ctx.getExecutionId();
HistoryStore history = histories.get(executionId);
List<HistoryEvent> events = ctx.getEvents();
if (history == null) {
if (events.isEmpty() || events.get(0).getEventType() != EventType.WorkflowExecutionStarted) {
throw new IllegalStateException("No history found for " + executionId);
}
history = new HistoryStore(executionId, lock);
histories.put(executionId, history);
}
history.checkNextEventId(ctx.getInitialEventId());
history.addAllLocked(events, ctx.currentTimeInNanoseconds());
result = history.getNextEventIdLocked();
timerService.updateLocks(ctx.getTimerLocks());
ctx.fireCallbacks(history.getEventsLocked().size());
} finally {
if (historiesEmpty && !histories.isEmpty()) {
// Initially locked in the constructor
timerService.unlockTimeSkipping();
}
lock.unlock();
}
// Push tasks to the queues out of locks
DecisionTask decisionTask = ctx.getDecisionTask();
if (decisionTask != null) {
BlockingQueue<PollForDecisionTaskResponse> decisionsQueue = getDecisionTaskListQueue(decisionTask.getTaskListId());
decisionsQueue.add(decisionTask.getTask());
}
List<ActivityTask> activityTasks = ctx.getActivityTasks();
if (activityTasks != null) {
for (ActivityTask activityTask : activityTasks) {
BlockingQueue<PollForActivityTaskResponse> activitiesQueue = getActivityTaskListQueue(activityTask.getTaskListId());
activitiesQueue.add(activityTask.getTask());
}
}
List<Timer> timers = ctx.getTimers();
if (timers != null) {
for (Timer t : timers) {
timerService.schedule(Duration.ofSeconds(t.getDelaySeconds()), t.getCallback());
}
}
return result;
}
use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.
the class WorkflowTestingTest method testTimerCancellation.
@Test
public void testTimerCancellation() throws TException {
Worker worker = testEnvironment.newWorker(TASK_LIST);
worker.registerWorkflowImplementationTypes(TestTimerCancellationWorkflow.class);
worker.registerActivitiesImplementations(new ActivityImpl());
worker.start();
WorkflowClient client = testEnvironment.newWorkflowClient();
TestWorkflow workflow = client.newWorkflowStub(TestWorkflow.class);
WorkflowExecution execution = WorkflowClient.start(workflow::workflow1, "input1");
WorkflowStub untyped = client.newUntypedWorkflowStub(execution, Optional.empty());
testEnvironment.sleep(Duration.ofHours(1));
untyped.cancel();
try {
untyped.getResult(String.class);
fail("unreacheable");
} catch (CancellationException e) {
}
History history = testEnvironment.getWorkflowService().GetWorkflowExecutionHistory(new GetWorkflowExecutionHistoryRequest().setExecution(execution).setDomain(client.getDomain())).getHistory();
List<HistoryEvent> historyEvents = history.getEvents();
assertTrue(WorkflowExecutionUtils.prettyPrintHistory(history, false), WorkflowExecutionUtils.containsEvent(historyEvents, EventType.TimerCanceled));
}
Aggregations