Search in sources :

Example 1 with RequiredRam

use of edu.iu.dsc.tws.tsched.utils.RequiredRam in project twister2 by DSC-SPIDAL.

the class FirstFitTaskScheduling method assignInstancesToContainers.

/*private static int getLargestContainerSize(Map<Integer, List<InstanceId>> InstancesAllocation) {
        int max = 0;
        for (List<InstanceId> instances : InstancesAllocation.values ()) {
            if (instances.size () > max) {
                max = instances.size ();
            }
        }
        System.out.println("Maximum container value is:\t"+max);
        return max;
  }*/
public void assignInstancesToContainers(TaskSchedulePlanBuilder taskSchedulePlanBuilder, Map<String, Integer> parallelTaskMap) {
    ArrayList<RequiredRam> ramRequirements = getSortedRAMInstances(parallelTaskMap.keySet());
    for (RequiredRam ramRequirement : ramRequirements) {
        String taskName = ramRequirement.getTaskName();
        int numberOfInstances = parallelTaskMap.get(taskName);
        System.out.println("Number of Instances for the task name:" + numberOfInstances + "\t" + taskName);
        for (int j = 0; j < numberOfInstances; j++) {
            FirstFitInstanceAllocation(taskSchedulePlanBuilder, taskName);
            System.out.println("I am inside assign instances to container function:" + taskSchedulePlanBuilder.getTaskDiskMap() + "\t" + taskName);
        }
    }
}
Also used : RequiredRam(edu.iu.dsc.tws.tsched.utils.RequiredRam)

Example 2 with RequiredRam

use of edu.iu.dsc.tws.tsched.utils.RequiredRam in project twister2 by DSC-SPIDAL.

the class FirstFitTaskScheduling method getSortedRAMInstances.

private ArrayList<RequiredRam> getSortedRAMInstances(Set<String> taskNameSet) {
    Job job = new Job();
    job.setJob(job);
    ArrayList<RequiredRam> ramRequirements = new ArrayList<>();
    Map<String, Double> taskRamMap = JobAttributes.getTaskRamMap(job);
    for (String taskName : taskNameSet) {
        if (taskRamMap.containsKey(taskName)) {
            instanceRAM = taskRamMap.get(taskName);
        }
        // RequiredRam requiredRam = new RequiredRam (taskName, instanceRAM);
        // ramRequirements.add (requiredRam);
        ramRequirements.add(new RequiredRam(taskName, instanceRAM));
        System.out.println("Task Name and Required Ram:" + taskName + "\t" + instanceRAM);
    }
    Collections.sort(ramRequirements, Collections.reverseOrder());
    return ramRequirements;
}
Also used : RequiredRam(edu.iu.dsc.tws.tsched.utils.RequiredRam) ArrayList(java.util.ArrayList) Job(edu.iu.dsc.tws.tsched.utils.Job)

Example 3 with RequiredRam

use of edu.iu.dsc.tws.tsched.utils.RequiredRam in project twister2 by DSC-SPIDAL.

the class FirstFitStreamingTaskScheduler method assignInstancesToContainers.

/**
 * This method retrieve the sorted array list of ram requirements map and allocate the task
 * instances available in the map.
 */
private void assignInstancesToContainers(TaskSchedulePlanBuilder taskSchedulePlanBuilder, Map<String, Integer> parallelTaskMap) throws TaskSchedulerException {
    ArrayList<RequiredRam> ramRequirements = getSortedRAMInstances(parallelTaskMap.keySet());
    for (RequiredRam ramRequirement : ramRequirements) {
        String taskName = ramRequirement.getTaskName();
        int numberOfInstances = parallelTaskMap.get(taskName);
        for (int j = 0; j < numberOfInstances; j++) {
            firstFitInstanceAllocation(taskSchedulePlanBuilder, taskName);
        }
    }
}
Also used : RequiredRam(edu.iu.dsc.tws.tsched.utils.RequiredRam)

Example 4 with RequiredRam

use of edu.iu.dsc.tws.tsched.utils.RequiredRam in project twister2 by DSC-SPIDAL.

the class FirstFitStreamingTaskScheduler method getSortedRAMInstances.

/**
 * This method sort the task instances in an increasing order based on the required ram
 * configuration values.
 */
private ArrayList<RequiredRam> getSortedRAMInstances(Set<String> taskNameSet) {
    ArrayList<RequiredRam> ramRequirements = new ArrayList<>();
    TreeSet<Vertex> orderedTaskSet = new TreeSet<>(new VertexComparator());
    orderedTaskSet.addAll(this.taskVertexSet);
    Map<String, Double> taskRamMap = taskAttributes.getTaskRamMap(this.taskVertexSet);
    for (String taskName : taskNameSet) {
        Resource resource = TaskScheduleUtils.getResourceRequirement(taskName, taskRamMap, this.defaultResourceValue, this.maxContainerResourceValue, this.paddingPercentage);
        ramRequirements.add(new RequiredRam(taskName, resource.getRam()));
    }
    ramRequirements.sort(Collections.reverseOrder());
    return ramRequirements;
}
Also used : RequiredRam(edu.iu.dsc.tws.tsched.utils.RequiredRam) Vertex(edu.iu.dsc.tws.api.compute.graph.Vertex) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Resource(edu.iu.dsc.tws.api.compute.schedule.elements.Resource)

Aggregations

RequiredRam (edu.iu.dsc.tws.tsched.utils.RequiredRam)4 ArrayList (java.util.ArrayList)2 Vertex (edu.iu.dsc.tws.api.compute.graph.Vertex)1 Resource (edu.iu.dsc.tws.api.compute.schedule.elements.Resource)1 Job (edu.iu.dsc.tws.tsched.utils.Job)1 TreeSet (java.util.TreeSet)1