public void endQuery() { endQuery(tickerNanos()); }
private void transitionToFinished() { cleanupQueryQuietly(); queryStateTimer.endQuery(); queryState.setIf(FINISHED, currentState -> !currentState.isDone()); }
public boolean transitionToCanceled() { cleanupQueryQuietly(); queryStateTimer.endQuery(); // NOTE: The failure cause must be set before triggering the state change, so // listeners can observe the exception. This is safe because the failure cause // can only be observed if the transition to FAILED is successful. failureCause.compareAndSet(null, toFailure(new PrestoException(USER_CANCELED, "Query was canceled"))); boolean canceled = queryState.setIf(FAILED, currentState -> !currentState.isDone()); if (canceled) { session.getTransactionId().ifPresent(transactionId -> { if (transactionManager.isAutoCommit(transactionId)) { transactionManager.asyncAbort(transactionId); } else { transactionManager.fail(transactionId); } }); } return canceled; }
public boolean transitionToFailed(Throwable throwable) { cleanupQueryQuietly(); queryStateTimer.endQuery(); // NOTE: The failure cause must be set before triggering the state change, so // listeners can observe the exception. This is safe because the failure cause // can only be observed if the transition to FAILED is successful. requireNonNull(throwable, "throwable is null"); failureCause.compareAndSet(null, toFailure(throwable)); boolean failed = queryState.setIf(FAILED, currentState -> !currentState.isDone()); if (failed) { QUERY_STATE_LOG.debug(throwable, "Query %s failed", queryId); session.getTransactionId().ifPresent(transactionId -> { if (transactionManager.isAutoCommit(transactionId)) { transactionManager.asyncAbort(transactionId); } else { transactionManager.fail(transactionId); } }); } else { QUERY_STATE_LOG.debug(throwable, "Failure after query %s finished", queryId); } return failed; }