use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.
the class StateMachines method startDecisionTask.
private static void startDecisionTask(RequestContext ctx, DecisionTaskData data, PollForDecisionTaskRequest request, long notUsed) {
DecisionTaskStartedEventAttributes a = new DecisionTaskStartedEventAttributes().setIdentity(request.getIdentity()).setScheduledEventId(data.scheduledEventId);
HistoryEvent event = new HistoryEvent().setEventType(EventType.DecisionTaskStarted).setDecisionTaskStartedEventAttributes(a);
long startedEventId = ctx.addEvent(event);
ctx.onCommit((historySize) -> {
data.decisionTask.setStartedEventId(startedEventId);
DecisionTaskToken taskToken = new DecisionTaskToken(ctx.getExecutionId(), historySize);
data.decisionTask.setTaskToken(taskToken.toBytes());
GetWorkflowExecutionHistoryRequest getRequest = new GetWorkflowExecutionHistoryRequest().setDomain(request.getDomain()).setExecution(ctx.getExecution());
List<HistoryEvent> events;
try {
events = data.store.getWorkflowExecutionHistory(ctx.getExecutionId(), getRequest).getHistory().getEvents();
} catch (EntityNotExistsError entityNotExistsError) {
throw new InternalServiceError(entityNotExistsError.toString());
}
data.decisionTask.setHistory(new History().setEvents(events));
data.previousStartedEventId = startedEventId;
data.attempt++;
});
}
use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.
the class StateMachines method failExternalSignal.
private static void failExternalSignal(RequestContext ctx, SignalExternalData data, SignalExternalWorkflowExecutionFailedCause cause, long notUsed) {
SignalExternalWorkflowExecutionInitiatedEventAttributes initiatedEvent = data.initiatedEvent;
SignalExternalWorkflowExecutionFailedEventAttributes a = new SignalExternalWorkflowExecutionFailedEventAttributes().setInitiatedEventId(data.initiatedEventId).setWorkflowExecution(initiatedEvent.getWorkflowExecution()).setControl(initiatedEvent.getControl()).setCause(cause).setDomain(initiatedEvent.getDomain());
HistoryEvent event = new HistoryEvent().setEventType(EventType.SignalExternalWorkflowExecutionFailed).setSignalExternalWorkflowExecutionFailedEventAttributes(a);
ctx.addEvent(event);
}
use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.
the class StateMachines method requestActivityCancellation.
private static void requestActivityCancellation(RequestContext ctx, ActivityTaskData data, RequestCancelActivityTaskDecisionAttributes d, long decisionTaskCompletedEventId) {
ActivityTaskCancelRequestedEventAttributes a = new ActivityTaskCancelRequestedEventAttributes().setActivityId(d.getActivityId()).setDecisionTaskCompletedEventId(decisionTaskCompletedEventId);
HistoryEvent event = new HistoryEvent().setEventType(EventType.ActivityTaskCancelRequested).setActivityTaskCancelRequestedEventAttributes(a);
ctx.addEvent(event);
}
use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.
the class StateMachines method timeoutDecisionTask.
private static void timeoutDecisionTask(RequestContext ctx, DecisionTaskData data, Object ignored, long notUsed) {
DecisionTaskTimedOutEventAttributes a = new DecisionTaskTimedOutEventAttributes().setStartedEventId(data.previousStartedEventId).setTimeoutType(TimeoutType.START_TO_CLOSE).setScheduledEventId(data.scheduledEventId);
HistoryEvent event = new HistoryEvent().setEventType(EventType.DecisionTaskTimedOut).setDecisionTaskTimedOutEventAttributes(a);
ctx.addEvent(event);
}
use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.
the class StateMachines method fireTimer.
private static void fireTimer(RequestContext ctx, TimerData data, Object ignored, long notUsed) {
TimerFiredEventAttributes a = new TimerFiredEventAttributes().setTimerId(data.startedEvent.getTimerId()).setStartedEventId(data.startedEventId);
HistoryEvent event = new HistoryEvent().setEventType(EventType.TimerFired).setTimerFiredEventAttributes(a);
ctx.addEvent(event);
}
Aggregations