use of com.uber.cadence.InternalServiceError in project cadence-client by uber-java.
the class ActivityId method fromBytes.
static ActivityId fromBytes(byte[] serialized) throws InternalServiceError {
ByteArrayInputStream bin = new ByteArrayInputStream(serialized);
DataInputStream in = new DataInputStream(bin);
try {
String domain = in.readUTF();
String workflowId = in.readUTF();
String runId = in.readUTF();
String id = in.readUTF();
return new ActivityId(domain, workflowId, runId, id);
} catch (IOException e) {
throw new InternalServiceError(Throwables.getStackTraceAsString(e));
}
}
use of com.uber.cadence.InternalServiceError in project cadence-client by uber-java.
the class DecisionTaskToken method toBytes.
/**
* Used for task tokens.
*/
byte[] toBytes() throws InternalServiceError {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(bout);
try {
addBytes(out);
} catch (IOException e) {
throw new InternalServiceError(Throwables.getStackTraceAsString(e));
}
return bout.toByteArray();
}
use of com.uber.cadence.InternalServiceError in project cadence-client by uber-java.
the class ExecutionId method toBytes.
/**
* Used for task tokens.
*/
byte[] toBytes() throws InternalServiceError {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(bout);
try {
addBytes(out);
} catch (IOException e) {
throw new InternalServiceError(Throwables.getStackTraceAsString(e));
}
return bout.toByteArray();
}
use of com.uber.cadence.InternalServiceError in project cadence-client by uber-java.
the class TestWorkflowMutableStateImpl method processCompleteWorkflowExecution.
private void processCompleteWorkflowExecution(RequestContext ctx, CompleteWorkflowExecutionDecisionAttributes d, long decisionTaskCompletedId) throws InternalServiceError {
workflow.action(StateMachines.Action.COMPLETE, ctx, d, decisionTaskCompletedId);
if (parent.isPresent()) {
// unlocked by the parent
ctx.lockTimer();
ChildWorkflowExecutionCompletedEventAttributes a = new ChildWorkflowExecutionCompletedEventAttributes().setResult(d.getResult()).setDomain(ctx.getDomain()).setWorkflowExecution(ctx.getExecution()).setWorkflowType(startRequest.getWorkflowType());
ForkJoinPool.commonPool().execute(() -> {
try {
parent.get().childWorkflowCompleted(ctx.getExecutionId().getWorkflowId().getWorkflowId(), a);
} catch (EntityNotExistsError entityNotExistsError) {
// Parent might already close
} catch (BadRequestError | InternalServiceError e) {
log.error("Failure reporting child completion", e);
}
});
}
}
use of com.uber.cadence.InternalServiceError in project cadence-client by uber-java.
the class TestWorkflowMutableStateImpl method update.
private void update(boolean completeDecisionUpdate, UpdateProcedure updater) throws InternalServiceError, EntityNotExistsError, BadRequestError {
lock.lock();
selfAdvancingTimer.lockTimeSkipping();
try {
checkCompleted();
boolean concurrentDecision = !completeDecisionUpdate && (decision != null && decision.getState() == StateMachines.State.STARTED);
RequestContext ctx = new RequestContext(clock, this, nextEventId);
updater.apply(ctx);
if (concurrentDecision && workflow.getState() != State.TIMED_OUT) {
concurrentToDecision.add(ctx);
ctx.fireCallbacks(0);
} else {
nextEventId = ctx.commitChanges(store);
}
} catch (InternalServiceError | EntityNotExistsError | BadRequestError e) {
throw e;
} catch (Exception e) {
throw new InternalServiceError(Throwables.getStackTraceAsString(e));
} finally {
selfAdvancingTimer.unlockTimeSkipping();
lock.unlock();
}
}
Aggregations