Search in sources :

Example 31 with WorkerPlan

use of edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan 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 32 with WorkerPlan

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

the class DataLocalityBatchTaskSchedulerTest method createWorkPlan.

private WorkerPlan createWorkPlan(int workers) {
    WorkerPlan plan = new WorkerPlan();
    for (int i = 0; i < workers; i++) {
        Worker w = new Worker(i);
        w.addProperty("bandwidth", 1000.0);
        w.addProperty("latency", 0.1);
        plan.addWorker(w);
    }
    return plan;
}
Also used : Worker(edu.iu.dsc.tws.api.compute.schedule.elements.Worker) WorkerPlan(edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan)

Example 33 with WorkerPlan

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

the class DataLocalityTaskSchedulerTest method createWorkPlan.

private WorkerPlan createWorkPlan(int workers) {
    WorkerPlan plan = new WorkerPlan();
    for (int i = 0; i < workers; i++) {
        Worker w = new Worker(i);
        w.addProperty("bandwidth", 1000.0);
        w.addProperty("latency", 0.1);
        plan.addWorker(w);
    }
    return plan;
}
Also used : Worker(edu.iu.dsc.tws.api.compute.schedule.elements.Worker) WorkerPlan(edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan)

Example 34 with WorkerPlan

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

Example 35 with WorkerPlan

use of edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan 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);
}
Also used : TaskSchedulePlan(edu.iu.dsc.tws.api.compute.schedule.elements.TaskSchedulePlan) 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) TaskSchedulerClassTest(edu.iu.dsc.tws.tsched.utils.TaskSchedulerClassTest) Test(org.junit.Test)

Aggregations

WorkerPlan (edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan)36 TaskSchedulePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskSchedulePlan)28 ComputeGraph (edu.iu.dsc.tws.api.compute.graph.ComputeGraph)24 TaskSchedulerClassTest (edu.iu.dsc.tws.tsched.utils.TaskSchedulerClassTest)23 Test (org.junit.Test)23 WorkerSchedulePlan (edu.iu.dsc.tws.api.compute.schedule.elements.WorkerSchedulePlan)20 TaskInstancePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskInstancePlan)18 Map (java.util.Map)18 Config (edu.iu.dsc.tws.api.config.Config)11 Worker (edu.iu.dsc.tws.api.compute.schedule.elements.Worker)8 DataLocalityBatchTaskScheduler (edu.iu.dsc.tws.tsched.batch.datalocalityaware.DataLocalityBatchTaskScheduler)4 ExecutionPlanBuilder (edu.iu.dsc.tws.executor.core.ExecutionPlanBuilder)3 DataLocalityStreamingTaskScheduler (edu.iu.dsc.tws.tsched.streaming.datalocalityaware.DataLocalityStreamingTaskScheduler)3 Communicator (edu.iu.dsc.tws.api.comms.Communicator)2 TWSChannel (edu.iu.dsc.tws.api.comms.channel.TWSChannel)2 TaskSchedulerException (edu.iu.dsc.tws.api.compute.exceptions.TaskSchedulerException)2 ExecutionPlan (edu.iu.dsc.tws.api.compute.executor.ExecutionPlan)2 Path (edu.iu.dsc.tws.api.data.Path)2 TimeoutException (edu.iu.dsc.tws.api.exceptions.TimeoutException)2 Twister2RuntimeException (edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)2