Search in sources :

Example 26 with WorkerSchedulePlan

use of edu.iu.dsc.tws.api.compute.schedule.elements.WorkerSchedulePlan in project twister2 by DSC-SPIDAL.

the class RoundRobinBatchTaskSchedulerTest method testUniqueSchedules1.

@Test
public void testUniqueSchedules1() {
    int parallel = 16;
    int workers = 2;
    ComputeGraph graph = createGraph(parallel);
    RoundRobinBatchTaskScheduler scheduler = new RoundRobinBatchTaskScheduler();
    scheduler.initialize(Config.newBuilder().build());
    WorkerPlan workerPlan = createWorkPlan(workers);
    for (int i = 0; i < 1; i++) {
        TaskSchedulePlan plan1 = scheduler.schedule(graph, workerPlan);
        TaskSchedulePlan plan2 = scheduler.schedule(graph, workerPlan);
        Assert.assertEquals(plan1.getContainers().size(), plan2.getContainers().size());
        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(), graph.vertex("source").getParallelism());
        }
    }
}
Also used : 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) ComputeGraph(edu.iu.dsc.tws.api.compute.graph.ComputeGraph) Map(java.util.Map) WorkerPlan(edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan) Test(org.junit.Test) TaskSchedulerClassTest(edu.iu.dsc.tws.tsched.utils.TaskSchedulerClassTest)

Example 27 with WorkerSchedulePlan

use of edu.iu.dsc.tws.api.compute.schedule.elements.WorkerSchedulePlan in project twister2 by DSC-SPIDAL.

the class DataLocalityBatchTaskSchedulerTest method testUniqueSchedules2.

@Test
public void testUniqueSchedules2() {
    int parallel = 4;
    int workers = 2;
    ComputeGraph graph = createGraphWithConstraints(parallel);
    DataLocalityBatchTaskScheduler scheduler = new DataLocalityBatchTaskScheduler();
    Config config = getConfig();
    scheduler.initialize(config, 1);
    generateData(config);
    DataGenerator dataGenerator = new DataGenerator(config);
    dataGenerator.generate(new Path(String.valueOf(config.get(DataObjectConstants.DINPUT_DIRECTORY))), 1000, 2);
    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();
        LOG.info("container plan instances and parallel:" + containerPlanTaskInstances.size() + "\t" + parallel);
        Assert.assertEquals(containerPlanTaskInstances.size(), parallel);
    }
}
Also used : Path(edu.iu.dsc.tws.api.data.Path) 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) DataGenerator(edu.iu.dsc.tws.tsched.utils.DataGenerator) DataLocalityBatchTaskScheduler(edu.iu.dsc.tws.tsched.batch.datalocalityaware.DataLocalityBatchTaskScheduler) Map(java.util.Map) Test(org.junit.Test) TaskSchedulerClassTest(edu.iu.dsc.tws.tsched.utils.TaskSchedulerClassTest)

Example 28 with WorkerSchedulePlan

use of edu.iu.dsc.tws.api.compute.schedule.elements.WorkerSchedulePlan in project twister2 by DSC-SPIDAL.

the class DataLocalityBatchTaskSchedulerTest method testUniqueSchedules4.

@Test
public void testUniqueSchedules4() {
    int parallel = 4;
    int workers = 2;
    ComputeGraph graph = createGraphWithMultipleComputeTaskAndConstraints(parallel);
    DataLocalityBatchTaskScheduler scheduler = new DataLocalityBatchTaskScheduler();
    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(), workers * graph.getTaskVertexSet().size());
    }
}
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) DataLocalityBatchTaskScheduler(edu.iu.dsc.tws.tsched.batch.datalocalityaware.DataLocalityBatchTaskScheduler) Map(java.util.Map) Test(org.junit.Test) TaskSchedulerClassTest(edu.iu.dsc.tws.tsched.utils.TaskSchedulerClassTest)

Example 29 with WorkerSchedulePlan

use of edu.iu.dsc.tws.api.compute.schedule.elements.WorkerSchedulePlan in project twister2 by DSC-SPIDAL.

the class DataLocalityBatchTaskSchedulerTest method testUniqueSchedules3.

@Test
public void testUniqueSchedules3() {
    int parallel = 4;
    int workers = 2;
    ComputeGraph graph = createGraphWithComputeTaskAndConstraints(parallel);
    DataLocalityBatchTaskScheduler scheduler = new DataLocalityBatchTaskScheduler();
    Config config = getConfig();
    scheduler.initialize(config, 1);
    generateData(config);
    DataGenerator dataGenerator = new DataGenerator(config);
    dataGenerator.generate(new Path(String.valueOf(config.get(DataObjectConstants.DINPUT_DIRECTORY))), 1000, 2);
    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();
        LOG.info("container plan instances and parallel:" + containerPlanTaskInstances.size() + "\t" + workers * graph.getTaskVertexSet().size());
        Assert.assertEquals(containerPlanTaskInstances.size(), workers * graph.getTaskVertexSet().size());
    }
}
Also used : Path(edu.iu.dsc.tws.api.data.Path) 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) DataGenerator(edu.iu.dsc.tws.tsched.utils.DataGenerator) DataLocalityBatchTaskScheduler(edu.iu.dsc.tws.tsched.batch.datalocalityaware.DataLocalityBatchTaskScheduler) Map(java.util.Map) Test(org.junit.Test) TaskSchedulerClassTest(edu.iu.dsc.tws.tsched.utils.TaskSchedulerClassTest)

Example 30 with WorkerSchedulePlan

use of edu.iu.dsc.tws.api.compute.schedule.elements.WorkerSchedulePlan 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)));
    }
}
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)

Aggregations

WorkerSchedulePlan (edu.iu.dsc.tws.api.compute.schedule.elements.WorkerSchedulePlan)31 TaskInstancePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskInstancePlan)29 TaskSchedulePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskSchedulePlan)27 Map (java.util.Map)26 ComputeGraph (edu.iu.dsc.tws.api.compute.graph.ComputeGraph)21 WorkerPlan (edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan)20 TaskSchedulerClassTest (edu.iu.dsc.tws.tsched.utils.TaskSchedulerClassTest)19 Test (org.junit.Test)19 HashMap (java.util.HashMap)10 Resource (edu.iu.dsc.tws.api.compute.schedule.elements.Resource)9 Config (edu.iu.dsc.tws.api.config.Config)9 ArrayList (java.util.ArrayList)8 List (java.util.List)8 Vertex (edu.iu.dsc.tws.api.compute.graph.Vertex)7 TaskInstanceId (edu.iu.dsc.tws.api.compute.schedule.elements.TaskInstanceId)7 Worker (edu.iu.dsc.tws.api.compute.schedule.elements.Worker)6 TaskInstanceMapCalculation (edu.iu.dsc.tws.tsched.spi.taskschedule.TaskInstanceMapCalculation)6 HashSet (java.util.HashSet)6 LinkedHashSet (java.util.LinkedHashSet)6 LinkedHashMap (java.util.LinkedHashMap)5