use of com.facebook.presto.execution.Lifespan in project presto by prestodb.
the class HttpRemoteTask method processTaskUpdate.
private synchronized void processTaskUpdate(TaskInfo newValue, List<TaskSource> sources) {
updateTaskInfo(newValue);
// remove acknowledged splits, which frees memory
for (TaskSource source : sources) {
PlanNodeId planNodeId = source.getPlanNodeId();
boolean isTableScanSource = tableScanPlanNodeIds.contains(planNodeId);
int removed = 0;
long removedWeight = 0;
for (ScheduledSplit split : source.getSplits()) {
if (pendingSplits.remove(planNodeId, split)) {
if (isTableScanSource) {
removed++;
removedWeight = addExact(removedWeight, split.getSplit().getSplitWeight().getRawValue());
}
}
}
if (source.isNoMoreSplits()) {
noMoreSplits.put(planNodeId, false);
}
for (Lifespan lifespan : source.getNoMoreSplitsForLifespan()) {
pendingNoMoreSplitsForLifespan.remove(planNodeId, lifespan);
}
if (isTableScanSource) {
pendingSourceSplitCount -= removed;
pendingSourceSplitsWeight -= removedWeight;
}
}
// Update stats before split queue space to ensure node stats are up to date before waking up the scheduler
updateTaskStats();
updateSplitQueueSpace();
}
use of com.facebook.presto.execution.Lifespan in project presto by prestodb.
the class TestHttpRemoteTask method testRegular.
@Test(timeOut = 30000, dataProvider = "thriftEncodingToggle")
public void testRegular(boolean useThriftEncoding) throws Exception {
AtomicLong lastActivityNanos = new AtomicLong(System.nanoTime());
TestingTaskResource testingTaskResource = new TestingTaskResource(lastActivityNanos, FailureScenario.NO_FAILURE);
HttpRemoteTaskFactory httpRemoteTaskFactory = createHttpRemoteTaskFactory(testingTaskResource, useThriftEncoding);
RemoteTask remoteTask = createRemoteTask(httpRemoteTaskFactory);
testingTaskResource.setInitialTaskInfo(remoteTask.getTaskInfo());
remoteTask.start();
Lifespan lifespan = Lifespan.driverGroup(3);
remoteTask.addSplits(ImmutableMultimap.of(TABLE_SCAN_NODE_ID, new Split(new ConnectorId("test"), TestingTransactionHandle.create(), TestingSplit.createLocalSplit(), lifespan, NON_CACHEABLE)));
poll(() -> testingTaskResource.getTaskSource(TABLE_SCAN_NODE_ID) != null);
poll(() -> testingTaskResource.getTaskSource(TABLE_SCAN_NODE_ID).getSplits().size() == 1);
remoteTask.noMoreSplits(TABLE_SCAN_NODE_ID, lifespan);
poll(() -> testingTaskResource.getTaskSource(TABLE_SCAN_NODE_ID).getNoMoreSplitsForLifespan().size() == 1);
remoteTask.noMoreSplits(TABLE_SCAN_NODE_ID);
poll(() -> testingTaskResource.getTaskSource(TABLE_SCAN_NODE_ID).isNoMoreSplits());
remoteTask.cancel();
poll(() -> remoteTask.getTaskStatus().getState().isDone());
poll(() -> remoteTask.getTaskInfo().getTaskStatus().getState().isDone());
httpRemoteTaskFactory.stop();
}
Aggregations