private void waitForAsyncRenames() { for (CompletableFuture<?> fileRenameFuture : fileRenameFutures) { MoreFutures.getFutureValue(fileRenameFuture, PrestoException.class); } }
@Override public void fatal(Throwable cause) { try (SetThreadName ignored = new SetThreadName("UpdateResponseHandler-%s", taskId)) { failTask(cause); } }
public TaskManagementExecutor() { taskManagementExecutor = newScheduledThreadPool(5, threadsNamed("task-management-%s")); taskManagementExecutorMBean = new ThreadPoolExecutorMBean((ThreadPoolExecutor) taskManagementExecutor); }
@Inject public IndexLookup(Connector connector, ColumnCardinalityCache cardinalityCache) { this.connector = requireNonNull(connector, "connector is null"); this.cardinalityCache = requireNonNull(cardinalityCache, "cardinalityCache is null"); // Create a bounded executor with a pool size at 4x number of processors this.coreExecutor = newCachedThreadPool(daemonThreadsNamed("cardinality-lookup-%s")); this.executorService = new BoundedExecutor(coreExecutor, 4 * Runtime.getRuntime().availableProcessors()); }
public TestScanFilterAndProjectOperator() { executor = newCachedThreadPool(daemonThreadsNamed("test-executor-%s")); scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed("test-scheduledExecutor-%s")); }
private void updateSignalAndStatusFutures() { dataSignalFuture = whenAnyComplete(dataRequests); statusFuture = toCompletableFuture(nonCancellationPropagating(dataSignalFuture)); }
@Override public boolean needsInput() { if (finishing || outputPage != null) { return false; } if (channelSet == null) { channelSet = tryGetFutureValue(channelSetFuture).orElse(null); } return channelSet != null; }
public void process(OutputBuffer delegate) { if (futureResult.isDone()) { return; } try { ListenableFuture<BufferResult> result = delegate.get(bufferId, startingSequenceId, maxSize); futureResult.setAsync(result); } catch (Exception e) { futureResult.setException(e); } } }
private void waitForMinimumWorkers() { ListenableFuture<?> minimumWorkerFuture = clusterSizeMonitor.waitForMinimumWorkers(); addSuccessCallback(minimumWorkerFuture, this::startExecution); addExceptionCallback(minimumWorkerFuture, stateMachine::transitionToFailed); }
@Inject public QueryExecutionMBean(@ForQueryExecution ExecutorService executor) { this.executorMBean = new ThreadPoolExecutorMBean((ThreadPoolExecutor) executor); }
@Override public ListenableFuture<?> isBlocked() { CompletableFuture<?> pageSourceBlocked = pageSource.isBlocked(); return pageSourceBlocked.isDone() ? NOT_BLOCKED : toListenableFuture(pageSourceBlocked); }
@Override public void finish() { if (finishing) { return; } if (!spillInProgress.isDone()) { return; } checkSuccess(spillInProgress, "spilling failed"); finishing = true; }
@Override public void abort() { getFutureValue(finish()); }
@BeforeClass public void setupClass() { executor = newCachedThreadPool(daemonThreadsNamed("hive-%s")); }
private static <T> T requireFutureValue(Future<T> future) { return tryGetFutureValue(future).orElseThrow(AssertionError::new); }
@Override public void fatal(Throwable cause) { try (SetThreadName ignored = new SetThreadName("TaskInfoFetcher-%s", taskId)) { onFail.accept(cause); } }
private boolean hasPreviousSpillCompletedSuccessfully() { if (spillInProgress.isDone()) { // check for exception from previous spill for early failure getFutureValue(spillInProgress); return true; } else { return false; } }
@Override public void addStateChangeListener(StateChangeListener<TaskStatus> stateChangeListener) { try (SetThreadName ignored = new SetThreadName("HttpRemoteTask-%s", taskId)) { taskStatusFetcher.addStateChangeListener(stateChangeListener); } }
@Override public void addInput(Page page) { int multiplier = getFutureValue(multiplierFuture); for (int i = 0; i < multiplier; i++) { pages.add(page); } }
@Override public void addStateChangeListener(StateChangeListener<QueryState> stateChangeListener) { try (SetThreadName ignored = new SetThreadName("Query-%s", stateMachine.getQueryId())) { stateMachine.addStateChangeListener(stateChangeListener); } }