Search in sources :

Example 1 with Task

use of org.apache.hyracks.control.cc.job.Task in project asterixdb by apache.

the class JobExecutor method findTaskLocation.

private String findTaskLocation(TaskId tid) {
    ActivityId aid = tid.getActivityId();
    ActivityCluster ac = jobRun.getActivityClusterGraph().getActivityMap().get(aid);
    Task[] tasks = getActivityClusterPlan(ac).getActivityPlanMap().get(aid).getTasks();
    List<TaskClusterAttempt> tcAttempts = tasks[tid.getPartition()].getTaskCluster().getAttempts();
    if (tcAttempts == null || tcAttempts.isEmpty()) {
        return null;
    }
    TaskClusterAttempt lastTCA = tcAttempts.get(tcAttempts.size() - 1);
    TaskAttempt ta = lastTCA.getTaskAttempts().get(tid);
    return ta == null ? null : ta.getNodeId();
}
Also used : Task(org.apache.hyracks.control.cc.job.Task) TaskClusterAttempt(org.apache.hyracks.control.cc.job.TaskClusterAttempt) ActivityId(org.apache.hyracks.api.dataflow.ActivityId) TaskAttempt(org.apache.hyracks.control.cc.job.TaskAttempt) ActivityCluster(org.apache.hyracks.api.job.ActivityCluster)

Example 2 with Task

use of org.apache.hyracks.control.cc.job.Task in project asterixdb by apache.

the class ActivityClusterPlanner method assignConnectorPolicy.

private void assignConnectorPolicy(ActivityCluster ac, Map<ActivityId, ActivityPlan> taskMap) {
    Map<ConnectorDescriptorId, IConnectorPolicy> cPolicyMap = new HashMap<>();
    Set<ActivityId> activities = ac.getActivityMap().keySet();
    BitSet targetBitmap = new BitSet();
    for (ActivityId a1 : activities) {
        Task[] ac1TaskStates = taskMap.get(a1).getTasks();
        int nProducers = ac1TaskStates.length;
        List<IConnectorDescriptor> outputConns = ac.getActivityOutputMap().get(a1);
        if (outputConns == null) {
            continue;
        }
        for (IConnectorDescriptor c : outputConns) {
            ConnectorDescriptorId cdId = c.getConnectorId();
            ActivityId a2 = ac.getConsumerActivity(cdId);
            Task[] ac2TaskStates = taskMap.get(a2).getTasks();
            int nConsumers = ac2TaskStates.length;
            int[] fanouts = new int[nProducers];
            if (c.allProducersToAllConsumers()) {
                for (int i = 0; i < nProducers; ++i) {
                    fanouts[i] = nConsumers;
                }
            } else {
                for (int i = 0; i < nProducers; ++i) {
                    c.indicateTargetPartitions(nProducers, nConsumers, i, targetBitmap);
                    fanouts[i] = targetBitmap.cardinality();
                }
            }
            IConnectorPolicy cp = assignConnectorPolicy(ac, c, nProducers, nConsumers, fanouts);
            cPolicyMap.put(cdId, cp);
        }
    }
    executor.getJobRun().getConnectorPolicyMap().putAll(cPolicyMap);
}
Also used : IConnectorDescriptor(org.apache.hyracks.api.dataflow.IConnectorDescriptor) Task(org.apache.hyracks.control.cc.job.Task) HashMap(java.util.HashMap) IConnectorPolicy(org.apache.hyracks.api.dataflow.connectors.IConnectorPolicy) ActivityId(org.apache.hyracks.api.dataflow.ActivityId) ConnectorDescriptorId(org.apache.hyracks.api.dataflow.ConnectorDescriptorId) BitSet(java.util.BitSet)

Example 3 with Task

use of org.apache.hyracks.control.cc.job.Task in project asterixdb by apache.

the class ActivityClusterPlanner method getTaskCluster.

private TaskCluster getTaskCluster(TaskId tid) {
    JobRun run = executor.getJobRun();
    ActivityCluster ac = run.getActivityClusterGraph().getActivityMap().get(tid.getActivityId());
    ActivityClusterPlan acp = run.getActivityClusterPlanMap().get(ac.getId());
    Task[] tasks = acp.getActivityPlanMap().get(tid.getActivityId()).getTasks();
    Task task = tasks[tid.getPartition()];
    assert task.getTaskId().equals(tid);
    return task.getTaskCluster();
}
Also used : Task(org.apache.hyracks.control.cc.job.Task) ActivityClusterPlan(org.apache.hyracks.control.cc.job.ActivityClusterPlan) JobRun(org.apache.hyracks.control.cc.job.JobRun) ActivityCluster(org.apache.hyracks.api.job.ActivityCluster)

Example 4 with Task

use of org.apache.hyracks.control.cc.job.Task in project asterixdb by apache.

the class ActivityClusterPlanner method buildActivityPlanMap.

