use of com.facebook.presto.util.PeriodicTaskExecutor in project presto by prestodb.
the class ConfidenceBasedNodeTtlFetcherManager method scheduleRefresh.
public void scheduleRefresh() {
periodicTtlRefresher = new PeriodicTaskExecutor(ttlFetcher.get().getRefreshInterval().toMillis(), nodeTtlFetcherManagerConfig.getInitialDelayBeforeRefresh().toMillis(), newSingleThreadScheduledExecutor(threadsNamed("refresh-node-ttl-executor-%s")), this::refreshTtlInfo, ConfidenceBasedNodeTtlFetcherManager::jitterForPeriodicRefresh);
periodicTtlRefresher.start();
}
use of com.facebook.presto.util.PeriodicTaskExecutor in project presto by prestodb.
the class ResourceManagerClusterStatusSender method registerQuery.
@Override
public void registerQuery(ManagedQueryExecution queryExecution) {
QueryId queryId = queryExecution.getBasicQueryInfo().getQueryId();
queries.computeIfAbsent(queryId, unused -> {
AtomicLong sequenceId = new AtomicLong();
PeriodicTaskExecutor taskExecutor = new PeriodicTaskExecutor(queryHeartbeatInterval.toMillis(), executor, () -> sendQueryHeartbeat(queryExecution, sequenceId.incrementAndGet()));
taskExecutor.start();
return taskExecutor;
});
queryExecution.addStateChangeListener(newState -> {
if (newState.isDone()) {
queries.computeIfPresent(queryId, (unused, queryHeartbeatSender) -> {
queryHeartbeatSender.forceRun();
queryHeartbeatSender.stop();
return null;
});
}
});
}
Aggregations