use of com.facebook.presto.execution.StateMachine.StateChangeListener in project presto by prestodb.
the class QueryStateMachine method addQueryInfoStateChangeListener.
/**
* Add a listener for the final query info. This notification is guaranteed to be fired only once.
* Listener is always notified asynchronously using a dedicated notification thread pool so, care should
* be taken to avoid leaking {@code this} when adding a listener in a constructor.
*/
public void addQueryInfoStateChangeListener(StateChangeListener<QueryInfo> stateChangeListener) {
AtomicBoolean done = new AtomicBoolean();
StateChangeListener<Optional<QueryInfo>> fireOnceStateChangeListener = finalQueryInfo -> {
if (finalQueryInfo.isPresent() && done.compareAndSet(false, true)) {
stateChangeListener.stateChanged(finalQueryInfo.get());
}
};
finalQueryInfo.addStateChangeListener(fireOnceStateChangeListener);
}
use of com.facebook.presto.execution.StateMachine.StateChangeListener in project presto by prestodb.
the class TaskInfoFetcher method addFinalTaskInfoListener.
/**
* Add a listener for the final task info. This notification is guaranteed to be fired only once.
* Listener is always notified asynchronously using a dedicated notification thread pool so, care should
* be taken to avoid leaking {@code this} when adding a listener in a constructor. Additionally, it is
* possible notifications are observed out of order due to the asynchronous execution.
*/
public void addFinalTaskInfoListener(StateChangeListener<TaskInfo> stateChangeListener) {
AtomicBoolean done = new AtomicBoolean();
StateChangeListener<Optional<TaskInfo>> fireOnceStateChangeListener = finalTaskInfo -> {
if (finalTaskInfo.isPresent() && done.compareAndSet(false, true)) {
stateChangeListener.stateChanged(finalTaskInfo.get());
}
};
finalTaskInfo.addStateChangeListener(fireOnceStateChangeListener);
fireOnceStateChangeListener.stateChanged(finalTaskInfo.get());
}
use of com.facebook.presto.execution.StateMachine.StateChangeListener in project presto by prestodb.
the class StageExecutionStateMachine method addFinalStageInfoListener.
/**
* Add a listener for the final stage info. This notification is guaranteed to be fired only once.
* Listener is always notified asynchronously using a dedicated notification thread pool so, care should
* be taken to avoid leaking {@code this} when adding a listener in a constructor. Additionally, it is
* possible notifications are observed out of order due to the asynchronous execution.
*/
public void addFinalStageInfoListener(StateChangeListener<StageExecutionInfo> finalStatusListener) {
AtomicBoolean done = new AtomicBoolean();
StateChangeListener<Optional<StageExecutionInfo>> fireOnceStateChangeListener = finalStageInfo -> {
if (finalStageInfo.isPresent() && done.compareAndSet(false, true)) {
finalStatusListener.stateChanged(finalStageInfo.get());
}
};
finalInfo.addStateChangeListener(fireOnceStateChangeListener);
}
Aggregations