Search in sources :

Example 1 with Resource

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

Example 2 with Resource

use of edu.iu.dsc.tws.tsched.spi.taskschedule.Resource in project twister2 by DSC-SPIDAL.

the class FirstFitTaskScheduling method initialize.

public void initialize(Config config, Job job) {
    this.configValue = config;
    this.jobObject = job;
    this.defaultResourceValue = new Resource(Context.instanceRam(configValue), Context.instanceDisk(configValue), Context.instanceCPU(configValue));
    this.paddingPercentage = JobAttributes.JOB_CONTAINER_PADDING_PERCENTAGE;
    instanceRAM = this.defaultResourceValue.getRam();
    instanceDisk = this.defaultResourceValue.getDisk();
    instanceCPU = this.defaultResourceValue.getCpu();
    // This value will be calculated by adding the container percentage value....
    this.maximumContainerResourceValue = new Resource(JobAttributes.JOB_CONTAINER_MAX_RAM_VALUE, JobAttributes.JOB_CONTAINER_MAX_DISK_VALUE, JobAttributes.JOB_CONTAINER_MAX_CPU_VALUE);
    System.out.println("instance default values:" + instanceRAM + "\t" + instanceDisk + "\t" + instanceCPU);
}
Also used : Resource(edu.iu.dsc.tws.tsched.spi.taskschedule.Resource)

Example 3 with Resource

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

Example 4 with Resource

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

Example 5 with Resource

use of edu.iu.dsc.tws.tsched.spi.taskschedule.Resource in project twister2 by DSC-SPIDAL.

the class TaskSchedulePlanBuilder method buildContainerPlans.

private Set<TaskSchedulePlan.ContainerPlan> buildContainerPlans(Map<Integer, Container> containerValue, Map<String, Double> taskrammap, Map<String, Double> taskdiskmap, Map<String, Double> taskcpumap, Resource instdefaultresourcevalue, int containerPadding) {
    Set<TaskSchedulePlan.ContainerPlan> containerPlans = new LinkedHashSet<>();
    try {
        for (Integer containerId : containerValue.keySet()) {
            Container container = containerValue.get(containerId);
            if (container.getTaskInstances().size() == 0) {
                continue;
            }
            Double containerRAMValue = 0.0;
            Double containerDiskValue = 0.0;
            Double containerCPUValue = 0.0;
            Set<TaskSchedulePlan.TaskInstancePlan> taskInstancePlans = new HashSet<>();
            for (TaskSchedulePlan.TaskInstancePlan taskInstancePlan : container.getTaskInstances()) {
                TaskInstanceId instanceId = new TaskInstanceId(taskInstancePlan.getTaskName(), taskInstancePlan.getTaskId(), taskInstancePlan.getTaskIndex());
                Double instanceRAMValue;
                Double instanceDiskValue;
                Double instanceCPUValue;
                if (taskrammap.containsKey(instanceId.getTaskName())) {
                    instanceRAMValue = taskrammap.get(instanceId.getTaskName());
                } else {
                    instanceRAMValue = instdefaultresourcevalue.getRam();
                }
                containerRAMValue += instanceRAMValue;
                LOG.info("ResourceContainer Ram Value:" + containerRAMValue);
                if (taskdiskmap.containsKey(instanceId.getTaskName())) {
                    instanceDiskValue = instdefaultresourcevalue.getDisk();
                } else {
                    instanceDiskValue = instdefaultresourcevalue.getDisk();
                }
                containerDiskValue += instanceDiskValue;
                LOG.info("ResourceContainer Disk Value:" + containerDiskValue);
                if (taskcpumap.containsKey(instanceId.getTaskName())) {
                    instanceCPUValue = instdefaultresourcevalue.getCpu();
                } else {
                    instanceCPUValue = instdefaultresourcevalue.getCpu();
                }
                containerCPUValue += instanceCPUValue;
                Resource resource = new Resource(instanceRAMValue, instanceDiskValue, instanceCPUValue);
                taskInstancePlans.add(new TaskSchedulePlan.TaskInstancePlan(instanceId.getTaskName(), instanceId.getTaskId(), instanceId.getTaskIndex(), resource));
            /*taskInstancePlans.add(new TaskSchedulePlan.TaskInstancePlan (instanceId,
                new ResourceContainer(instanceRAMValue, instanceDiskValue, instanceCPUValue)));*/
            }
            LOG.info("ResourceContainer CPU Value:" + containerCPUValue);
            /* containerCpu += (paddingPercentage * containerCpu) / 100;
          containerRam = containerRam.increaseBy(paddingPercentage);
          containerDiskInBytes = containerDiskInBytes.increaseBy(paddingPercentage); */
            Resource resource = new Resource(containerRAMValue, containerDiskValue, containerCPUValue);
            TaskSchedulePlan.ContainerPlan containerPlan = new TaskSchedulePlan.ContainerPlan(containerId, taskInstancePlans, resource);
            containerPlans.add(containerPlan);
        }
    } catch (NullPointerException ne) {
        ne.printStackTrace();
    }
    return containerPlans;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Resource(edu.iu.dsc.tws.tsched.spi.taskschedule.Resource) TaskInstanceId(edu.iu.dsc.tws.tsched.spi.taskschedule.TaskInstanceId) TaskSchedulePlan(edu.iu.dsc.tws.tsched.spi.taskschedule.TaskSchedulePlan) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

Resource (edu.iu.dsc.tws.tsched.spi.taskschedule.Resource)5 TaskSchedulePlan (edu.iu.dsc.tws.tsched.spi.taskschedule.TaskSchedulePlan)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 InstanceId (edu.iu.dsc.tws.tsched.spi.taskschedule.InstanceId)2 List (java.util.List)2 InstanceMapCalculation (edu.iu.dsc.tws.tsched.spi.taskschedule.InstanceMapCalculation)1 TaskInstanceId (edu.iu.dsc.tws.tsched.spi.taskschedule.TaskInstanceId)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1