Search in sources :

Example 1 with PeriodicTaskExecutor

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();
}
Also used : PeriodicTaskExecutor(com.facebook.presto.util.PeriodicTaskExecutor)

Example 2 with PeriodicTaskExecutor

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;
            });
        }
    });
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) PeriodicTaskExecutor(com.facebook.presto.util.PeriodicTaskExecutor) QueryId(com.facebook.presto.spi.QueryId)

Aggregations

PeriodicTaskExecutor (com.facebook.presto.util.PeriodicTaskExecutor)2 QueryId (com.facebook.presto.spi.QueryId)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1