use of edu.iu.dsc.tws.tsched.utils.Job 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;
}
use of edu.iu.dsc.tws.tsched.utils.Job in project twister2 by DSC-SPIDAL.
the class RRTaskScheduling method RoundRobinScheduling.
/**
* This method is to perform the Round Robin based Scheduling operation.
* And, it will allocate the instances in a Round Robin mode.
*
* @return Container Instance Map
*/
private Map<Integer, List<InstanceId>> RoundRobinScheduling() {
int taskIndex = 1;
int globalTaskIndex = 1;
Job job = new Job();
job = job.getJob();
Map<Integer, List<InstanceId>> roundRobinAllocation = new HashMap<>();
try {
int numberOfContainers = JobAttributes.getNumberOfContainers(job);
int totalInstances = JobAttributes.getTotalNumberOfInstances(job);
for (int i = 1; i <= numberOfContainers; i++) {
roundRobinAllocation.put(i, new ArrayList<InstanceId>());
}
Map<String, Integer> parallelTaskMap = JobAttributes.getParallelTaskMap(job);
for (String task : parallelTaskMap.keySet()) {
int numberOfInstances = parallelTaskMap.get(task);
for (int i = 0; i < numberOfInstances; i++) {
roundRobinAllocation.get(taskIndex).add(new InstanceId(task, globalTaskIndex, i));
if (taskIndex != numberOfContainers) {
taskIndex = taskIndex + 1;
} else {
taskIndex = 1;
}
globalTaskIndex += 1;
}
}
} catch (NullPointerException ne) {
ne.printStackTrace();
}
return roundRobinAllocation;
}
use of edu.iu.dsc.tws.tsched.utils.Job in project twister2 by DSC-SPIDAL.
the class TaskScheduling method init.
@Override
public void init(edu.iu.dsc.tws.common.config.Config config, int id, ResourcePlan resourcePlan) {
taskExecutor = new TaskExecutorFixedThread();
this.status = Status.INIT;
// TaskPlan taskPlan = Utils.createTaskPlan(config, resourcePlan);
// TWSNetwork network = new TWSNetwork(config, taskPlan);
// TWSCommunication channel = network.getDataFlowTWSCommunication();
Set<Integer> sources = new HashSet<>();
sources.add(0);
// schedule();
try {
Job job = new Job();
job.setJobId(1);
job.setTaskLength(4);
job.setJob(job);
RoundRobinTaskScheduling roundRobinTaskScheduling = new RoundRobinTaskScheduling();
roundRobinTaskScheduling.initialize(job);
TaskSchedulePlan taskSchedulePlan = roundRobinTaskScheduling.tschedule();
System.out.println("Task schedule plan details:" + taskSchedulePlan);
} catch (Exception ee) {
ee.printStackTrace();
}
}
use of edu.iu.dsc.tws.tsched.utils.Job in project twister2 by DSC-SPIDAL.
the class TaskScheduling method schedule.
public void schedule() {
System.out.println("I am inside init method");
Job job = new Job();
job.setJob(job);
Task[] taskList = new Task[4];
RoundRobinTaskScheduling roundRobinTaskScheduling = new RoundRobinTaskScheduling();
// Config config = null;
// roundRobinTaskScheduling.initialize(config, job);
roundRobinTaskScheduling.initialize(job);
TaskSchedulePlan taskSchedulePlan = roundRobinTaskScheduling.tschedule();
}
Aggregations