Search in sources :

Example 11 with Worker

use of edu.iu.dsc.tws.api.compute.schedule.elements.Worker in project twister2 by DSC-SPIDAL.

the class DataLocalityBatchTaskScheduler method calculateDistance.

/**
 * It calculates the distance between the data nodes and the worker nodes.
 */
private Map<String, List<DataTransferTimeCalculator>> calculateDistance(List<String> datanodesList, WorkerPlan workerPlan, int taskIndex) {
    Map<String, List<DataTransferTimeCalculator>> workerPlanMap = new HashMap<>();
    Worker worker;
    double workerBandwidth;
    double workerLatency;
    double calculateDistance = 0.0;
    double datanodeBandwidth;
    double datanodeLatency;
    for (String nodesList : datanodesList) {
        ArrayList<DataTransferTimeCalculator> calculatedVal = new ArrayList<>();
        for (int i = 0; i < workerPlan.getNumberOfWorkers(); i++) {
            worker = workerPlan.getWorker(i);
            DataTransferTimeCalculator calculateDataTransferTime = new DataTransferTimeCalculator(nodesList, calculateDistance);
            if (worker.getProperty(Context.TWISTER2_BANDWIDTH) != null && worker.getProperty(Context.TWISTER2_LATENCY) != null) {
                workerBandwidth = (double) worker.getProperty(Context.TWISTER2_BANDWIDTH);
                workerLatency = (double) worker.getProperty(Context.TWISTER2_LATENCY);
            } else {
                workerBandwidth = TaskSchedulerContext.containerInstanceBandwidth(config);
                workerLatency = TaskSchedulerContext.containerInstanceLatency(config);
            }
            // Right now using the default configuration values
            datanodeBandwidth = TaskSchedulerContext.datanodeInstanceBandwidth(config);
            datanodeLatency = TaskSchedulerContext.datanodeInstanceLatency(config);
            // Calculate the distance between worker nodes and data nodes.
            calculateDistance = Math.abs((2 * workerBandwidth * workerLatency) - (2 * datanodeBandwidth * datanodeLatency));
            // (use this formula to calculate the data transfer time)
            // calculateDistance = File Size / Bandwidth;
            calculateDataTransferTime.setRequiredDataTransferTime(calculateDistance);
            calculateDataTransferTime.setNodeName(worker.getId() + "");
            calculateDataTransferTime.setTaskIndex(taskIndex);
            calculatedVal.add(calculateDataTransferTime);
        }
        workerPlanMap.put(nodesList, calculatedVal);
    }
    return workerPlanMap;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) Worker(edu.iu.dsc.tws.api.compute.schedule.elements.Worker) DataTransferTimeCalculator(edu.iu.dsc.tws.tsched.utils.DataTransferTimeCalculator) ArrayList(java.util.ArrayList) List(java.util.List)

Example 12 with Worker

use of edu.iu.dsc.tws.api.compute.schedule.elements.Worker in project twister2 by DSC-SPIDAL.

the class DataLocalityStreamingTaskScheduler method dTTimecalculatorList.

/**
 * Data transfer time calculator list
 */
private List<DataTransferTimeCalculator> dTTimecalculatorList(int index, WorkerPlan workerPlan, Map<Integer, List<TaskInstanceId>> map, int containerIndex, int maxTaskPerContainer) {
    List<String> inputDataList = getInputFilesList();
    Map<String, List<DataTransferTimeCalculator>> workerDatanodeDistanceMap;
    List<DataTransferTimeCalculator> dataTransferTimeCalculatorList = null;
    List<String> datanodesList;
    /*If the index is zero, simply calculate the distance between the worker node and the
    datanodes. Else, if the index values is greater than 0, check the container has reached
    the maximum task instances per container. If it is yes, then calculationList the container to
    the allocatedWorkers list which will not be considered for the next scheduling cycle.*/
    DataNodeLocatorUtils dataNodeLocatorUtils = new DataNodeLocatorUtils(config);
    if (inputDataList.size() > 0) {
        if (index == 0) {
            datanodesList = dataNodeLocatorUtils.findDataNodesLocation(inputDataList);
            workerDatanodeDistanceMap = distanceCalculator(datanodesList, workerPlan, index, allocatedWorkers);
            dataTransferTimeCalculatorList = findBestWorkerNode(workerDatanodeDistanceMap);
        } else {
            datanodesList = dataNodeLocatorUtils.findDataNodesLocation(inputDataList);
            Worker worker = workerPlan.getWorker(containerIndex);
            if (map.get(containerIndex).size() >= maxTaskPerContainer) {
                allocatedWorkers.add(worker.getId());
            }
            workerDatanodeDistanceMap = distanceCalculator(datanodesList, workerPlan, index, allocatedWorkers);
            dataTransferTimeCalculatorList = findBestWorkerNode(workerDatanodeDistanceMap);
        }
    }
    return dataTransferTimeCalculatorList;
}
Also used : DataNodeLocatorUtils(edu.iu.dsc.tws.data.utils.DataNodeLocatorUtils) DataTransferTimeCalculator(edu.iu.dsc.tws.tsched.utils.DataTransferTimeCalculator) Worker(edu.iu.dsc.tws.api.compute.schedule.elements.Worker) ArrayList(java.util.ArrayList) List(java.util.List)

