Search in sources :

Example 16 with HistoryEvent

use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.

the class StateMachines method reportActivityTaskCancellation.

private static void reportActivityTaskCancellation(RequestContext ctx, ActivityTaskData data, Object request, long notUsed) {
    byte[] details = null;
    if (request instanceof RespondActivityTaskCanceledRequest) {
        details = ((RespondActivityTaskCanceledRequest) request).getDetails();
    } else if (request instanceof RespondActivityTaskCanceledByIDRequest) {
        details = ((RespondActivityTaskCanceledByIDRequest) request).getDetails();
    }
    ActivityTaskCanceledEventAttributes a = new ActivityTaskCanceledEventAttributes().setScheduledEventId(data.scheduledEventId).setStartedEventId(data.startedEventId);
    if (details != null) {
        a.setDetails(details);
    }
    HistoryEvent event = new HistoryEvent().setEventType(EventType.ActivityTaskCanceled).setActivityTaskCanceledEventAttributes(a);
    ctx.addEvent(event);
}
Also used : RespondActivityTaskCanceledByIDRequest(com.uber.cadence.RespondActivityTaskCanceledByIDRequest) ActivityTaskCanceledEventAttributes(com.uber.cadence.ActivityTaskCanceledEventAttributes) HistoryEvent(com.uber.cadence.HistoryEvent) RespondActivityTaskCanceledRequest(com.uber.cadence.RespondActivityTaskCanceledRequest)

Example 17 with HistoryEvent

use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.

the class StateMachines method initiateExternalSignal.

private static void initiateExternalSignal(RequestContext ctx, SignalExternalData data, SignalExternalWorkflowExecutionDecisionAttributes d, long decisionTaskCompletedEventId) {
    SignalExternalWorkflowExecutionInitiatedEventAttributes a = new SignalExternalWorkflowExecutionInitiatedEventAttributes();
    a.setDecisionTaskCompletedEventId(decisionTaskCompletedEventId);
    if (d.isSetControl()) {
        a.setControl(d.getControl());
    }
    if (d.isSetInput()) {
        a.setInput(d.getInput());
    }
    if (d.isSetDomain()) {
        a.setDomain(d.getDomain());
    }
    if (d.isSetChildWorkflowOnly()) {
        a.setChildWorkflowOnly(d.isChildWorkflowOnly());
    }
    a.setSignalName(d.getSignalName());
    a.setWorkflowExecution(d.getExecution());
    HistoryEvent event = new HistoryEvent().setEventType(EventType.SignalExternalWorkflowExecutionInitiated).setSignalExternalWorkflowExecutionInitiatedEventAttributes(a);
    long initiatedEventId = ctx.addEvent(event);
    ctx.onCommit((historySize) -> {
        data.initiatedEventId = initiatedEventId;
        data.initiatedEvent = a;
    });
}
Also used : HistoryEvent(com.uber.cadence.HistoryEvent) SignalExternalWorkflowExecutionInitiatedEventAttributes(com.uber.cadence.SignalExternalWorkflowExecutionInitiatedEventAttributes)

Example 18 with HistoryEvent

use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.

the class StateMachines method initiateChildWorkflow.

private static void initiateChildWorkflow(RequestContext ctx, ChildWorkflowData data, StartChildWorkflowExecutionDecisionAttributes d, long decisionTaskCompletedEventId) {
    StartChildWorkflowExecutionInitiatedEventAttributes a = new StartChildWorkflowExecutionInitiatedEventAttributes().setControl(d.getControl()).setInput(d.getInput()).setChildPolicy(d.getChildPolicy()).setDecisionTaskCompletedEventId(decisionTaskCompletedEventId).setDomain(d.getDomain() == null ? ctx.getDomain() : d.getDomain()).setExecutionStartToCloseTimeoutSeconds(d.getExecutionStartToCloseTimeoutSeconds()).setTaskStartToCloseTimeoutSeconds(d.getTaskStartToCloseTimeoutSeconds()).setTaskList(d.getTaskList()).setWorkflowId(d.getWorkflowId()).setWorkflowIdReusePolicy(d.getWorkflowIdReusePolicy()).setWorkflowType(d.getWorkflowType());
    HistoryEvent event = new HistoryEvent().setEventType(EventType.StartChildWorkflowExecutionInitiated).setStartChildWorkflowExecutionInitiatedEventAttributes(a);
    long initiatedEventId = ctx.addEvent(event);
    ctx.onCommit((historySize) -> {
        data.initiatedEventId = initiatedEventId;
        data.initiatedEvent = a;
        StartWorkflowExecutionRequest startChild = new StartWorkflowExecutionRequest().setInput(d.getInput()).setDomain(d.getDomain() == null ? ctx.getDomain() : d.getDomain()).setExecutionStartToCloseTimeoutSeconds(d.getExecutionStartToCloseTimeoutSeconds()).setTaskStartToCloseTimeoutSeconds(d.getTaskStartToCloseTimeoutSeconds()).setTaskList(d.getTaskList()).setWorkflowId(d.getWorkflowId()).setWorkflowIdReusePolicy(d.getWorkflowIdReusePolicy()).setWorkflowType(d.getWorkflowType());
        addStartChildTask(ctx, data, initiatedEventId, startChild);
    });
}
Also used : StartChildWorkflowExecutionInitiatedEventAttributes(com.uber.cadence.StartChildWorkflowExecutionInitiatedEventAttributes) HistoryEvent(com.uber.cadence.HistoryEvent) StartWorkflowExecutionRequest(com.uber.cadence.StartWorkflowExecutionRequest)

Example 19 with HistoryEvent

use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.

the class StateMachines method startTimer.

private static void startTimer(RequestContext ctx, TimerData data, StartTimerDecisionAttributes d, long decisionTaskCompletedEventId) {
    TimerStartedEventAttributes a = new TimerStartedEventAttributes().setDecisionTaskCompletedEventId(decisionTaskCompletedEventId).setStartToFireTimeoutSeconds(d.getStartToFireTimeoutSeconds()).setTimerId(d.getTimerId());
    HistoryEvent event = new HistoryEvent().setEventType(EventType.TimerStarted).setTimerStartedEventAttributes(a);
    long startedEventId = ctx.addEvent(event);
    ctx.onCommit((historySize) -> {
        data.startedEvent = a;
        data.startedEventId = startedEventId;
    });
}
Also used : TimerStartedEventAttributes(com.uber.cadence.TimerStartedEventAttributes) HistoryEvent(com.uber.cadence.HistoryEvent)

Example 20 with HistoryEvent

use of com.uber.cadence.HistoryEvent in project cadence-client by uber-java.

the class StateMachines method requestWorkflowCancellation.

private static void requestWorkflowCancellation(RequestContext ctx, WorkflowData data, RequestCancelWorkflowExecutionRequest cancelRequest, long notUsed) {
    WorkflowExecutionCancelRequestedEventAttributes a = new WorkflowExecutionCancelRequestedEventAttributes().setIdentity(cancelRequest.getIdentity());
    HistoryEvent cancelRequested = new HistoryEvent().setEventType(EventType.WorkflowExecutionCancelRequested).setWorkflowExecutionCancelRequestedEventAttributes(a);
    ctx.addEvent(cancelRequested);
}
Also used : WorkflowExecutionCancelRequestedEventAttributes(com.uber.cadence.WorkflowExecutionCancelRequestedEventAttributes) 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