use of com.uber.cadence.InternalServiceError in project cadence-client by uber-java.
the class TestWorkflowMutableStateImpl method processFailWorkflowExecution.
private void processFailWorkflowExecution(RequestContext ctx, FailWorkflowExecutionDecisionAttributes d, long decisionTaskCompletedId) throws InternalServiceError {
workflow.action(StateMachines.Action.FAIL, ctx, d, decisionTaskCompletedId);
if (parent.isPresent()) {
// unlocked by the parent
ctx.lockTimer();
ChildWorkflowExecutionFailedEventAttributes a = new ChildWorkflowExecutionFailedEventAttributes().setDetails(d.getDetails()).setReason(d.getReason()).setWorkflowType(startRequest.getWorkflowType()).setDomain(ctx.getDomain()).setWorkflowExecution(ctx.getExecution());
ForkJoinPool.commonPool().execute(() -> {
try {
parent.get().childWorklfowFailed(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 query.
@Override
public QueryWorkflowResponse query(QueryWorkflowRequest queryRequest) throws TException {
QueryId queryId = new QueryId(executionId);
PollForDecisionTaskResponse task = new PollForDecisionTaskResponse().setTaskToken(queryId.toBytes()).setWorkflowExecution(executionId.getExecution()).setWorkflowType(startRequest.getWorkflowType()).setQuery(queryRequest.getQuery());
TaskListId taskListId = new TaskListId(queryRequest.getDomain(), startRequest.getTaskList().getName());
store.sendQueryTask(executionId, taskListId, task);
CompletableFuture<QueryWorkflowResponse> result = new CompletableFuture<>();
queries.put(queryId.getQueryId(), result);
try {
return result.get();
} catch (InterruptedException e) {
return new QueryWorkflowResponse();
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause instanceof TException) {
throw (TException) cause;
}
throw new InternalServiceError(Throwables.getStackTraceAsString(cause));
}
}
use of com.uber.cadence.InternalServiceError in project cadence-client by uber-java.
the class WorkflowStubImpl method query.
@Override
public <R> R query(String queryType, Class<R> returnType, Object... args) {
checkStarted();
QueryWorkflowParameters p = new QueryWorkflowParameters();
p.setInput(dataConverter.toData(args));
p.setQueryType(queryType);
p.setWorkflowId(execution.get().getWorkflowId());
try {
byte[] result = genericClient.queryWorkflow(p);
return dataConverter.fromData(result, returnType);
} catch (RuntimeException e) {
Exception unwrapped = CheckedExceptionWrapper.unwrap(e);
if (unwrapped instanceof EntityNotExistsError) {
throw new WorkflowNotFoundException(execution.get(), workflowType, e.getMessage());
}
if (unwrapped instanceof QueryFailedError) {
throw new WorkflowQueryException(execution.get(), unwrapped.getMessage());
}
if (unwrapped instanceof InternalServiceError) {
throw new WorkflowServiceException(execution.get(), workflowType, unwrapped);
}
throw e;
}
}
use of com.uber.cadence.InternalServiceError in project cadence-client by uber-java.
the class TestWorkflowMutableStateImpl method processCancelWorkflowExecution.
private void processCancelWorkflowExecution(RequestContext ctx, CancelWorkflowExecutionDecisionAttributes d, long decisionTaskCompletedId) throws InternalServiceError {
workflow.action(StateMachines.Action.CANCEL, ctx, d, decisionTaskCompletedId);
if (parent.isPresent()) {
// unlocked by the parent
ctx.lockTimer();
ChildWorkflowExecutionCanceledEventAttributes a = new ChildWorkflowExecutionCanceledEventAttributes().setDetails(d.getDetails()).setDomain(ctx.getDomain()).setWorkflowExecution(ctx.getExecution()).setWorkflowType(startRequest.getWorkflowType());
ForkJoinPool.commonPool().execute(() -> {
try {
parent.get().childWorkflowCanceled(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 startWorkflow.
@Override
public void startWorkflow() throws InternalServiceError, BadRequestError {
try {
update(ctx -> {
workflow.action(StateMachines.Action.START, ctx, startRequest, 0);
scheduleDecision(ctx);
ctx.addTimer(startRequest.getExecutionStartToCloseTimeoutSeconds(), this::timeoutWorkflow);
});
} catch (EntityNotExistsError entityNotExistsError) {
throw new InternalServiceError(Throwables.getStackTraceAsString(entityNotExistsError));
}
if (parent.isPresent()) {
ChildWorkflowExecutionStartedEventAttributes a = new ChildWorkflowExecutionStartedEventAttributes().setWorkflowExecution(getExecutionId().getExecution()).setDomain(getExecutionId().getDomain()).setWorkflowType(startRequest.getWorkflowType());
ForkJoinPool.commonPool().execute(() -> {
try {
parent.get().childWorkflowStarted(a);
} catch (EntityNotExistsError entityNotExistsError) {
// Not a problem. Parent might just close by now.
} catch (BadRequestError | InternalServiceError e) {
log.error("Failure reporting child completion", e);
}
});
}
}
Aggregations