use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.
the class StateMachines method failWorkflow.
private static void failWorkflow(RequestContext ctx, WorkflowData data, FailWorkflowExecutionDecisionAttributes d, long decisionTaskCompletedEventId) {
WorkflowExecutionFailedEventAttributes a = new WorkflowExecutionFailedEventAttributes().setReason(d.getReason()).setDetails(d.getDetails()).setDecisionTaskCompletedEventId(decisionTaskCompletedEventId);
HistoryEvent event = new HistoryEvent().setEventType(EventType.WorkflowExecutionFailed).setWorkflowExecutionFailedEventAttributes(a);
ctx.addEvent(event);
}
use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.
the class StateMachines method completeWorkflow.
private static void completeWorkflow(RequestContext ctx, WorkflowData data, CompleteWorkflowExecutionDecisionAttributes d, long decisionTaskCompletedEventId) {
WorkflowExecutionCompletedEventAttributes a = new WorkflowExecutionCompletedEventAttributes().setResult(d.getResult()).setDecisionTaskCompletedEventId(decisionTaskCompletedEventId);
HistoryEvent event = new HistoryEvent().setEventType(EventType.WorkflowExecutionCompleted).setWorkflowExecutionCompletedEventAttributes(a);
ctx.addEvent(event);
}
use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.
the class StateMachines method scheduleDecisionTask.
private static void scheduleDecisionTask(RequestContext ctx, DecisionTaskData data, StartWorkflowExecutionRequest request, long notUsed) {
DecisionTaskScheduledEventAttributes a = new DecisionTaskScheduledEventAttributes().setStartToCloseTimeoutSeconds(request.getTaskStartToCloseTimeoutSeconds()).setTaskList(request.getTaskList()).setAttempt(data.attempt);
HistoryEvent event = new HistoryEvent().setEventType(EventType.DecisionTaskScheduled).setDecisionTaskScheduledEventAttributes(a);
long scheduledEventId = ctx.addEvent(event);
PollForDecisionTaskResponse decisionTaskResponse = new PollForDecisionTaskResponse();
if (data.previousStartedEventId > 0) {
decisionTaskResponse.setPreviousStartedEventId(data.previousStartedEventId);
}
decisionTaskResponse.setWorkflowExecution(ctx.getExecution());
decisionTaskResponse.setWorkflowType(request.getWorkflowType());
decisionTaskResponse.setAttempt(data.attempt);
TaskListId taskListId = new TaskListId(ctx.getDomain(), request.getTaskList().getName());
DecisionTask decisionTask = new DecisionTask(taskListId, decisionTaskResponse);
ctx.setDecisionTask(decisionTask);
ctx.onCommit((historySize) -> {
data.scheduledEventId = scheduledEventId;
data.decisionTask = decisionTaskResponse;
});
}
use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.
the class StateMachines method completeDecisionTask.
private static void completeDecisionTask(RequestContext ctx, DecisionTaskData data, RespondDecisionTaskCompletedRequest request, long notUsed) {
DecisionTaskCompletedEventAttributes a = new DecisionTaskCompletedEventAttributes().setIdentity(request.getIdentity()).setScheduledEventId(data.scheduledEventId);
HistoryEvent event = new HistoryEvent().setEventType(EventType.DecisionTaskCompleted).setDecisionTaskCompletedEventAttributes(a);
ctx.addEvent(event);
ctx.onCommit((historySize) -> data.attempt = 0);
}
use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.
the class StateMachines method scheduleActivityTask.
private static void scheduleActivityTask(RequestContext ctx, ActivityTaskData data, ScheduleActivityTaskDecisionAttributes d, long decisionTaskCompletedEventId) {
ActivityTaskScheduledEventAttributes a = new ActivityTaskScheduledEventAttributes().setInput(d.getInput()).setActivityId(d.getActivityId()).setActivityType(d.getActivityType()).setDomain(d.getDomain() == null ? ctx.getDomain() : d.getDomain()).setHeartbeatTimeoutSeconds(d.getHeartbeatTimeoutSeconds()).setScheduleToCloseTimeoutSeconds(d.getScheduleToCloseTimeoutSeconds()).setScheduleToStartTimeoutSeconds(d.getScheduleToStartTimeoutSeconds()).setStartToCloseTimeoutSeconds(d.getStartToCloseTimeoutSeconds()).setTaskList(d.getTaskList()).setDecisionTaskCompletedEventId(decisionTaskCompletedEventId);
HistoryEvent event = new HistoryEvent().setEventType(EventType.ActivityTaskScheduled).setActivityTaskScheduledEventAttributes(a);
long scheduledEventId = ctx.addEvent(event);
PollForActivityTaskResponse taskResponse = new PollForActivityTaskResponse().setActivityType(d.getActivityType()).setWorkflowExecution(ctx.getExecution()).setActivityId(d.getActivityId()).setInput(d.getInput()).setHeartbeatTimeoutSeconds(d.getHeartbeatTimeoutSeconds()).setScheduleToCloseTimeoutSeconds(d.getScheduleToCloseTimeoutSeconds()).setStartToCloseTimeoutSeconds(d.getStartToCloseTimeoutSeconds()).setScheduledTimestamp(ctx.currentTimeInNanoseconds());
TaskListId taskListId = new TaskListId(ctx.getDomain(), d.getTaskList().getName());
ActivityTask activityTask = new ActivityTask(taskListId, taskResponse);
ctx.addActivityTask(activityTask);
ctx.onCommit((historySize) -> {
data.scheduledEvent = a;
data.scheduledEventId = scheduledEventId;
data.activityTask = taskResponse;
});
}
Aggregations