use of com.uber.cadence.BadRequestError in project cadence-client by uber-java.
the class ActivityExecutionContextImpl method recordActivityHeartbeat.
/**
* @throws CancellationException
* @see ActivityExecutionContext#recordActivityHeartbeat(Object)
*/
@Override
public void recordActivityHeartbeat(Object details) throws ActivityCompletionException {
// TODO: call service with the specified minimal interval (through @ActivityExecutionOptions)
// allowing more frequent calls of this method.
RecordActivityTaskHeartbeatRequest r = new RecordActivityTaskHeartbeatRequest();
r.setTaskToken(task.getTaskToken());
byte[] serialized = dataConverter.toData(details);
r.setDetails(serialized);
RecordActivityTaskHeartbeatResponse status;
try {
status = service.RecordActivityTaskHeartbeat(r);
if (status.isCancelRequested()) {
throw new ActivityCancelledException(task);
}
} catch (EntityNotExistsError e) {
throw new ActivityNotExistsException(task, e);
} catch (BadRequestError e) {
throw new ActivityCompletionFailureException(task, e);
} catch (TException e) {
log.warn("Failure heartbeating on activityID=" + task.getActivityId() + " of Workflow=" + task.getWorkflowExecution(), e);
// Not rethrowing to not fail activity implementation on intermittent connection or Cadence errors.
}
}
use of com.uber.cadence.BadRequestError 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.BadRequestError 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();
}
}
use of com.uber.cadence.BadRequestError 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.BadRequestError 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);
}
});
}
}
Aggregations