use of edu.iu.dsc.tws.tsched.spi.taskschedule.TaskInstanceId 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;
}
Aggregations