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");
}
}
}
}
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));
}
}
}
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()));
}
}
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();
}
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;
}
Aggregations