Search in sources :

Example 11 with TaskSchedulerException

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

the class BatchTaskScheduler method dependentTaskWorkerAllocation.

/**
 * This method is for allocating the multiple dependent task graphs. First, it stores the
 * scheduled worker list in the list for scheduling the next task graphs. It gets invoked
 * when all the task graphs are connected together.
 */
private void dependentTaskWorkerAllocation(ComputeGraph graph, Vertex vertex, int numberOfContainers, int globalTaskIndex) {
    int totalTaskInstances;
    if (graph.getNodeConstraints().isEmpty()) {
        totalTaskInstances = taskAttributes.getTotalNumberOfInstances(vertex);
        String task = vertex.getName();
        int containerIndex;
        for (int i = 0; i < totalTaskInstances; i++) {
            if (workerIdList.size() == 0) {
                containerIndex = i % numberOfContainers;
            } else {
                containerIndex = i % workerIdList.size();
            }
            batchTaskAllocation.get(containerIndex).add(new TaskInstanceId(task, globalTaskIndex, i));
        }
    } else {
        totalTaskInstances = taskAttributes.getTotalNumberOfInstances(vertex, graph.getNodeConstraints());
        int instancesPerWorker = taskAttributes.getInstancesPerWorker(graph.getGraphConstraints());
        int maxTaskInstancesPerContainer = 0;
        int containerIndex;
        for (int i = 0; i < totalTaskInstances; i++) {
            if (workerIdList.size() == 0) {
                containerIndex = i % numberOfContainers;
            } else {
                containerIndex = i % workerIdList.size();
            }
            if (maxTaskInstancesPerContainer < instancesPerWorker) {
                batchTaskAllocation.get(containerIndex).add(new TaskInstanceId(vertex.getName(), globalTaskIndex, i));
                ++maxTaskInstancesPerContainer;
            } else {
                throw new TaskSchedulerException("Task Scheduling couldn't be possible for the present" + "configuration, please check the number of workers maximum instances per worker");
            }
        }
    }
}
Also used : TaskInstanceId(edu.iu.dsc.tws.api.compute.schedule.elements.TaskInstanceId) TaskSchedulerException(edu.iu.dsc.tws.api.compute.exceptions.TaskSchedulerException)

Example 12 with TaskSchedulerException

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

the class BatchTaskScheduler method independentTaskWorkerAllocation.

/**
 * This method is to allocate the task for the individual task graph.
 *
 * @param graph
 * @param vertex
 * @param numberOfContainers
 * @param globalTaskIndex
 */
private void independentTaskWorkerAllocation(ComputeGraph graph, Vertex vertex, int numberOfContainers, int globalTaskIndex) {
    int totalTaskInstances;
    if (!graph.getNodeConstraints().isEmpty()) {
        totalTaskInstances = taskAttributes.getTotalNumberOfInstances(vertex, graph.getNodeConstraints());
    } else {
        totalTaskInstances = taskAttributes.getTotalNumberOfInstances(vertex);
    }
    if (!graph.getNodeConstraints().isEmpty()) {
        int instancesPerWorker = taskAttributes.getInstancesPerWorker(graph.getGraphConstraints());
        int maxTaskInstancesPerContainer = 0;
        int containerIndex;
        for (int i = 0; i < totalTaskInstances; i++) {
            containerIndex = i % numberOfContainers;
            if (maxTaskInstancesPerContainer < instancesPerWorker) {
                batchTaskAllocation.get(containerIndex).add(new TaskInstanceId(vertex.getName(), globalTaskIndex, i));
                ++maxTaskInstancesPerContainer;
            } else {
                throw new TaskSchedulerException("Task Scheduling couldn't be possible for the present" + "configuration, please check the number of workers, " + "maximum instances per worker");
            }
        }
    } else {
        String task = vertex.getName();
        int containerIndex;
        for (int i = 0; i < totalTaskInstances; i++) {
            containerIndex = i % numberOfContainers;
            batchTaskAllocation.get(containerIndex).add(new TaskInstanceId(task, globalTaskIndex, i));
        }
    }
}
Also used : TaskInstanceId(edu.iu.dsc.tws.api.compute.schedule.elements.TaskInstanceId) TaskSchedulerException(edu.iu.dsc.tws.api.compute.exceptions.TaskSchedulerException)

Example 13 with TaskSchedulerException

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

the class Container method assertHasSpace.

private void assertHasSpace(Resource resourceValue) throws TaskSchedulerException {
    Resource usedResources = this.getTotalUsedResources();
    double newRam = usedResources.getRam() + resourceValue.getRam() + paddingPercentage;
    double newDisk = usedResources.getDisk() + resourceValue.getDisk() + paddingPercentage;
    double newCpu = usedResources.getCpu() + resourceValue.getCpu() + paddingPercentage;
    if (newRam > this.resource.getRam()) {
        throw new TaskSchedulerException(String.format("Adding %s bytes of ram to existing %s " + "bytes with %d percent padding would exceed capacity %s", resourceValue.getRam(), usedResources.getRam(), paddingPercentage, this.resource.getRam()));
    }
    if (newDisk > this.resource.getDisk()) {
        throw new TaskSchedulerException(String.format("Adding %s bytes of disk to existing %s " + "bytes with %s percent padding would exceed capacity %s", resourceValue.getDisk(), usedResources.getDisk(), paddingPercentage, this.resource.getDisk()));
    }
    if (newCpu > this.resource.getCpu()) {
        throw new TaskSchedulerException(String.format("Adding %s cores to existing %s " + "cores with %d percent padding would exceed capacity %s", resourceValue.getCpu(), usedResources.getCpu(), paddingPercentage, this.resource.getCpu()));
    }
}
Also used : Resource(edu.iu.dsc.tws.api.compute.schedule.elements.Resource) TaskSchedulerException(edu.iu.dsc.tws.api.compute.exceptions.TaskSchedulerException)

