Search in sources :

Example 21 with ComputeGraph

use of edu.iu.dsc.tws.api.compute.graph.ComputeGraph in project twister2 by DSC-SPIDAL.

the class DataLocalityTaskSchedulerTest method testUniqueSchedules3.

@Test
public void testUniqueSchedules3() {
    int parallel = 10;
    int workers = 3;
    ComputeGraph graph = createGraphWithComputeTaskAndConstraints(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)));
    }
}
Also used : ComputeGraph(edu.iu.dsc.tws.api.compute.graph.ComputeGraph) Config(edu.iu.dsc.tws.api.config.Config) WorkerPlan(edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan) TaskSchedulePlan(edu.iu.dsc.tws.api.compute.schedule.elements.TaskSchedulePlan) WorkerSchedulePlan(edu.iu.dsc.tws.api.compute.schedule.elements.WorkerSchedulePlan) TaskInstancePlan(edu.iu.dsc.tws.api.compute.schedule.elements.TaskInstancePlan) DataLocalityStreamingTaskScheduler(edu.iu.dsc.tws.tsched.streaming.datalocalityaware.DataLocalityStreamingTaskScheduler) Map(java.util.Map) Test(org.junit.Test) TaskSchedulerClassTest(edu.iu.dsc.tws.tsched.utils.TaskSchedulerClassTest)

Example 22 with ComputeGraph

use of edu.iu.dsc.tws.api.compute.graph.ComputeGraph in project twister2 by DSC-SPIDAL.

the class DataLocalityTaskSchedulerTest method createGraphWithConstraints.

private ComputeGraph createGraphWithConstraints(int parallel) {
    TaskSchedulerClassTest.TestSource testSource = new TaskSchedulerClassTest.TestSource();
    TaskSchedulerClassTest.TestSink testSink = new TaskSchedulerClassTest.TestSink();
    ComputeGraphBuilder computeGraphBuilder = ComputeGraphBuilder.newBuilder(Config.newBuilder().build());
    computeGraphBuilder.addSource("source", testSource, parallel);
    ComputeConnection computeConnection = computeGraphBuilder.addCompute("sink", testSink, parallel);
    computeConnection.direct("source").viaEdge("direct-edge").withDataType(MessageTypes.OBJECT);
    computeGraphBuilder.setMode(OperationMode.STREAMING);
    computeGraphBuilder.addGraphConstraints(Context.TWISTER2_MAX_TASK_INSTANCES_PER_WORKER, "10");
    ComputeGraph taskGraph = computeGraphBuilder.build();
    return taskGraph;
}
Also used : TaskSchedulerClassTest(edu.iu.dsc.tws.tsched.utils.TaskSchedulerClassTest) ComputeGraph(edu.iu.dsc.tws.api.compute.graph.ComputeGraph) ComputeGraphBuilder(edu.iu.dsc.tws.task.impl.ComputeGraphBuilder) ComputeConnection(edu.iu.dsc.tws.task.impl.ComputeConnection)

Example 23 with ComputeGraph

use of edu.iu.dsc.tws.api.compute.graph.ComputeGraph in project twister2 by DSC-SPIDAL.

the class DataLocalityTaskSchedulerTest method createGraph.

private ComputeGraph createGraph(int parallel) {
    TaskSchedulerClassTest.TestSource testSource = new TaskSchedulerClassTest.TestSource();
    TaskSchedulerClassTest.TestSink testSink = new TaskSchedulerClassTest.TestSink();
    ComputeGraphBuilder computeGraphBuilder = ComputeGraphBuilder.newBuilder(Config.newBuilder().build());
    computeGraphBuilder.addSource("source", testSource, parallel);
    ComputeConnection computeConnection = computeGraphBuilder.addCompute("sink", testSink, parallel);
    computeConnection.direct("source").viaEdge("direct-edge").withDataType(MessageTypes.OBJECT);
    computeGraphBuilder.setMode(OperationMode.STREAMING);
    ComputeGraph taskGraph = computeGraphBuilder.build();
    return taskGraph;
}
Also used : TaskSchedulerClassTest(edu.iu.dsc.tws.tsched.utils.TaskSchedulerClassTest) ComputeGraph(edu.iu.dsc.tws.api.compute.graph.ComputeGraph) ComputeGraphBuilder(edu.iu.dsc.tws.task.impl.ComputeGraphBuilder) ComputeConnection(edu.iu.dsc.tws.task.impl.ComputeConnection)

Example 24 with ComputeGraph

use of edu.iu.dsc.tws.api.compute.graph.ComputeGraph in project twister2 by DSC-SPIDAL.

the class BatchTaskSchedulerTest method testUniqueSchedules6.

