Search in sources :

Example 1 with Job

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;
}
Also used : RequiredRam(edu.iu.dsc.tws.tsched.utils.RequiredRam) ArrayList(java.util.ArrayList) Job(edu.iu.dsc.tws.tsched.utils.Job)

Example 2 with Job

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;
}
Also used : HashMap(java.util.HashMap) InstanceId(edu.iu.dsc.tws.tsched.spi.taskschedule.InstanceId) ArrayList(java.util.ArrayList) List(java.util.List) Job(edu.iu.dsc.tws.tsched.utils.Job)

Example 3 with Job

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();
    }
}
Also used : TaskSchedulePlan(edu.iu.dsc.tws.tsched.spi.taskschedule.TaskSchedulePlan) TaskExecutorFixedThread(edu.iu.dsc.tws.task.core.TaskExecutorFixedThread) Job(edu.iu.dsc.tws.tsched.utils.Job) HashSet(java.util.HashSet)

Example 4 with Job

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();
}
Also used : TaskSchedulePlan(edu.iu.dsc.tws.tsched.spi.taskschedule.TaskSchedulePlan) Task(edu.iu.dsc.tws.tsched.utils.Task) Job(edu.iu.dsc.tws.tsched.utils.Job)

Aggregations

Job (edu.iu.dsc.tws.tsched.utils.Job)4 TaskSchedulePlan (edu.iu.dsc.tws.tsched.spi.taskschedule.TaskSchedulePlan)2 ArrayList (java.util.ArrayList)2 TaskExecutorFixedThread (edu.iu.dsc.tws.task.core.TaskExecutorFixedThread)1 InstanceId (edu.iu.dsc.tws.tsched.spi.taskschedule.InstanceId)1 RequiredRam (edu.iu.dsc.tws.tsched.utils.RequiredRam)1 Task (edu.iu.dsc.tws.tsched.utils.Task)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1