use of edu.iu.dsc.tws.api.compute.graph.ComputeGraph in project twister2 by DSC-SPIDAL.
the class DataLocalityTaskSchedulerTest method testUniqueSchedules2.
@Test
public void testUniqueSchedules2() {
int parallel = 10;
int workers = 2;
ComputeGraph graph = createGraphWithConstraints(parallel);
DataLocalityStreamingTaskScheduler scheduler = new DataLocalityStreamingTaskScheduler();
Config config = getConfig();
scheduler.initialize(config, 1);
generateData(config);
WorkerPlan workerPlan = createWorkPlan(workers);
TaskSchedulePlan plan1 = scheduler.schedule(graph, workerPlan);
Assert.assertNotNull(plan1);
Map<Integer, WorkerSchedulePlan> containersMap = plan1.getContainersMap();
for (Map.Entry<Integer, WorkerSchedulePlan> entry : containersMap.entrySet()) {
WorkerSchedulePlan workerSchedulePlan = entry.getValue();
Set<TaskInstancePlan> containerPlanTaskInstances = workerSchedulePlan.getTaskInstances();
Assert.assertEquals(containerPlanTaskInstances.size(), Integer.parseInt(graph.getGraphConstraints().get(Context.TWISTER2_MAX_TASK_INSTANCES_PER_WORKER)));
}
}
use of edu.iu.dsc.tws.api.compute.graph.ComputeGraph in project twister2 by DSC-SPIDAL.
the class DataLocalityTaskSchedulerTest method createGraphWithComputeTaskAndConstraints.
private ComputeGraph createGraphWithComputeTaskAndConstraints(int parallel) {
TaskSchedulerClassTest.TestSource testSource = new TaskSchedulerClassTest.TestSource();
TaskSchedulerClassTest.TestCompute testCompute = new TaskSchedulerClassTest.TestCompute();
TaskSchedulerClassTest.TestSink testSink = new TaskSchedulerClassTest.TestSink();
ComputeGraphBuilder computeGraphBuilder = ComputeGraphBuilder.newBuilder(Config.newBuilder().build());
computeGraphBuilder.addSource("source", testSource, parallel);
ComputeConnection computeConnection = computeGraphBuilder.addCompute("compute", testCompute, parallel);
ComputeConnection sinkComputeConnection = computeGraphBuilder.addCompute("sink", testSink, parallel);
computeConnection.direct("source").viaEdge("cdirect-edge").withDataType(MessageTypes.OBJECT);
sinkComputeConnection.direct("compute").viaEdge("sdirect-edge").withDataType(MessageTypes.OBJECT);
computeGraphBuilder.setMode(OperationMode.STREAMING);
computeGraphBuilder.addGraphConstraints(Context.TWISTER2_MAX_TASK_INSTANCES_PER_WORKER, "10");
ComputeGraph taskGraph = computeGraphBuilder.build();
return taskGraph;
}
use of edu.iu.dsc.tws.api.compute.graph.ComputeGraph in project twister2 by DSC-SPIDAL.
the class TaskSchedulerTest method testUniqueSchedules2.
@Test
public void testUniqueSchedules2() {
int parallel = 2;
ComputeGraph graph = createBatchGraph(parallel);
TaskScheduler scheduler = new TaskScheduler();
Config config = getConfig();
scheduler.initialize(config);
WorkerPlan workerPlan = createWorkPlan(parallel);
if (graph.getOperationMode().equals("BATCH")) {
Assert.assertEquals(scheduler.getClass(), TaskSchedulerContext.batchTaskSchedulingClass(config));
}
TaskSchedulePlan plan1 = scheduler.schedule(graph, workerPlan);
Assert.assertNotNull(plan1);
}
use of edu.iu.dsc.tws.api.compute.graph.ComputeGraph in project twister2 by DSC-SPIDAL.
the class TaskSchedulerTest method testUniqueSchedules1.
@Test
public void testUniqueSchedules1() {
int parallel = 2;
ComputeGraph graph = createStreamingGraph(parallel);
TaskScheduler scheduler = new TaskScheduler();
Config config = getConfig();
scheduler.initialize(config);
WorkerPlan workerPlan = createWorkPlan(parallel);
if (graph.getOperationMode().equals("STREAMING")) {
Assert.assertEquals(scheduler.getClass(), TaskSchedulerContext.streamingTaskSchedulingClass(config));
}
TaskSchedulePlan plan1 = scheduler.schedule(graph, workerPlan);
Assert.assertNotNull(plan1);
}
Aggregations