Search in sources :

Example 21 with Vertex

use of edu.iu.dsc.tws.api.compute.graph.Vertex 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)

Example 22 with Vertex

use of edu.iu.dsc.tws.api.compute.graph.Vertex in project twister2 by DSC-SPIDAL.

the class TaskAttributes method getTaskDiskMap.

/**
 * This method retrieve the set of task vertices and check if the task vertex has the user
 * specified disk value. If the user doesn't specify the required disk configuration it will
 * assign the default disk value from the task configuration file and store it in the map.
 */
public Map<String, Double> getTaskDiskMap(Set<Vertex> taskVertices) {
    Map<String, Double> taskDiskMap = new LinkedHashMap<>();
    Object disk;
    double requiredDisk;
    for (Vertex task : taskVertices) {
        Config config = task.getConfig();
        if (config.get("Disk") != null) {
            disk = config.get("Disk");
            requiredDisk = (double) ((Integer) disk);
        } else {
            requiredDisk = TaskSchedulerContext.taskInstanceDisk(config);
        }
        taskDiskMap.put(task.getName(), requiredDisk);
    }
    return taskDiskMap;
}
Also used : Vertex(edu.iu.dsc.tws.api.compute.graph.Vertex) Config(edu.iu.dsc.tws.api.config.Config) LinkedHashMap(java.util.LinkedHashMap)

Example 23 with Vertex

use of edu.iu.dsc.tws.api.compute.graph.Vertex in project twister2 by DSC-SPIDAL.

the class TaskAttributes method getParallelTaskMap.

public Map<String, Integer> getParallelTaskMap(Set<Vertex> iTaskSet) {
    Map<String, Integer> parallelTaskMap = new LinkedHashMap<>();
    for (Vertex taskVertex : iTaskSet) {
        Config config = taskVertex.getConfig();
        String taskName = taskVertex.getName();
        int parallelTaskCount;
        if (taskVertex.getParallelism() >= 1) {
            parallelTaskCount = taskVertex.getParallelism();
        } else {
            parallelTaskCount = TaskSchedulerContext.taskParallelism(config);
        }
        parallelTaskMap.put(taskName, parallelTaskCount);
    }
    return parallelTaskMap;
}
Also used : Vertex(edu.iu.dsc.tws.api.compute.graph.Vertex) Config(edu.iu.dsc.tws.api.config.Config) LinkedHashMap(java.util.LinkedHashMap)

Example 24 with Vertex

use of edu.iu.dsc.tws.api.compute.graph.Vertex in project twister2 by DSC-SPIDAL.

the class TaskAttributes method getTaskRamMap.

/**
 * This method retrieve the set of task vertices and check if the task vertex has the user
 * specified ram value. If the user doesn't specify the required ram configuration it will
 * assign the default ram value from the task configuration file and store it in the map.
 */
public Map<String, Double> getTaskRamMap(Set<Vertex> taskVertices) {
    Map<String, Double> taskRamMap = new HashMap<>();
    Object ram;
    double requiredRam;
    for (Vertex task : taskVertices) {
        Config config = task.getConfig();
        if (config.get("Ram") != null) {
            ram = config.get("Ram");
            requiredRam = (double) ((Integer) ram);
        } else {
            requiredRam = TaskSchedulerContext.taskInstanceRam(config);
        }
        taskRamMap.put(task.getName(), requiredRam);
    }
    return taskRamMap;
}
Also used : Vertex(edu.iu.dsc.tws.api.compute.graph.Vertex) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) Config(edu.iu.dsc.tws.api.config.Config)

Example 25 with Vertex

use of edu.iu.dsc.tws.api.compute.graph.Vertex in project twister2 by DSC-SPIDAL.

the class TaskVertexParser method parseVertexSet.

public List<Set<Vertex>> parseVertexSet(ComputeGraph computeGraph) {
    Set<Vertex> taskVertexSet = computeGraph.getTaskVertexSet();
    for (Vertex vertex : taskVertexSet) {
        if (computeGraph.inDegreeOfTask(vertex) == 0) {
            add(vertex);
            targetVertexSet.add(vertex);
            if (computeGraph.childrenOfTask(vertex).size() >= 1) {
                checkChildTasks(computeGraph, vertex);
            }
        } else {
            if (checkChildTasks(computeGraph, vertex)) {
                if (!targetVertexSet.contains(vertex)) {
                    add(vertex);
                    targetVertexSet.add(vertex);
                }
            }
        }
    }
    for (Set<Vertex> aTaskVertexSet : taskVertexList) {
        for (Vertex vertex : aTaskVertexSet) {
            LOG.fine("%%% Vertex Details:" + vertex.getName() + "\t" + aTaskVertexSet.size());
        }
    }
    return taskVertexList;
}
Also used : Vertex(edu.iu.dsc.tws.api.compute.graph.Vertex)

Aggregations

Vertex (edu.iu.dsc.tws.api.compute.graph.Vertex)27 LinkedHashMap (java.util.LinkedHashMap)15 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)11 List (java.util.List)11 TaskInstanceId (edu.iu.dsc.tws.api.compute.schedule.elements.TaskInstanceId)10 Map (java.util.Map)10 Resource (edu.iu.dsc.tws.api.compute.schedule.elements.Resource)8 TaskInstancePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskInstancePlan)8 TaskSchedulePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskSchedulePlan)8 WorkerSchedulePlan (edu.iu.dsc.tws.api.compute.schedule.elements.WorkerSchedulePlan)8 Config (edu.iu.dsc.tws.api.config.Config)8 LinkedHashSet (java.util.LinkedHashSet)8 Worker (edu.iu.dsc.tws.api.compute.schedule.elements.Worker)7 TaskInstanceMapCalculation (edu.iu.dsc.tws.tsched.spi.taskschedule.TaskInstanceMapCalculation)7 TreeSet (java.util.TreeSet)6 TaskSchedulerException (edu.iu.dsc.tws.api.compute.exceptions.TaskSchedulerException)4 TaskAttributes (edu.iu.dsc.tws.tsched.utils.TaskAttributes)4 HashSet (java.util.HashSet)4 Set (java.util.Set)4