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);
}
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;
});
}
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);
});
}
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;
});
}
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);
}
Aggregations