use of com.uber.cadence.InternalServiceError in project cadence-client by uber-java.
the class ExecutionId method fromBytes.
static ExecutionId fromBytes(byte[] serialized) throws InternalServiceError {
ByteArrayInputStream bin = new ByteArrayInputStream(serialized);
DataInputStream in = new DataInputStream(bin);
try {
return readFromBytes(in);
} catch (IOException e) {
throw new InternalServiceError(Throwables.getStackTraceAsString(e));
}
}
use of com.uber.cadence.InternalServiceError 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++;
});
}
Aggregations