use of edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan in project twister2 by DSC-SPIDAL.
the class TaskExecutor method plan.
/**
* Create an execution plan from the given graph
*
* @param graph task graph
* @return the data set
*/
public ExecutionPlan plan(ComputeGraph graph) {
TaskScheduler taskScheduler = new TaskScheduler();
taskScheduler.initialize(config);
WorkerPlan workerPlan = createWorkerPlan();
TaskSchedulePlan taskSchedulePlan = taskScheduler.schedule(graph, workerPlan);
ExecutionPlanBuilder executionPlanBuilder = new ExecutionPlanBuilder(workerID, workerInfoList, communicator, this.checkpointingClient);
return executionPlanBuilder.build(config, graph, taskSchedulePlan);
}
use of edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan in project twister2 by DSC-SPIDAL.
the class CSVInputFormatTest 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;
}
use of edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan in project twister2 by DSC-SPIDAL.
the class RoundRobinTaskSchedulerTest method testUniqueSchedules4.
@Test
public void testUniqueSchedules4() {
int parallel = 16;
int workers = 2;
ComputeGraph graph = createGraphWithComputeTaskAndConstraints(parallel);
RoundRobinTaskScheduler scheduler = new RoundRobinTaskScheduler();
scheduler.initialize(Config.newBuilder().build());
WorkerPlan workerPlan = createWorkPlan(workers);
TaskSchedulePlan plan1 = scheduler.schedule(graph, workerPlan);
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.schedule.elements.WorkerPlan in project twister2 by DSC-SPIDAL.
the class TaskScheduler method generateTaskSchedulePlan.
private TaskSchedulePlan generateTaskSchedulePlan(String className) {
Class<?> taskSchedulerClass;
Method method;
TaskSchedulePlan taskSchedulePlan;
try {
taskSchedulerClass = getClass().getClassLoader().loadClass(className);
Object newInstance = taskSchedulerClass.newInstance();
method = taskSchedulerClass.getMethod("initialize", new Class<?>[] { Config.class });
method.invoke(newInstance, config);
method = taskSchedulerClass.getMethod("schedule", new Class<?>[] { ComputeGraph.class, WorkerPlan.class });
taskSchedulePlan = (TaskSchedulePlan) method.invoke(newInstance, computeGraph, workerPlan);
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException | InstantiationException | ClassNotFoundException | TaskSchedulerException e) {
throw new Twister2RuntimeException(e);
}
if (taskSchedulePlan != null) {
Map<Integer, WorkerSchedulePlan> containersMap = taskSchedulePlan.getContainersMap();
for (Map.Entry<Integer, WorkerSchedulePlan> entry : containersMap.entrySet()) {
Integer integer = entry.getKey();
WorkerSchedulePlan workerSchedulePlan = entry.getValue();
Set<TaskInstancePlan> containerPlanTaskInstances = workerSchedulePlan.getTaskInstances();
LOG.fine("Task Details for Container Id:" + integer);
for (TaskInstancePlan ip : containerPlanTaskInstances) {
LOG.fine("Task Id:" + ip.getTaskId() + "\tTask Index" + ip.getTaskIndex() + "\tTask Name:" + ip.getTaskName());
}
}
}
return taskSchedulePlan;
}
use of edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan in project twister2 by DSC-SPIDAL.
the class BatchTaskSchedulerTest method testUniqueSchedules1.
@Test
public void testUniqueSchedules1() {
int parallel = 16;
int workers = 2;
ComputeGraph graph = createGraph(parallel, "graph");
BatchTaskScheduler scheduler = new BatchTaskScheduler();
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());
}
}
}
Aggregations