Example 13 with Worker

use of edu.iu.dsc.tws.api.compute.schedule.elements.Worker in project twister2 by DSC-SPIDAL.

the class DataLocalityBatchTaskSchedulerTest method createWorkPlan2.

private WorkerPlan createWorkPlan2(int workers) {
    WorkerPlan plan = new WorkerPlan();
    for (int i = workers - 1; i >= 0; i--) {
        Worker w = new Worker(i);
        w.addProperty("bandwidth", 1000.0);
        w.addProperty("latency", 0.1);
        plan.addWorker(w);
    }
    return plan;
}
Also used : Worker(edu.iu.dsc.tws.api.compute.schedule.elements.Worker) WorkerPlan(edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan)

Example 14 with Worker

use of edu.iu.dsc.tws.api.compute.schedule.elements.Worker in project twister2 by DSC-SPIDAL.

the class DataLocalityBatchTaskSchedulerTest method createWorkPlan.

private WorkerPlan createWorkPlan(int workers) {
    WorkerPlan plan = new WorkerPlan();
    for (int i = 0; i < workers; i++) {
        Worker w = new Worker(i);
        w.addProperty("bandwidth", 1000.0);
        w.addProperty("latency", 0.1);
        plan.addWorker(w);
    }
    return plan;
}
Also used : Worker(edu.iu.dsc.tws.api.compute.schedule.elements.Worker) WorkerPlan(edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan)

Example 15 with Worker

use of edu.iu.dsc.tws.api.compute.schedule.elements.Worker in project twister2 by DSC-SPIDAL.

the class DataLocalityTaskSchedulerTest method createWorkPlan.

private WorkerPlan createWorkPlan(int workers) {
    WorkerPlan plan = new WorkerPlan();
    for (int i = 0; i < workers; i++) {
        Worker w = new Worker(i);
        w.addProperty("bandwidth", 1000.0);
        w.addProperty("latency", 0.1);
        plan.addWorker(w);
    }
    return plan;
}
Also used : Worker(edu.iu.dsc.tws.api.compute.schedule.elements.Worker) WorkerPlan(edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan)

Aggregations

Worker (edu.iu.dsc.tws.api.compute.schedule.elements.Worker)16 ArrayList (java.util.ArrayList)10 WorkerPlan (edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan)8 List (java.util.List)8 HashMap (java.util.HashMap)7 Vertex (edu.iu.dsc.tws.api.compute.graph.Vertex)6 Resource (edu.iu.dsc.tws.api.compute.schedule.elements.Resource)6 TaskInstanceId (edu.iu.dsc.tws.api.compute.schedule.elements.TaskInstanceId)6 TaskInstancePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskInstancePlan)6 TaskSchedulePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskSchedulePlan)6 WorkerSchedulePlan (edu.iu.dsc.tws.api.compute.schedule.elements.WorkerSchedulePlan)6 TaskInstanceMapCalculation (edu.iu.dsc.tws.tsched.spi.taskschedule.TaskInstanceMapCalculation)6 LinkedHashMap (java.util.LinkedHashMap)6 Map (java.util.Map)6 LinkedHashSet (java.util.LinkedHashSet)5 HashSet (java.util.HashSet)3 JobMasterAPI (edu.iu.dsc.tws.proto.jobmaster.JobMasterAPI)2 DataTransferTimeCalculator (edu.iu.dsc.tws.tsched.utils.DataTransferTimeCalculator)2 TaskVertexParser (edu.iu.dsc.tws.tsched.utils.TaskVertexParser)2 Set (java.util.Set)2