Search in sources :

Example 1 with ActivityTimeoutException

use of com.uber.cadence.workflow.ActivityTimeoutException in project cadence-client by uber-java.

the class WorkflowTestingTest method testActivityScheduleToCloseTimeout.

@Test
public void testActivityScheduleToCloseTimeout() {
    Worker worker = testEnvironment.newWorker(TASK_LIST);
    worker.registerWorkflowImplementationTypes(TestActivityTimeoutWorkflowImpl.class);
    worker.registerActivitiesImplementations(new TimingOutActivityImpl());
    worker.start();
    WorkflowClient client = testEnvironment.newWorkflowClient();
    TestActivityTimeoutWorkflow workflow = client.newWorkflowStub(TestActivityTimeoutWorkflow.class);
    try {
        workflow.workflow(1, 10, 10);
        fail("unreacheable");
    } catch (WorkflowException e) {
        assertTrue(e.getCause() instanceof ActivityTimeoutException);
        assertEquals(TimeoutType.SCHEDULE_TO_CLOSE, ((ActivityTimeoutException) e.getCause()).getTimeoutType());
    }
}
Also used : ActivityTimeoutException(com.uber.cadence.workflow.ActivityTimeoutException) WorkflowException(com.uber.cadence.client.WorkflowException) Worker(com.uber.cadence.worker.Worker) WorkflowClient(com.uber.cadence.client.WorkflowClient) Test(org.junit.Test)

Example 2 with ActivityTimeoutException

use of com.uber.cadence.workflow.ActivityTimeoutException in project cadence-client by uber-java.

the class WorkflowTestingTest method testActivityScheduleToStartTimeout.

@Test
public void testActivityScheduleToStartTimeout() {
    Worker worker = testEnvironment.newWorker(TASK_LIST);
    worker.registerWorkflowImplementationTypes(TestActivityTimeoutWorkflowImpl.class);
    worker.start();
    WorkflowClient client = testEnvironment.newWorkflowClient();
    TestActivityTimeoutWorkflow workflow = client.newWorkflowStub(TestActivityTimeoutWorkflow.class);
    try {
        workflow.workflow(10, 1, 10);
        fail("unreacheable");
    } catch (WorkflowException e) {
        assertTrue(e.getCause() instanceof ActivityTimeoutException);
        assertEquals(TimeoutType.SCHEDULE_TO_START, ((ActivityTimeoutException) e.getCause()).getTimeoutType());
    }
}
Also used : ActivityTimeoutException(com.uber.cadence.workflow.ActivityTimeoutException) WorkflowException(com.uber.cadence.client.WorkflowException) Worker(com.uber.cadence.worker.Worker) WorkflowClient(com.uber.cadence.client.WorkflowClient) Test(org.junit.Test)

Example 3 with ActivityTimeoutException

use of com.uber.cadence.workflow.ActivityTimeoutException in project cadence-client by uber-java.

the class WorkflowTestingTest method testActivityStartToCloseTimeout.

@Test
public void testActivityStartToCloseTimeout() {
    Worker worker = testEnvironment.newWorker(TASK_LIST);
    worker.registerWorkflowImplementationTypes(TestActivityTimeoutWorkflowImpl.class);
    worker.registerActivitiesImplementations(new TimingOutActivityImpl());
    worker.start();
    WorkflowClient client = testEnvironment.newWorkflowClient();
    TestActivityTimeoutWorkflow workflow = client.newWorkflowStub(TestActivityTimeoutWorkflow.class);
    try {
        workflow.workflow(10, 10, 1);
        fail("unreacheable");
    } catch (WorkflowException e) {
        assertTrue(e.getCause() instanceof ActivityTimeoutException);
        assertEquals(TimeoutType.START_TO_CLOSE, ((ActivityTimeoutException) e.getCause()).getTimeoutType());
    }
}
Also used : ActivityTimeoutException(com.uber.cadence.workflow.ActivityTimeoutException) WorkflowException(com.uber.cadence.client.WorkflowException) Worker(com.uber.cadence.worker.Worker) WorkflowClient(com.uber.cadence.client.WorkflowClient) Test(org.junit.Test)

Example 4 with ActivityTimeoutException

