Search in sources :

Example 1 with InternalServiceError

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));
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InternalServiceError(com.uber.cadence.InternalServiceError) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream)

Example 2 with InternalServiceError

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();
}
Also used : DataOutputStream(java.io.DataOutputStream) InternalServiceError(com.uber.cadence.InternalServiceError) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 3 with InternalServiceError

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();
}
Also used : DataOutputStream(java.io.DataOutputStream) InternalServiceError(com.uber.cadence.InternalServiceError) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 4 with InternalServiceError

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);
            }
        });
    }
}
Also used : InternalServiceError(com.uber.cadence.InternalServiceError) ChildWorkflowExecutionCompletedEventAttributes(com.uber.cadence.ChildWorkflowExecutionCompletedEventAttributes) EntityNotExistsError(com.uber.cadence.EntityNotExistsError) BadRequestError(com.uber.cadence.BadRequestError)

Example 5 with InternalServiceError

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();
    }
}
Also used : InternalServiceError(com.uber.cadence.InternalServiceError) EntityNotExistsError(com.uber.cadence.EntityNotExistsError) BadRequestError(com.uber.cadence.BadRequestError) TException(org.apache.thrift.TException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

InternalServiceError (com.uber.cadence.InternalServiceError)17 EntityNotExistsError (com.uber.cadence.EntityNotExistsError)10 IOException (java.io.IOException)8 BadRequestError (com.uber.cadence.BadRequestError)7 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 DataInputStream (java.io.DataInputStream)3 DataOutputStream (java.io.DataOutputStream)3 ExecutionException (java.util.concurrent.ExecutionException)3 TException (org.apache.thrift.TException)3 ChildWorkflowExecutionCanceledEventAttributes (com.uber.cadence.ChildWorkflowExecutionCanceledEventAttributes)1 ChildWorkflowExecutionCompletedEventAttributes (com.uber.cadence.ChildWorkflowExecutionCompletedEventAttributes)1 ChildWorkflowExecutionFailedEventAttributes (com.uber.cadence.ChildWorkflowExecutionFailedEventAttributes)1 ChildWorkflowExecutionStartedEventAttributes (com.uber.cadence.ChildWorkflowExecutionStartedEventAttributes)1 ChildWorkflowExecutionTimedOutEventAttributes (com.uber.cadence.ChildWorkflowExecutionTimedOutEventAttributes)1 Decision (com.uber.cadence.Decision)1 DecisionTaskStartedEventAttributes (com.uber.cadence.DecisionTaskStartedEventAttributes)1 GetWorkflowExecutionHistoryRequest (com.uber.cadence.GetWorkflowExecutionHistoryRequest)1 History (com.uber.cadence.History)1 HistoryEvent (com.uber.cadence.HistoryEvent)1