Search in sources :

Example 1 with FailureWrapperException

use of io.temporal.internal.replay.FailureWrapperException in project sdk-java by temporalio.

the class POJOActivityTaskHandler method mapToActivityFailure.

@SuppressWarnings("deprecation")
private ActivityTaskHandler.Result mapToActivityFailure(Throwable exception, String activityId, Scope metricsScope, boolean isLocalActivity) {
    if (exception instanceof ActivityCanceledException) {
        if (isLocalActivity) {
            metricsScope.counter(MetricsType.LOCAL_ACTIVITY_EXEC_CANCELLED_COUNTER).inc(1);
            metricsScope.counter(MetricsType.LOCAL_ACTIVITY_CANCELED_COUNTER).inc(1);
        } else {
            metricsScope.counter(MetricsType.ACTIVITY_EXEC_CANCELLED_COUNTER).inc(1);
            metricsScope.counter(MetricsType.ACTIVITY_CANCELED_COUNTER).inc(1);
        }
        String stackTrace = FailureConverter.serializeStackTrace(exception);
        throw new FailureWrapperException(Failure.newBuilder().setStackTrace(stackTrace).setCanceledFailureInfo(CanceledFailureInfo.newBuilder()).build());
    }
    Scope ms = metricsScope.tagged(ImmutableMap.of(MetricsTag.EXCEPTION, exception.getClass().getSimpleName()));
    if (isLocalActivity) {
        ms.counter(MetricsType.LOCAL_ACTIVITY_EXEC_FAILED_COUNTER).inc(1);
        ms.counter(MetricsType.LOCAL_ACTIVITY_FAILED_COUNTER).inc(1);
    } else {
        ms.counter(MetricsType.ACTIVITY_EXEC_FAILED_COUNTER).inc(1);
    }
    if (exception instanceof TemporalFailure) {
        ((TemporalFailure) exception).setDataConverter(dataConverter);
    }
    if (exception instanceof TimeoutFailure) {
        exception = new SimulatedTimeoutFailure((TimeoutFailure) exception);
    }
    Failure failure = FailureConverter.exceptionToFailure(exception);
    RespondActivityTaskFailedRequest.Builder result = RespondActivityTaskFailedRequest.newBuilder().setFailure(failure);
    return new ActivityTaskHandler.Result(activityId, null, new Result.TaskFailedResult(result.build(), exception), null, null, false);
}
Also used : FailureWrapperException(io.temporal.internal.replay.FailureWrapperException) Scope(com.uber.m3.tally.Scope) TimeoutFailure(io.temporal.failure.TimeoutFailure) SimulatedTimeoutFailure(io.temporal.failure.SimulatedTimeoutFailure) ActivityCanceledException(io.temporal.client.ActivityCanceledException) TemporalFailure(io.temporal.failure.TemporalFailure) SimulatedTimeoutFailure(io.temporal.failure.SimulatedTimeoutFailure) TimeoutFailure(io.temporal.failure.TimeoutFailure) TemporalFailure(io.temporal.failure.TemporalFailure) SimulatedTimeoutFailure(io.temporal.failure.SimulatedTimeoutFailure) Failure(io.temporal.api.failure.v1.Failure) RespondActivityTaskFailedRequest(io.temporal.api.workflowservice.v1.RespondActivityTaskFailedRequest)

Aggregations

Scope (com.uber.m3.tally.Scope)1 Failure (io.temporal.api.failure.v1.Failure)1 RespondActivityTaskFailedRequest (io.temporal.api.workflowservice.v1.RespondActivityTaskFailedRequest)1 ActivityCanceledException (io.temporal.client.ActivityCanceledException)1 SimulatedTimeoutFailure (io.temporal.failure.SimulatedTimeoutFailure)1 TemporalFailure (io.temporal.failure.TemporalFailure)1 TimeoutFailure (io.temporal.failure.TimeoutFailure)1 FailureWrapperException (io.temporal.internal.replay.FailureWrapperException)1