use of com.uber.cadence.workflow.ActivityTimeoutException in project cadence-client by uber-java.

the class SyncDecisionContext method mapActivityException.

private RuntimeException mapActivityException(Exception failure) {
    if (failure == null) {
        return null;
    }
    if (failure instanceof CancellationException) {
        return (CancellationException) failure;
    }
    if (failure instanceof ActivityTaskFailedException) {
        ActivityTaskFailedException taskFailed = (ActivityTaskFailedException) failure;
        String causeClassName = taskFailed.getReason();
        Class<? extends Exception> causeClass;
        Exception cause;
        try {
            // cc is just to have a place to put this annotation
            @SuppressWarnings("unchecked") Class<? extends Exception> cc = (Class<? extends Exception>) Class.forName(causeClassName);
            causeClass = cc;
            cause = getDataConverter().fromData(taskFailed.getDetails(), causeClass);
        } catch (Exception e) {
            cause = e;
        }
        return new ActivityFailureException(taskFailed.getEventId(), taskFailed.getActivityType(), taskFailed.getActivityId(), cause);
    }
    if (failure instanceof ActivityTaskTimeoutException) {
        ActivityTaskTimeoutException timedOut = (ActivityTaskTimeoutException) failure;
        return new ActivityTimeoutException(timedOut.getEventId(), timedOut.getActivityType(), timedOut.getActivityId(), timedOut.getTimeoutType(), timedOut.getDetails(), getDataConverter());
    }
    if (failure instanceof ActivityException) {
        return (ActivityException) failure;
    }
    throw new IllegalArgumentException("Unexpected exception type: " + failure.getClass().getName(), failure);
}
Also used : ActivityFailureException(com.uber.cadence.workflow.ActivityFailureException) ActivityTimeoutException(com.uber.cadence.workflow.ActivityTimeoutException) CancellationException(java.util.concurrent.CancellationException) ActivityException(com.uber.cadence.workflow.ActivityException) ActivityTaskFailedException(com.uber.cadence.internal.replay.ActivityTaskFailedException) ActivityTimeoutException(com.uber.cadence.workflow.ActivityTimeoutException) ChildWorkflowTaskFailedException(com.uber.cadence.internal.replay.ChildWorkflowTaskFailedException) ActivityTaskTimeoutException(com.uber.cadence.internal.replay.ActivityTaskTimeoutException) ActivityTaskFailedException(com.uber.cadence.internal.replay.ActivityTaskFailedException) ChildWorkflowFailureException(com.uber.cadence.workflow.ChildWorkflowFailureException) CancellationException(java.util.concurrent.CancellationException) ChildWorkflowException(com.uber.cadence.workflow.ChildWorkflowException) ActivityFailureException(com.uber.cadence.workflow.ActivityFailureException) SignalExternalWorkflowException(com.uber.cadence.workflow.SignalExternalWorkflowException) ActivityException(com.uber.cadence.workflow.ActivityException) ActivityTaskTimeoutException(com.uber.cadence.internal.replay.ActivityTaskTimeoutException)

Aggregations

ActivityTimeoutException (com.uber.cadence.workflow.ActivityTimeoutException)4 WorkflowClient (com.uber.cadence.client.WorkflowClient)3 WorkflowException (com.uber.cadence.client.WorkflowException)3 Worker (com.uber.cadence.worker.Worker)3 Test (org.junit.Test)3 ActivityTaskFailedException (com.uber.cadence.internal.replay.ActivityTaskFailedException)1 ActivityTaskTimeoutException (com.uber.cadence.internal.replay.ActivityTaskTimeoutException)1 ChildWorkflowTaskFailedException (com.uber.cadence.internal.replay.ChildWorkflowTaskFailedException)1 ActivityException (com.uber.cadence.workflow.ActivityException)1 ActivityFailureException (com.uber.cadence.workflow.ActivityFailureException)1 ChildWorkflowException (com.uber.cadence.workflow.ChildWorkflowException)1 ChildWorkflowFailureException (com.uber.cadence.workflow.ChildWorkflowFailureException)1 SignalExternalWorkflowException (com.uber.cadence.workflow.SignalExternalWorkflowException)1 CancellationException (java.util.concurrent.CancellationException)1