use of io.prestosql.execution.StateMachine.StateChangeListener in project hetu-core by openlookeng.
the class StageStateMachine 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<StageInfo> finalStatusListener) {
AtomicBoolean done = new AtomicBoolean();
StateChangeListener<Optional<StageInfo>> fireOnceStateChangeListener = finalStageInfo -> {
if (finalStageInfo.isPresent() && done.compareAndSet(false, true)) {
finalStatusListener.stateChanged(finalStageInfo.get());
}
};
finalStageInfo.addStateChangeListener(fireOnceStateChangeListener);
}
use of io.prestosql.execution.StateMachine.StateChangeListener in project hetu-core by openlookeng.
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 io.prestosql.execution.StateMachine.StateChangeListener in project hetu-core by openlookeng.
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);
}
Aggregations