Search in sources :

Example 36 with HistoryEvent

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++;
    });
}
Also used : DecisionTaskStartedEventAttributes(com.uber.cadence.DecisionTaskStartedEventAttributes) GetWorkflowExecutionHistoryRequest(com.uber.cadence.GetWorkflowExecutionHistoryRequest) InternalServiceError(com.uber.cadence.InternalServiceError) EntityNotExistsError(com.uber.cadence.EntityNotExistsError) HistoryEvent(com.uber.cadence.HistoryEvent) History(com.uber.cadence.History)

Example 37 with HistoryEvent

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

Example 38 with HistoryEvent

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

Example 39 with HistoryEvent

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

Example 40 with HistoryEvent

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