use of edu.iu.dsc.tws.tsched.spi.taskschedule.TaskSchedulePlan in project twister2 by DSC-SPIDAL.
the class TaskScheduling method init.
@Override
public void init(edu.iu.dsc.tws.common.config.Config config, int id, ResourcePlan resourcePlan) {
taskExecutor = new TaskExecutorFixedThread();
this.status = Status.INIT;
// TaskPlan taskPlan = Utils.createTaskPlan(config, resourcePlan);
// TWSNetwork network = new TWSNetwork(config, taskPlan);
// TWSCommunication channel = network.getDataFlowTWSCommunication();
Set<Integer> sources = new HashSet<>();
sources.add(0);
// schedule();
try {
Job job = new Job();
job.setJobId(1);
job.setTaskLength(4);
job.setJob(job);
RoundRobinTaskScheduling roundRobinTaskScheduling = new RoundRobinTaskScheduling();
roundRobinTaskScheduling.initialize(job);
TaskSchedulePlan taskSchedulePlan = roundRobinTaskScheduling.tschedule();
System.out.println("Task schedule plan details:" + taskSchedulePlan);
} catch (Exception ee) {
ee.printStackTrace();
}
}
use of edu.iu.dsc.tws.tsched.spi.taskschedule.TaskSchedulePlan in project twister2 by DSC-SPIDAL.
the class TaskScheduling method schedule.
public void schedule() {
System.out.println("I am inside init method");
Job job = new Job();
job.setJob(job);
Task[] taskList = new Task[4];
RoundRobinTaskScheduling roundRobinTaskScheduling = new RoundRobinTaskScheduling();
// Config config = null;
// roundRobinTaskScheduling.initialize(config, job);
roundRobinTaskScheduling.initialize(job);
TaskSchedulePlan taskSchedulePlan = roundRobinTaskScheduling.tschedule();
}
use of edu.iu.dsc.tws.tsched.spi.taskschedule.TaskSchedulePlan in project twister2 by DSC-SPIDAL.
the class TaskSchedulePlanBuilder method getContainers.
private Map<Integer, Container> getContainers(TaskSchedulePlan previoustaskscheduleplan, int requestedcontainerpadding, HashMap<String, TreeSet<Integer>> taskindexes, TreeSet<Integer> taskids) {
if (previoustaskscheduleplan != null) {
LOG.info("Previous Task Schedule Plan is:" + previoustaskscheduleplan);
}
Map<Integer, Container> containerMap = new HashMap<>();
/*ResourceContainer resource = null;
try {
ResourceContainer resource = previoustaskscheduleplan.getMaxContainerResources ();
} catch (NullPointerException ne){
ne.printStackTrace ();
}*/
// for testing
Resource resource = new Resource(2.0, 5.0, 5.0);
LOG.info("ResourceContainer inside the container:" + resource);
for (TaskSchedulePlan.ContainerPlan currentContainerPlan : previoustaskscheduleplan.getContainers()) {
Container container = new Container(currentContainerPlan.getContainerId(), resource, requestedcontainerpadding);
for (TaskSchedulePlan.TaskInstancePlan taskInstancePlan : currentContainerPlan.getTaskInstances()) {
addToContainer(container, taskInstancePlan, taskindexes, taskids);
}
containerMap.put(currentContainerPlan.getContainerId(), container);
}
if (!containerMap.isEmpty()) {
LOG.info("ResourceContainer values are:" + containerMap);
} else {
LOG.info("container values are empty");
}
return containerMap;
}
use of edu.iu.dsc.tws.tsched.spi.taskschedule.TaskSchedulePlan in project twister2 by DSC-SPIDAL.
the class RRTaskScheduling method tschedule.
/**
* This method invokes the Round Robin Scheduling Method and fetch the container instance allocation map.
* Using the map value it calculates the required ram, disk, and cpu percentage for
* each container and instances in each container and generates the task schedule plan
* for those instances and the containers.
*/
@Override
public TaskSchedulePlan tschedule() {
Map<Integer, List<InstanceId>> roundRobinContainerInstanceMap = RoundRobinScheduling();
Set<TaskSchedulePlan.ContainerPlan> containerPlans = new HashSet<>();
double containerCPUValue = getContainerCPUValue(roundRobinContainerInstanceMap);
double containerRAMValue = getContainerRamValue(roundRobinContainerInstanceMap);
double containerDiskValue = getContainerDiskValue(roundRobinContainerInstanceMap);
for (Integer containerId : roundRobinContainerInstanceMap.keySet()) {
List<InstanceId> taskInstanceIds = roundRobinContainerInstanceMap.get(containerId);
Map<InstanceId, TaskSchedulePlan.TaskInstancePlan> taskInstancePlanMap = new HashMap<>();
for (InstanceId id : taskInstanceIds) {
double instanceCPUValue = instanceCPU;
double instanceRAMValue = instanceRAM;
double instanceDiskValue = instanceDisk;
Resource resource = new Resource(instanceRAM, instanceDisk, instanceCPU);
taskInstancePlanMap.put(id, new TaskSchedulePlan.TaskInstancePlan("mpitask", 1, 1, resource));
}
Resource resource = new Resource(containerRAMValue, containerDiskValue, containerCPUValue);
TaskSchedulePlan.ContainerPlan taskContainerPlan = new TaskSchedulePlan.ContainerPlan(containerId, new HashSet<>(taskInstancePlanMap.values()), resource);
containerPlans.add(taskContainerPlan);
}
return new TaskSchedulePlan(jobObject.getJobId(), containerPlans);
}
use of edu.iu.dsc.tws.tsched.spi.taskschedule.TaskSchedulePlan in project twister2 by DSC-SPIDAL.
the class RoundRobinTaskScheduling method tschedule.
@Override
public TaskSchedulePlan tschedule() {
Set<TaskSchedulePlan.ContainerPlan> containerPlans = new HashSet<>();
Map<Integer, List<InstanceId>> roundRobinContainerInstanceMap = RoundRobinScheduling.RoundRobinSchedulingAlgorithm(job);
// commented the bottom on March 23rd 2018
/*InstanceMapCalculation instanceMapCalculation = new
InstanceMapCalculation (instanceRAM, instanceDisk, instanceCPU);*/
InstanceMapCalculation instanceMapCalculation = new InstanceMapCalculation(instanceRAM, instanceCPU, instanceDisk);
/*Map<Integer, Map<InstanceId, Double>> instancesRamMap =
instanceMapCalculation.getInstancesRamMapInContainer(roundRobinContainerInstanceMap);
Map<Integer, Map<InstanceId, Double>> instancesDiskMap =
instanceMapCalculation.getInstancesDiskMapInContainer(roundRobinContainerInstanceMap);
Map<Integer, Map<InstanceId, Double>> instancesCPUMap =
instanceMapCalculation.getInstancesCPUMapInContainer(roundRobinContainerInstanceMap);*/
Map<Integer, Map<InstanceId, Double>> instancesRamMap = instanceMapCalculation.getInstancesRamMapInContainer(roundRobinContainerInstanceMap, job);
Map<Integer, Map<InstanceId, Double>> instancesDiskMap = instanceMapCalculation.getInstancesDiskMapInContainer(roundRobinContainerInstanceMap, job);
Map<Integer, Map<InstanceId, Double>> instancesCPUMap = instanceMapCalculation.getInstancesCPUMapInContainer(roundRobinContainerInstanceMap, job);
LOG.info("Round Robin Container Instance Map:" + roundRobinContainerInstanceMap + "\n");
for (int containerId : roundRobinContainerInstanceMap.keySet()) {
List<InstanceId> taskInstanceIds = roundRobinContainerInstanceMap.get(containerId);
Map<InstanceId, TaskSchedulePlan.TaskInstancePlan> taskInstancePlanMap = new HashMap<>();
for (InstanceId id : taskInstanceIds) {
// double instanceDiskValue = instanceDisk;
// double instanceCPUValue = instanceCPU;
double instanceRAMValue = instancesRamMap.get(containerId).get(id);
double instanceDiskValue = instancesDiskMap.get(containerId).get(id);
double instanceCPUValue = instancesCPUMap.get(containerId).get(id);
Resource resource = new Resource(instanceRAMValue, instanceDiskValue, instanceCPUValue);
taskInstancePlanMap.put(id, new TaskSchedulePlan.TaskInstancePlan("mpitask", 1, 1, resource));
}
Resource resource = new Resource(containerRAMValue, containerDiskValue, containerCPUValue);
TaskSchedulePlan.ContainerPlan taskContainerPlan = new TaskSchedulePlan.ContainerPlan(containerId, new HashSet<>(taskInstancePlanMap.values()), resource);
containerPlans.add(taskContainerPlan);
// TaskSchedulePlan.ContainerPlan taskContainerPlan = new TaskSchedulePlan.
// ContainerPlan(containerId, resource);
// containerPlans.add(taskContainerPlan);
// LOG.info("Job Id Is:" + job.getJobId());
}
return new TaskSchedulePlan(job.getJobId(), containerPlans);
}
Aggregations