@Test
public void testUniqueSchedules6() {
    int parallel = 200;
    int workers = 400;
    ComputeGraph[] graph = new ComputeGraph[3];
    Arrays.setAll(graph, i -> createGraphWithDifferentParallelism(parallel, "graph" + i));
    BatchTaskScheduler scheduler = new BatchTaskScheduler();
    scheduler.initialize(Config.newBuilder().build());
    WorkerPlan workerPlan = createWorkPlan(workers);
    Map<String, TaskSchedulePlan> plan1 = scheduler.schedule(workerPlan, graph[0], graph[1]);
    for (Map.Entry<String, TaskSchedulePlan> taskSchedulePlanEntry : plan1.entrySet()) {
        TaskSchedulePlan plan2 = taskSchedulePlanEntry.getValue();
        Map<Integer, WorkerSchedulePlan> containersMap = plan2.getContainersMap();
        int index = 0;
        for (Map.Entry<Integer, WorkerSchedulePlan> entry : containersMap.entrySet()) {
            WorkerSchedulePlan workerSchedulePlan = entry.getValue();
            Set<TaskInstancePlan> containerPlanTaskInstances = workerSchedulePlan.getTaskInstances();
            index++;
            if (index <= parallel) {
                Assert.assertEquals(containerPlanTaskInstances.size(), workers / parallel);
            } else {
                Assert.assertEquals(containerPlanTaskInstances.size(), 0);
            }
        }
    }
}
Also used : ComputeGraph(edu.iu.dsc.tws.api.compute.graph.ComputeGraph) WorkerPlan(edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan) TaskSchedulePlan(edu.iu.dsc.tws.api.compute.schedule.elements.TaskSchedulePlan) WorkerSchedulePlan(edu.iu.dsc.tws.api.compute.schedule.elements.WorkerSchedulePlan) TaskInstancePlan(edu.iu.dsc.tws.api.compute.schedule.elements.TaskInstancePlan) Map(java.util.Map) Test(org.junit.Test) TaskSchedulerClassTest(edu.iu.dsc.tws.tsched.utils.TaskSchedulerClassTest)

Example 25 with ComputeGraph

use of edu.iu.dsc.tws.api.compute.graph.ComputeGraph in project twister2 by DSC-SPIDAL.

the class BatchTaskSchedulerTest method createGraph.

private ComputeGraph createGraph(int parallel, String graphName) {
    TaskSchedulerClassTest.TestSource testSource = new TaskSchedulerClassTest.TestSource();
    TaskSchedulerClassTest.TestSink testSink = new TaskSchedulerClassTest.TestSink();
    ComputeGraphBuilder builder = ComputeGraphBuilder.newBuilder(Config.newBuilder().build());
    builder.addSource("source", testSource, parallel);
    ComputeConnection sinkConnection = builder.addCompute("sink", testSink, parallel);
    sinkConnection.direct("source").viaEdge(Context.TWISTER2_DIRECT_EDGE).withDataType(MessageTypes.OBJECT);
    builder.setMode(OperationMode.BATCH);
    ComputeGraph graph = builder.build();
    graph.setGraphName(graphName);
    return graph;
}
Also used : TaskSchedulerClassTest(edu.iu.dsc.tws.tsched.utils.TaskSchedulerClassTest) ComputeGraph(edu.iu.dsc.tws.api.compute.graph.ComputeGraph) ComputeGraphBuilder(edu.iu.dsc.tws.task.impl.ComputeGraphBuilder) ComputeConnection(edu.iu.dsc.tws.task.impl.ComputeConnection)

Aggregations

ComputeGraph (edu.iu.dsc.tws.api.compute.graph.ComputeGraph)89 ComputeConnection (edu.iu.dsc.tws.task.impl.ComputeConnection)40 ComputeGraphBuilder (edu.iu.dsc.tws.task.impl.ComputeGraphBuilder)39 TaskSchedulerClassTest (edu.iu.dsc.tws.tsched.utils.TaskSchedulerClassTest)38 ExecutionPlan (edu.iu.dsc.tws.api.compute.executor.ExecutionPlan)32 TaskSchedulePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskSchedulePlan)26 WorkerPlan (edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan)25 Test (org.junit.Test)25 WorkerSchedulePlan (edu.iu.dsc.tws.api.compute.schedule.elements.WorkerSchedulePlan)22 Map (java.util.Map)22 TaskInstancePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskInstancePlan)20 Config (edu.iu.dsc.tws.api.config.Config)18 DataObject (edu.iu.dsc.tws.api.dataset.DataObject)9 ComputeEnvironment (edu.iu.dsc.tws.task.ComputeEnvironment)9 DataFlowGraph (edu.iu.dsc.tws.task.cdfw.DataFlowGraph)8 IExecutor (edu.iu.dsc.tws.api.compute.executor.IExecutor)7 JobConfig (edu.iu.dsc.tws.api.JobConfig)5 DataObjectSource (edu.iu.dsc.tws.task.dataobjects.DataObjectSource)5 HashMap (java.util.HashMap)5 Path (edu.iu.dsc.tws.api.data.Path)4