Search in sources :

Example 41 with HistoryEvent

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);
}
Also used : StartChildWorkflowExecutionFailedEventAttributes(com.uber.cadence.StartChildWorkflowExecutionFailedEventAttributes) SignalExternalWorkflowExecutionFailedEventAttributes(com.uber.cadence.SignalExternalWorkflowExecutionFailedEventAttributes) WorkflowExecutionFailedEventAttributes(com.uber.cadence.WorkflowExecutionFailedEventAttributes) ChildWorkflowExecutionFailedEventAttributes(com.uber.cadence.ChildWorkflowExecutionFailedEventAttributes) HistoryEvent(com.uber.cadence.HistoryEvent)

Example 42 with HistoryEvent

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);
}
Also used : ChildWorkflowExecutionCompletedEventAttributes(com.uber.cadence.ChildWorkflowExecutionCompletedEventAttributes) WorkflowExecutionCompletedEventAttributes(com.uber.cadence.WorkflowExecutionCompletedEventAttributes) HistoryEvent(com.uber.cadence.HistoryEvent)

Example 43 with HistoryEvent

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;
    });
}
Also used : DecisionTask(com.uber.cadence.internal.testservice.TestWorkflowStore.DecisionTask) TaskListId(com.uber.cadence.internal.testservice.TestWorkflowStore.TaskListId) PollForDecisionTaskResponse(com.uber.cadence.PollForDecisionTaskResponse) DecisionTaskScheduledEventAttributes(com.uber.cadence.DecisionTaskScheduledEventAttributes) HistoryEvent(com.uber.cadence.HistoryEvent)

Example 44 with HistoryEvent

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);
}
Also used : DecisionTaskCompletedEventAttributes(com.uber.cadence.DecisionTaskCompletedEventAttributes) HistoryEvent(com.uber.cadence.HistoryEvent)

Example 45 with HistoryEvent

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;
    });
}
Also used : ActivityTaskScheduledEventAttributes(com.uber.cadence.ActivityTaskScheduledEventAttributes) ActivityTask(com.uber.cadence.internal.testservice.TestWorkflowStore.ActivityTask) PollForActivityTaskResponse(com.uber.cadence.PollForActivityTaskResponse) TaskListId(com.uber.cadence.internal.testservice.TestWorkflowStore.TaskListId) HistoryEvent(com.uber.cadence.HistoryEvent)

Aggregations

HistoryEvent (com.uber.cadence.HistoryEvent)49 History (com.uber.cadence.History)5 WorkflowExecution (com.uber.cadence.WorkflowExecution)5 GetWorkflowExecutionHistoryRequest (com.uber.cadence.GetWorkflowExecutionHistoryRequest)4 GetWorkflowExecutionHistoryResponse (com.uber.cadence.GetWorkflowExecutionHistoryResponse)3 SignalExternalWorkflowExecutionInitiatedEventAttributes (com.uber.cadence.SignalExternalWorkflowExecutionInitiatedEventAttributes)3 ActivityTaskCompletedEventAttributes (com.uber.cadence.ActivityTaskCompletedEventAttributes)2 ActivityTaskFailedEventAttributes (com.uber.cadence.ActivityTaskFailedEventAttributes)2 ChildWorkflowExecutionTimedOutEventAttributes (com.uber.cadence.ChildWorkflowExecutionTimedOutEventAttributes)2 EntityNotExistsError (com.uber.cadence.EntityNotExistsError)2 PollForActivityTaskResponse (com.uber.cadence.PollForActivityTaskResponse)2 PollForDecisionTaskResponse (com.uber.cadence.PollForDecisionTaskResponse)2 SignalExternalWorkflowExecutionFailedEventAttributes (com.uber.cadence.SignalExternalWorkflowExecutionFailedEventAttributes)2 StartChildWorkflowExecutionInitiatedEventAttributes (com.uber.cadence.StartChildWorkflowExecutionInitiatedEventAttributes)2 StartWorkflowExecutionRequest (com.uber.cadence.StartWorkflowExecutionRequest)2 WorkflowExecutionContinuedAsNewEventAttributes (com.uber.cadence.WorkflowExecutionContinuedAsNewEventAttributes)2 WorkflowExecutionSignaledEventAttributes (com.uber.cadence.WorkflowExecutionSignaledEventAttributes)2 WorkflowExecutionStartedEventAttributes (com.uber.cadence.WorkflowExecutionStartedEventAttributes)2 TaskListId (com.uber.cadence.internal.testservice.TestWorkflowStore.TaskListId)2 ArrayList (java.util.ArrayList)2