Search in sources :

Example 1 with ExecutionAction

use of es.bsc.compss.types.allocatableactions.ExecutionAction in project compss by bsc-wdc.

the class ExecuteTasksRequest method submitSingleTask.

private <T extends WorkerResourceDescription> void submitSingleTask(TaskScheduler ts, ResourceScheduler<T> specificResource) {
    LOGGER.debug("Scheduling request for task " + task.getId() + " treated as singleTask");
    ExecutionAction action = new ExecutionAction(ts.generateSchedulingInformation(specificResource), ts.getOrchestrator(), producer, task);
    ts.newAllocatableAction(action);
}
Also used : ExecutionAction(es.bsc.compss.types.allocatableactions.ExecutionAction) MultiNodeExecutionAction(es.bsc.compss.types.allocatableactions.MultiNodeExecutionAction)

Example 2 with ExecutionAction

use of es.bsc.compss.types.allocatableactions.ExecutionAction in project compss by bsc-wdc.

the class PrintCurrentGraphRequest method process.

@Override
public void process(TaskScheduler ts) throws ShutdownException {
    try {
        PriorityQueue<Task> pending = new PriorityQueue<>();
        Set<Task> tasks = new HashSet<>();
        String prefix = "  ";
        // Header options
        graph.write(prefix + "outputorder=\"edgesfirst\";");
        graph.newLine();
        graph.write(prefix + "compound=true;");
        graph.newLine();
        /* Subgraph for blocked and scheduled tasks ******************** */
        graph.write(prefix + "subgraph cluster1 {");
        graph.newLine();
        graph.write(prefix + prefix + "color=white");
        graph.newLine();
        // Room for Blocked tasks
        int roomIndex = 1;
        graph.write(prefix + prefix + "subgraph cluster_room" + roomIndex + " {");
        ++roomIndex;
        graph.newLine();
        graph.write(prefix + prefix + prefix + "ranksep=0.20;");
        graph.newLine();
        graph.write(prefix + prefix + prefix + "node[height=0.75];");
        graph.newLine();
        graph.write(prefix + prefix + prefix + "label = \"Blocked\"");
        graph.newLine();
        graph.write(prefix + prefix + prefix + "color=red");
        graph.newLine();
        List<AllocatableAction> blockedActions = ts.getBlockedActions();
        for (AllocatableAction action : blockedActions) {
            if (action instanceof ExecutionAction) {
                ExecutionAction se = (ExecutionAction) action;
                Task t = se.getTask();
                graph.write(prefix + prefix + prefix + t.getDotDescription());
                graph.newLine();
                pending.addAll(t.getSuccessors());
                tasks.add(t);
            }
        }
        graph.write(prefix + prefix + "}");
        graph.newLine();
        // Room for unassigned tasks
        graph.write(prefix + prefix + "subgraph cluster_room" + roomIndex + " {");
        ++roomIndex;
        graph.newLine();
        graph.write(prefix + prefix + prefix + "ranksep=0.20;");
        graph.newLine();
        graph.write(prefix + prefix + prefix + "node[height=0.75];");
        graph.newLine();
        graph.write(prefix + prefix + prefix + "label = \"No Assigned\"");
        graph.newLine();
        graph.write(prefix + prefix + prefix + "color=orange");
        graph.newLine();
        List<AllocatableAction> unassignedActions = ts.getUnassignedActions();
        for (AllocatableAction action : unassignedActions) {
            if (action instanceof ExecutionAction) {
                ExecutionAction se = (ExecutionAction) action;
                Task t = se.getTask();
                graph.write(prefix + prefix + prefix + t.getDotDescription());
                graph.newLine();
                pending.addAll(t.getSuccessors());
                tasks.add(t);
            }
        }
        graph.write(prefix + prefix + "}");
        graph.newLine();
        // Add another room for each worker
        for (Worker<? extends WorkerResourceDescription> worker : ResourceManager.getAllWorkers()) {
            graph.write(prefix + prefix + "subgraph cluster_room" + roomIndex + " {");
            graph.newLine();
            graph.write(prefix + prefix + prefix + "label = \"" + worker.getName() + "\"");
            graph.newLine();
            graph.write(prefix + prefix + prefix + "color=black");
            graph.newLine();
            // Create a box for running tasks
            graph.write(prefix + prefix + prefix + "subgraph cluster_box" + roomIndex + "1 {");
            graph.newLine();
            graph.write(prefix + prefix + prefix + prefix + "label = \"Running\"");
            graph.newLine();
            graph.write(prefix + prefix + prefix + prefix + "ranksep=0.20;");
            graph.newLine();
            graph.write(prefix + prefix + prefix + prefix + "node[height=0.75];");
            graph.newLine();
            graph.write(prefix + prefix + prefix + prefix + "color=green");
            graph.newLine();
            AllocatableAction[] hostedActions = ts.getHostedActions(worker);
            for (AllocatableAction action : hostedActions) {
                if (action instanceof ExecutionAction) {
                    ExecutionAction se = (ExecutionAction) action;
                    Task t = se.getTask();
                    graph.write(prefix + prefix + prefix + prefix + t.getDotDescription());
                    graph.newLine();
                    pending.addAll(t.getSuccessors());
                    tasks.add(t);
                }
            }
            graph.write(prefix + prefix + prefix + "}");
            graph.newLine();
            graph.write(prefix + prefix + prefix + "subgraph cluster_box" + roomIndex + "2 {");
            graph.newLine();
            graph.write(prefix + prefix + prefix + prefix + "label = \"Resource Blocked\"");
            graph.newLine();
            graph.write(prefix + prefix + prefix + prefix + "ranksep=0.20;");
            graph.newLine();
            graph.write(prefix + prefix + prefix + prefix + "node[height=0.75];");
            graph.newLine();
            graph.write(prefix + prefix + prefix + prefix + "color=red");
            graph.newLine();
            PriorityQueue<AllocatableAction> blockedActionsOnResource = ts.getBlockedActionsOnResource(worker);
            for (AllocatableAction action : blockedActionsOnResource) {
                if (action instanceof ExecutionAction) {
                    ExecutionAction se = (ExecutionAction) action;
                    Task t = se.getTask();
                    graph.write(prefix + prefix + prefix + prefix + t.getDotDescription());
                    graph.newLine();
                    pending.addAll(t.getSuccessors());
                    tasks.add(t);
                }
            }
            // Close box
            graph.write(prefix + prefix + prefix + "}");
            graph.newLine();
            // Close room
            graph.write(prefix + prefix + "}");
            graph.newLine();
            ++roomIndex;
        }
        // Close cluster
        graph.write(prefix + "}");
        graph.newLine();
        /* Subgraph for pending tasks ********************************** */
        graph.write(prefix + "subgraph cluster2 {");
        graph.newLine();
        graph.write(prefix + prefix + "label = \"Pending\"");
        graph.newLine();
        graph.write(prefix + prefix + "ranksep=0.20;");
        graph.newLine();
        graph.write(prefix + prefix + "node[height=0.75];");
        graph.newLine();
        graph.write(prefix + prefix + "color=blue");
        graph.newLine();
        while (!pending.isEmpty()) {
            Task t = pending.poll();
            if (!tasks.contains(t)) {
                graph.write(prefix + prefix + t.getDotDescription());
                graph.newLine();
                tasks.add(t);
                pending.addAll(t.getSuccessors());
            }
        }
        // Close cluster
        graph.write(prefix + "}");
        graph.newLine();
        /* Write edges *************************************************** */
        for (Task t : tasks) {
            Set<Task> successors = new HashSet<>();
            successors.addAll(t.getSuccessors());
            for (Task t2 : successors) {
                graph.write(prefix + t.getId() + " -> " + t2.getId() + ";");
                graph.newLine();
            }
        }
        /* Force flush before end ***************************************** */
        graph.flush();
    } catch (IOException e) {
        LOGGER.error(ERROR_PRINT_CURRENT_GRAPH);
    }
    sem.release();
}
Also used : Task(es.bsc.compss.types.Task) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) IOException(java.io.IOException) PriorityQueue(java.util.PriorityQueue) ExecutionAction(es.bsc.compss.types.allocatableactions.ExecutionAction) HashSet(java.util.HashSet)

Aggregations

ExecutionAction (es.bsc.compss.types.allocatableactions.ExecutionAction)2 AllocatableAction (es.bsc.compss.scheduler.types.AllocatableAction)1 Task (es.bsc.compss.types.Task)1 MultiNodeExecutionAction (es.bsc.compss.types.allocatableactions.MultiNodeExecutionAction)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 PriorityQueue (java.util.PriorityQueue)1