use of com.uber.cadence.EntityNotExistsError 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.EntityNotExistsError 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.EntityNotExistsError 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);
}
});
}
}
use of com.uber.cadence.EntityNotExistsError in project cadence-client by uber-java.
the class TestWorkflowMutableStateImpl method reportWorkflowTimeoutToParent.
private void reportWorkflowTimeoutToParent(RequestContext ctx) {
if (!parent.isPresent()) {
return;
}
try {
ChildWorkflowExecutionTimedOutEventAttributes a = new ChildWorkflowExecutionTimedOutEventAttributes().setTimeoutType(TimeoutType.START_TO_CLOSE).setWorkflowType(startRequest.getWorkflowType()).setDomain(ctx.getDomain()).setWorkflowExecution(ctx.getExecution());
parent.get().childWorklfowTimedOut(ctx.getExecutionId().getWorkflowId().getWorkflowId(), a);
} catch (EntityNotExistsError entityNotExistsError) {
// Parent might already close
} catch (BadRequestError | InternalServiceError e) {
log.error("Failure reporting child timing out", e);
}
}
use of com.uber.cadence.EntityNotExistsError in project cadence-client by uber-java.
the class TestWorkflowMutableStateImpl method heartbeatActivityTask.
@Override
public RecordActivityTaskHeartbeatResponse heartbeatActivityTask(String activityId, RecordActivityTaskHeartbeatRequest request) throws InternalServiceError, EntityNotExistsError, BadRequestError {
RecordActivityTaskHeartbeatResponse result = new RecordActivityTaskHeartbeatResponse();
try {
update(ctx -> {
StateMachine<ActivityTaskData> activity = getActivity(activityId);
activity.action(StateMachines.Action.UPDATE, ctx, request, 0);
if (activity.getState() == StateMachines.State.CANCELLATION_REQUESTED) {
result.setCancelRequested(true);
}
ActivityTaskData data = activity.getData();
data.lastHeartbeatTime = clock.getAsLong();
int startToCloseTimeout = data.scheduledEvent.getStartToCloseTimeoutSeconds();
int heartbeatTimeout = data.scheduledEvent.getHeartbeatTimeoutSeconds();
updateHeartbeatTimer(ctx, activityId, activity, startToCloseTimeout, heartbeatTimeout);
});
} catch (InternalServiceError | EntityNotExistsError e) {
throw e;
} catch (Exception e) {
throw new InternalServiceError(Throwables.getStackTraceAsString(e));
}
return result;
}
Aggregations