use of com.facebook.presto.execution.QueryState.FINISHING in project presto by prestodb.
the class QueryStateMachine method transitionToFinishing.
public boolean transitionToFinishing() {
Duration durationSinceCreation = nanosSince(createNanos).convertToMostSuccinctTimeUnit();
queuedTime.compareAndSet(null, durationSinceCreation);
totalPlanningStartNanos.compareAndSet(null, tickerNanos());
totalPlanningTime.compareAndSet(null, nanosSince(totalPlanningStartNanos.get()));
DateTime now = DateTime.now();
executionStartTime.compareAndSet(null, now);
finishingStartNanos.compareAndSet(null, tickerNanos());
if (!queryState.setIf(FINISHING, currentState -> currentState != FINISHING && !currentState.isDone())) {
return false;
}
if (autoCommit) {
ListenableFuture<?> commitFuture = transactionManager.asyncCommit(session.getTransactionId().get());
Futures.addCallback(commitFuture, new FutureCallback<Object>() {
@Override
public void onSuccess(@Nullable Object result) {
transitionToFinished();
}
@Override
public void onFailure(Throwable throwable) {
transitionToFailed(throwable);
}
});
} else {
transitionToFinished();
}
return true;
}
Aggregations