use of com.facebook.presto.execution.SqlStageExecution in project presto by prestodb.
the class TestSourcePartitionedScheduler method testScheduleSplitsBatched.
@Test
public void testScheduleSplitsBatched() throws Exception {
StageExecutionPlan plan = createPlan(createFixedSplitSource(60, TestingSplit::createRemoteSplit));
NodeTaskMap nodeTaskMap = new NodeTaskMap(finalizerService);
SqlStageExecution stage = createSqlStageExecution(plan, nodeTaskMap);
SourcePartitionedScheduler scheduler = getSourcePartitionedScheduler(plan, stage, nodeManager, nodeTaskMap, 7);
for (int i = 0; i <= (60 / 7); i++) {
ScheduleResult scheduleResult = scheduler.schedule();
// finishes when last split is fetched
assertEquals(scheduleResult.isFinished(), i == (60 / 7));
// never blocks
assertTrue(scheduleResult.getBlocked().isDone());
// first three splits create new tasks
assertEquals(scheduleResult.getNewTasks().size(), i == 0 ? 3 : 0);
assertEquals(stage.getAllTasks().size(), 3);
assertPartitionedSplitCount(stage, min((i + 1) * 7, 60));
}
for (RemoteTask remoteTask : stage.getAllTasks()) {
assertEquals(remoteTask.getPartitionedSplitCount(), 20);
}
stage.abort();
}
use of com.facebook.presto.execution.SqlStageExecution in project presto by prestodb.
the class TestSourcePartitionedScheduler method testNoNodes.
@Test
public void testNoNodes() throws Exception {
try {
NodeTaskMap nodeTaskMap = new NodeTaskMap(finalizerService);
InMemoryNodeManager nodeManager = new InMemoryNodeManager();
NodeScheduler nodeScheduler = new NodeScheduler(new LegacyNetworkTopology(), nodeManager, new NodeSchedulerConfig().setIncludeCoordinator(false), nodeTaskMap);
StageExecutionPlan plan = createPlan(createFixedSplitSource(20, TestingSplit::createRemoteSplit));
SqlStageExecution stage = createSqlStageExecution(plan, nodeTaskMap);
SourcePartitionedScheduler scheduler = new SourcePartitionedScheduler(stage, Iterables.getOnlyElement(plan.getSplitSources().keySet()), Iterables.getOnlyElement(plan.getSplitSources().values()), new DynamicSplitPlacementPolicy(nodeScheduler.createNodeSelector(CONNECTOR_ID), stage::getAllTasks), 2);
scheduler.schedule();
fail("expected PrestoException");
} catch (PrestoException e) {
assertEquals(e.getErrorCode(), NO_NODES_AVAILABLE.toErrorCode());
}
}
Aggregations