use of edu.iu.dsc.tws.tsched.spi.taskschedule.InstanceMapCalculation 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