private Map<ActivityId, ActivityPlan> buildActivityPlanMap(ActivityCluster ac, JobRun jobRun, Map<ActivityId, ActivityPartitionDetails> pcMap) {
    Map<ActivityId, ActivityPlan> activityPlanMap = new HashMap<>();
    Set<ActivityId> depAnIds = new HashSet<>();
    for (ActivityId anId : ac.getActivityMap().keySet()) {
        depAnIds.clear();
        getDependencyActivityIds(depAnIds, anId, ac);
        ActivityPartitionDetails apd = pcMap.get(anId);
        Task[] tasks = new Task[apd.getPartitionCount()];
        ActivityPlan activityPlan = new ActivityPlan(apd);
        for (int i = 0; i < tasks.length; ++i) {
            TaskId tid = new TaskId(anId, i);
            tasks[i] = new Task(tid, activityPlan);
            for (ActivityId danId : depAnIds) {
                ActivityCluster dAC = ac.getActivityClusterGraph().getActivityMap().get(danId);
                ActivityClusterPlan dACP = jobRun.getActivityClusterPlanMap().get(dAC.getId());
                assert dACP != null : "IllegalStateEncountered: Dependent AC is being planned without a plan for " + "dependency AC: Encountered no plan for ActivityID " + danId;
                Task[] dATasks = dACP.getActivityPlanMap().get(danId).getTasks();
                assert dATasks != null : "IllegalStateEncountered: Dependent AC is being planned without a plan for" + " dependency AC: Encountered no plan for ActivityID " + danId;
                assert dATasks.length == tasks.length : "Dependency activity partitioned differently from " + "dependent: " + dATasks.length + " != " + tasks.length;
                Task dTask = dATasks[i];
                TaskId dTaskId = dTask.getTaskId();
                tasks[i].getDependencies().add(dTaskId);
                dTask.getDependents().add(tid);
            }
        }
        activityPlan.setTasks(tasks);
        activityPlanMap.put(anId, activityPlan);
    }
    return activityPlanMap;
}
Also used : Task(org.apache.hyracks.control.cc.job.Task) TaskId(org.apache.hyracks.api.dataflow.TaskId) HashMap(java.util.HashMap) ActivityId(org.apache.hyracks.api.dataflow.ActivityId) ActivityPlan(org.apache.hyracks.control.cc.job.ActivityPlan) ActivityCluster(org.apache.hyracks.api.job.ActivityCluster) ActivityClusterPlan(org.apache.hyracks.control.cc.job.ActivityClusterPlan) HashSet(java.util.HashSet)

Example 5 with Task

use of org.apache.hyracks.control.cc.job.Task in project asterixdb by apache.

the class ActivityClusterPlanner method buildConnectorPolicyUnawareTaskClusters.

private TaskCluster[] buildConnectorPolicyUnawareTaskClusters(ActivityCluster ac, Map<ActivityId, ActivityPlan> activityPlanMap) {
    List<Task> taskStates = new ArrayList<>();
    for (ActivityId anId : ac.getActivityMap().keySet()) {
        ActivityPlan ap = activityPlanMap.get(anId);
        Task[] tasks = ap.getTasks();
        taskStates.addAll(Arrays.asList(tasks));
    }
    TaskCluster tc = new TaskCluster(new TaskClusterId(ac.getId(), 0), ac, taskStates.toArray(new Task[taskStates.size()]));
    for (Task t : tc.getTasks()) {
        t.setTaskCluster(tc);
    }
    return new TaskCluster[] { tc };
}
Also used : Task(org.apache.hyracks.control.cc.job.Task) ActivityId(org.apache.hyracks.api.dataflow.ActivityId) ActivityPlan(org.apache.hyracks.control.cc.job.ActivityPlan) ArrayList(java.util.ArrayList) TaskCluster(org.apache.hyracks.control.cc.job.TaskCluster) TaskClusterId(org.apache.hyracks.control.cc.job.TaskClusterId)

Aggregations

Task (org.apache.hyracks.control.cc.job.Task)10 ActivityId (org.apache.hyracks.api.dataflow.ActivityId)9 TaskId (org.apache.hyracks.api.dataflow.TaskId)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 ConnectorDescriptorId (org.apache.hyracks.api.dataflow.ConnectorDescriptorId)5 ActivityCluster (org.apache.hyracks.api.job.ActivityCluster)5 List (java.util.List)4 ActivityPlan (org.apache.hyracks.control.cc.job.ActivityPlan)4 TaskCluster (org.apache.hyracks.control.cc.job.TaskCluster)4 BitSet (java.util.BitSet)3 IConnectorDescriptor (org.apache.hyracks.api.dataflow.IConnectorDescriptor)3 IConnectorPolicy (org.apache.hyracks.api.dataflow.connectors.IConnectorPolicy)3 JobRun (org.apache.hyracks.control.cc.job.JobRun)3 TaskAttempt (org.apache.hyracks.control.cc.job.TaskAttempt)3 TaskClusterAttempt (org.apache.hyracks.control.cc.job.TaskClusterAttempt)3 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Pair (org.apache.commons.lang3.tuple.Pair)2 ActivityClusterGraph (org.apache.hyracks.api.job.ActivityClusterGraph)2