use of com.uber.cadence.WorkflowExecutionTimedOutEventAttributes in project cadence-client by uber-java.
the class StateMachines method timeoutWorkflow.
private static void timeoutWorkflow(RequestContext ctx, WorkflowData data, TimeoutType timeoutType, long notUsed) {
WorkflowExecutionTimedOutEventAttributes a = new WorkflowExecutionTimedOutEventAttributes().setTimeoutType(timeoutType);
HistoryEvent event = new HistoryEvent().setEventType(EventType.WorkflowExecutionTimedOut).setWorkflowExecutionTimedOutEventAttributes(a);
ctx.addEvent(event);
}
use of com.uber.cadence.WorkflowExecutionTimedOutEventAttributes in project cadence-client by uber-java.
the class WorkflowExecutionUtils method getResultFromCloseEvent.
private static byte[] getResultFromCloseEvent(WorkflowExecution workflowExecution, Optional<String> workflowType, HistoryEvent closeEvent) {
if (closeEvent == null) {
throw new IllegalStateException("Workflow is still running");
}
switch(closeEvent.getEventType()) {
case WorkflowExecutionCompleted:
return closeEvent.getWorkflowExecutionCompletedEventAttributes().getResult();
case WorkflowExecutionCanceled:
byte[] details = closeEvent.getWorkflowExecutionCanceledEventAttributes().getDetails();
String message = details != null ? new String(details, StandardCharsets.UTF_8) : null;
throw new CancellationException(message);
case WorkflowExecutionFailed:
WorkflowExecutionFailedEventAttributes failed = closeEvent.getWorkflowExecutionFailedEventAttributes();
throw new WorkflowExecutionFailedException(failed.getReason(), failed.getDetails(), failed.getDecisionTaskCompletedEventId());
case WorkflowExecutionTerminated:
WorkflowExecutionTerminatedEventAttributes terminated = closeEvent.getWorkflowExecutionTerminatedEventAttributes();
throw new WorkflowTerminatedException(workflowExecution, workflowType, terminated.getReason(), terminated.getIdentity(), terminated.getDetails());
case WorkflowExecutionTimedOut:
WorkflowExecutionTimedOutEventAttributes timedOut = closeEvent.getWorkflowExecutionTimedOutEventAttributes();
throw new WorkflowTimedOutException(workflowExecution, workflowType, timedOut.getTimeoutType());
default:
throw new RuntimeException("Workflow end state is not completed: " + prettyPrintHistoryEvent(closeEvent));
}
}
Aggregations