@Override public void sendResult(RpcOutcomeListener<Ack> listener, QueryResult result) { Preconditions.checkState(result.hasQueryState()); // Release the wait latch if the query is terminated. final QueryState state = result.getQueryState(); final QueryId queryId = result.getQueryId(); if (logger.isDebugEnabled()) { logger.debug("Result arrived for QueryId: {} with QueryState: {}", QueryIdHelper.getQueryId(queryId), state); } switch (state) { case FAILED: error = result.getError(0); exception = new UserRemoteException(error); latch.countDown(); break; case CANCELED: case COMPLETED: Preconditions.checkState(result.getErrorCount() == 0); latch.countDown(); break; default: logger.error("Query with QueryId: {} is in unexpected state: {}", queryId, state); } // Notify the listener with ACK listener.success(Acks.OK, null); }
resultsListener.submissionFailed(new UserRemoteException(queryResult.getError(0)));