Example 14 with TaskSchedulerException

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

the class FirstFitStreamingTaskScheduler method schedule.

/**
 * This is the base method for the first fit task scheduling. It invokes the taskscheduleplan
 * builder to allocate the task instances into the containers.
 */
@Override
public TaskSchedulePlan schedule(ComputeGraph computeGraph, WorkerPlan workerPlan) {
    this.taskVertexSet = computeGraph.getTaskVertexSet();
    TaskSchedulePlanBuilder taskSchedulePlanBuilder = newTaskSchedulingPlanBuilder(null);
    try {
        taskSchedulePlanBuilder = FirstFitFTaskSchedulingAlgorithm(taskSchedulePlanBuilder);
    } catch (TaskSchedulerException te) {
        throw new TaskSchedulerException("Couldn't allocate all instances to task schedule plan", te);
    }
    return taskSchedulePlanBuilder.build();
}
Also used : TaskSchedulePlanBuilder(edu.iu.dsc.tws.tsched.builder.TaskSchedulePlanBuilder) TaskSchedulerException(edu.iu.dsc.tws.api.compute.exceptions.TaskSchedulerException)

Example 15 with TaskSchedulerException

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

the class TaskScheduler method generateTaskSchedulePlan.

private TaskSchedulePlan generateTaskSchedulePlan(String className) {
    Class<?> taskSchedulerClass;
    Method method;
    TaskSchedulePlan taskSchedulePlan;
    try {
        taskSchedulerClass = getClass().getClassLoader().loadClass(className);
        Object newInstance = taskSchedulerClass.newInstance();
        method = taskSchedulerClass.getMethod("initialize", new Class<?>[] { Config.class });
        method.invoke(newInstance, config);
        method = taskSchedulerClass.getMethod("schedule", new Class<?>[] { ComputeGraph.class, WorkerPlan.class });
        taskSchedulePlan = (TaskSchedulePlan) method.invoke(newInstance, computeGraph, workerPlan);
    } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException | InstantiationException | ClassNotFoundException | TaskSchedulerException e) {
        throw new Twister2RuntimeException(e);
    }
    if (taskSchedulePlan != null) {
        Map<Integer, WorkerSchedulePlan> containersMap = taskSchedulePlan.getContainersMap();
        for (Map.Entry<Integer, WorkerSchedulePlan> entry : containersMap.entrySet()) {
            Integer integer = entry.getKey();
            WorkerSchedulePlan workerSchedulePlan = entry.getValue();
            Set<TaskInstancePlan> containerPlanTaskInstances = workerSchedulePlan.getTaskInstances();
            LOG.fine("Task Details for Container Id:" + integer);
            for (TaskInstancePlan ip : containerPlanTaskInstances) {
                LOG.fine("Task Id:" + ip.getTaskId() + "\tTask Index" + ip.getTaskIndex() + "\tTask Name:" + ip.getTaskName());
            }
        }
    }
    return taskSchedulePlan;
}
Also used : Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) Config(edu.iu.dsc.tws.api.config.Config) ComputeGraph(edu.iu.dsc.tws.api.compute.graph.ComputeGraph) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) TaskSchedulerException(edu.iu.dsc.tws.api.compute.exceptions.TaskSchedulerException) WorkerPlan(edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan) TaskSchedulePlan(edu.iu.dsc.tws.api.compute.schedule.elements.TaskSchedulePlan) WorkerSchedulePlan(edu.iu.dsc.tws.api.compute.schedule.elements.WorkerSchedulePlan) TaskInstancePlan(edu.iu.dsc.tws.api.compute.schedule.elements.TaskInstancePlan) Map(java.util.Map)

Aggregations

TaskSchedulerException (edu.iu.dsc.tws.api.compute.exceptions.TaskSchedulerException)16 TaskInstanceId (edu.iu.dsc.tws.api.compute.schedule.elements.TaskInstanceId)8 Resource (edu.iu.dsc.tws.api.compute.schedule.elements.Resource)7 TaskInstancePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskInstancePlan)6 ArrayList (java.util.ArrayList)6 WorkerSchedulePlan (edu.iu.dsc.tws.api.compute.schedule.elements.WorkerSchedulePlan)5 TreeSet (java.util.TreeSet)5 Vertex (edu.iu.dsc.tws.api.compute.graph.Vertex)4 TaskAttributes (edu.iu.dsc.tws.tsched.utils.TaskAttributes)4 HashMap (java.util.HashMap)4 LinkedHashSet (java.util.LinkedHashSet)4 List (java.util.List)4 TaskSchedulePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskSchedulePlan)3 WorkerPlan (edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan)3 Config (edu.iu.dsc.tws.api.config.Config)3 Twister2RuntimeException (edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 ComputeGraph (edu.iu.dsc.tws.api.compute.graph.ComputeGraph)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2