Search in sources :

Example 1 with State

use of com.uber.cadence.internal.testservice.StateMachines.State in project cadence-client by uber-java.

the class TestWorkflowMutableStateImpl method processRequestCancelActivityTask.

private void processRequestCancelActivityTask(RequestContext ctx, RequestCancelActivityTaskDecisionAttributes a, long decisionTaskCompletedId) throws InternalServiceError {
    String activityId = a.getActivityId();
    StateMachine<?> activity = activities.get(activityId);
    if (activity == null) {
        RequestCancelActivityTaskFailedEventAttributes failedAttr = new RequestCancelActivityTaskFailedEventAttributes().setActivityId(activityId).setCause("ACTIVITY_ID_UNKNOWN").setDecisionTaskCompletedEventId(decisionTaskCompletedId);
        HistoryEvent cancellationFailed = new HistoryEvent().setEventType(EventType.RequestCancelActivityTaskFailed).setRequestCancelActivityTaskFailedEventAttributes(failedAttr);
        ctx.addEvent(cancellationFailed);
        return;
    }
    State beforeState = activity.getState();
    activity.action(StateMachines.Action.REQUEST_CANCELLATION, ctx, a, decisionTaskCompletedId);
    if (beforeState == StateMachines.State.INITIATED) {
        activity.action(StateMachines.Action.CANCEL, ctx, null, 0);
        activities.remove(activityId);
        ctx.setNeedDecision(true);
    }
}
Also used : State(com.uber.cadence.internal.testservice.StateMachines.State) HistoryEvent(com.uber.cadence.HistoryEvent) RequestCancelActivityTaskFailedEventAttributes(com.uber.cadence.RequestCancelActivityTaskFailedEventAttributes)

Aggregations

HistoryEvent (com.uber.cadence.HistoryEvent)1 RequestCancelActivityTaskFailedEventAttributes (com.uber.cadence.RequestCancelActivityTaskFailedEventAttributes)1 State (com.uber.cadence.internal.testservice.StateMachines.State)1