Search in sources :

Example 1 with InstanceMapCalculation

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);
}
Also used : InstanceId(edu.iu.dsc.tws.tsched.spi.taskschedule.InstanceId) HashMap(java.util.HashMap) Resource(edu.iu.dsc.tws.tsched.spi.taskschedule.Resource) InstanceMapCalculation(edu.iu.dsc.tws.tsched.spi.taskschedule.InstanceMapCalculation) TaskSchedulePlan(edu.iu.dsc.tws.tsched.spi.taskschedule.TaskSchedulePlan) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

InstanceId (edu.iu.dsc.tws.tsched.spi.taskschedule.InstanceId)1 InstanceMapCalculation (edu.iu.dsc.tws.tsched.spi.taskschedule.InstanceMapCalculation)1 Resource (edu.iu.dsc.tws.tsched.spi.taskschedule.Resource)1 TaskSchedulePlan (edu.iu.dsc.tws.tsched.spi.taskschedule.TaskSchedulePlan)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1