Search in sources :

Example 1 with QueryFailedError

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

the class TestWorkflowMutableStateImpl method completeQuery.

@Override
public void completeQuery(QueryId queryId, RespondQueryTaskCompletedRequest completeRequest) throws EntityNotExistsError {
    CompletableFuture<QueryWorkflowResponse> result = queries.get(queryId.getQueryId());
    if (result == null) {
        throw new EntityNotExistsError("Unknown query id: " + queryId.getQueryId());
    }
    if (completeRequest.getCompletedType() == QueryTaskCompletedType.COMPLETED) {
        QueryWorkflowResponse response = new QueryWorkflowResponse().setQueryResult(completeRequest.getQueryResult());
        result.complete(response);
    } else {
        QueryFailedError error = new QueryFailedError().setMessage(completeRequest.getErrorMessage());
        result.completeExceptionally(error);
    }
}
Also used : QueryWorkflowResponse(com.uber.cadence.QueryWorkflowResponse) EntityNotExistsError(com.uber.cadence.EntityNotExistsError) QueryFailedError(com.uber.cadence.QueryFailedError)

Example 2 with QueryFailedError

use of com.uber.cadence.QueryFailedError 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;
    }
}
Also used : WorkflowNotFoundException(com.uber.cadence.client.WorkflowNotFoundException) InternalServiceError(com.uber.cadence.InternalServiceError) EntityNotExistsError(com.uber.cadence.EntityNotExistsError) QueryFailedError(com.uber.cadence.QueryFailedError) QueryWorkflowParameters(com.uber.cadence.internal.replay.QueryWorkflowParameters) DuplicateWorkflowException(com.uber.cadence.client.DuplicateWorkflowException) TimeoutException(java.util.concurrent.TimeoutException) WorkflowFailureException(com.uber.cadence.client.WorkflowFailureException) WorkflowNotFoundException(com.uber.cadence.client.WorkflowNotFoundException) WorkflowQueryException(com.uber.cadence.client.WorkflowQueryException) WorkflowException(com.uber.cadence.client.WorkflowException) CancellationException(java.util.concurrent.CancellationException) CompletionException(java.util.concurrent.CompletionException) WorkflowExecutionFailedException(com.uber.cadence.internal.common.WorkflowExecutionFailedException) WorkflowServiceException(com.uber.cadence.client.WorkflowServiceException) WorkflowQueryException(com.uber.cadence.client.WorkflowQueryException) WorkflowServiceException(com.uber.cadence.client.WorkflowServiceException)

Aggregations

EntityNotExistsError (com.uber.cadence.EntityNotExistsError)2 QueryFailedError (com.uber.cadence.QueryFailedError)2 InternalServiceError (com.uber.cadence.InternalServiceError)1 QueryWorkflowResponse (com.uber.cadence.QueryWorkflowResponse)1 DuplicateWorkflowException (com.uber.cadence.client.DuplicateWorkflowException)1 WorkflowException (com.uber.cadence.client.WorkflowException)1 WorkflowFailureException (com.uber.cadence.client.WorkflowFailureException)1 WorkflowNotFoundException (com.uber.cadence.client.WorkflowNotFoundException)1 WorkflowQueryException (com.uber.cadence.client.WorkflowQueryException)1 WorkflowServiceException (com.uber.cadence.client.WorkflowServiceException)1 WorkflowExecutionFailedException (com.uber.cadence.internal.common.WorkflowExecutionFailedException)1 QueryWorkflowParameters (com.uber.cadence.internal.replay.QueryWorkflowParameters)1 CancellationException (java.util.concurrent.CancellationException)1 CompletionException (java.util.concurrent.CompletionException)1 TimeoutException (java.util.concurrent.TimeoutException)1