Search in sources :

Example 11 with ActivityId

use of org.apache.hyracks.api.dataflow.ActivityId in project asterixdb by apache.

the class CCNCFunctions method writeTaskAttemptId.

private static void writeTaskAttemptId(DataOutputStream dos, TaskAttemptId taId) throws IOException {
    TaskId tid = taId.getTaskId();
    ActivityId aid = tid.getActivityId();
    OperatorDescriptorId odId = aid.getOperatorDescriptorId();
    dos.writeInt(odId.getId());
    dos.writeInt(aid.getLocalId());
    dos.writeInt(tid.getPartition());
    dos.writeInt(taId.getAttempt());
}
Also used : OperatorDescriptorId(org.apache.hyracks.api.dataflow.OperatorDescriptorId) TaskId(org.apache.hyracks.api.dataflow.TaskId) ActivityId(org.apache.hyracks.api.dataflow.ActivityId)

Example 12 with ActivityId

use of org.apache.hyracks.api.dataflow.ActivityId in project asterixdb by apache.

the class CCNCFunctions method readTaskAttemptId.

private static TaskAttemptId readTaskAttemptId(DataInputStream dis) throws IOException {
    int odid = dis.readInt();
    int aid = dis.readInt();
    int partition = dis.readInt();
    int attempt = dis.readInt();
    TaskAttemptId taId = new TaskAttemptId(new TaskId(new ActivityId(new OperatorDescriptorId(odid), aid), partition), attempt);
    return taId;
}
Also used : OperatorDescriptorId(org.apache.hyracks.api.dataflow.OperatorDescriptorId) TaskId(org.apache.hyracks.api.dataflow.TaskId) TaskAttemptId(org.apache.hyracks.api.dataflow.TaskAttemptId) ActivityId(org.apache.hyracks.api.dataflow.ActivityId)

Example 13 with ActivityId

use of org.apache.hyracks.api.dataflow.ActivityId in project asterixdb by apache.

the class AbstractSorterOperatorDescriptor method contributeActivities.

@Override
public void contributeActivities(IActivityGraphBuilder builder) {
    SortActivity sa = getSortActivity(new ActivityId(odId, SORT_ACTIVITY_ID));
    MergeActivity ma = getMergeActivity(new ActivityId(odId, MERGE_ACTIVITY_ID));
    builder.addActivity(this, sa);
    builder.addSourceEdge(0, sa, 0);
    builder.addActivity(this, ma);
    builder.addTargetEdge(0, ma, 0);
    builder.addBlockingEdge(sa, ma);
}
Also used : ActivityId(org.apache.hyracks.api.dataflow.ActivityId)

Example 14 with ActivityId

use of org.apache.hyracks.api.dataflow.ActivityId in project asterixdb by apache.

the class JobExecutor method assignLocation.

private String assignLocation(ActivityClusterGraph acg, Map<TaskId, LValueConstraintExpression> locationMap, TaskId tid, TaskAttempt taskAttempt) throws HyracksException {
    ActivityId aid = tid.getActivityId();
    ActivityCluster ac = acg.getActivityMap().get(aid);
    Set<ActivityId> blockers = ac.getBlocked2BlockerMap().get(aid);
    String nodeId = null;
    if (blockers != null) {
        for (ActivityId blocker : blockers) {
            nodeId = findTaskLocation(new TaskId(blocker, tid.getPartition()));
            if (nodeId != null) {
                break;
            }
        }
    }
    INodeManager nodeManager = ccs.getNodeManager();
    Collection<String> liveNodes = nodeManager.getAllNodeIds();
    if (nodeId == null) {
        LValueConstraintExpression pLocationExpr = locationMap.get(tid);
        Object location = solver.getValue(pLocationExpr);
        if (location == null) {
            // pick any
            nodeId = liveNodes.toArray(new String[liveNodes.size()])[random.nextInt(1) % liveNodes.size()];
        } else if (location instanceof String) {
            nodeId = (String) location;
        } else if (location instanceof String[]) {
            for (String choice : (String[]) location) {
                if (liveNodes.contains(choice)) {
                    nodeId = choice;
                    break;
                }
            }
            if (nodeId == null) {
                throw new HyracksException("No satisfiable location found for " + taskAttempt.getTaskAttemptId());
            }
        } else {
            throw new HyracksException("Unknown type of value for " + pLocationExpr + ": " + location + "(" + location.getClass() + ")");
        }
    }
    if (nodeId == null) {
        throw new HyracksException("No satisfiable location found for " + taskAttempt.getTaskAttemptId());
    }
    if (!liveNodes.contains(nodeId)) {
        throw new HyracksException("Node " + nodeId + " not live");
    }
    return nodeId;
}
Also used : INodeManager(org.apache.hyracks.control.cc.cluster.INodeManager) LValueConstraintExpression(org.apache.hyracks.api.constraints.expressions.LValueConstraintExpression) TaskId(org.apache.hyracks.api.dataflow.TaskId) ActivityId(org.apache.hyracks.api.dataflow.ActivityId) HyracksException(org.apache.hyracks.api.exceptions.HyracksException) ActivityCluster(org.apache.hyracks.api.job.ActivityCluster)

Example 15 with ActivityId

use of org.apache.hyracks.api.dataflow.ActivityId 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)

Aggregations

ActivityId (org.apache.hyracks.api.dataflow.ActivityId)46 TaskId (org.apache.hyracks.api.dataflow.TaskId)12 HashMap (java.util.HashMap)11 IConnectorDescriptor (org.apache.hyracks.api.dataflow.IConnectorDescriptor)11 ActivityCluster (org.apache.hyracks.api.job.ActivityCluster)11 IActivity (org.apache.hyracks.api.dataflow.IActivity)9 Task (org.apache.hyracks.control.cc.job.Task)9 ArrayList (java.util.ArrayList)8 ConnectorDescriptorId (org.apache.hyracks.api.dataflow.ConnectorDescriptorId)7 OperatorDescriptorId (org.apache.hyracks.api.dataflow.OperatorDescriptorId)7 HashSet (java.util.HashSet)6 List (java.util.List)6 Pair (org.apache.commons.lang3.tuple.Pair)6 ActivityClusterGraph (org.apache.hyracks.api.job.ActivityClusterGraph)6 HyracksException (org.apache.hyracks.api.exceptions.HyracksException)5 ActivityPlan (org.apache.hyracks.control.cc.job.ActivityPlan)5 TaskCluster (org.apache.hyracks.control.cc.job.TaskCluster)5 IOperatorNodePushable (org.apache.hyracks.api.dataflow.IOperatorNodePushable)4 TaskAttemptId (org.apache.hyracks.api.dataflow.TaskAttemptId)4 IConnectorPolicy (org.apache.hyracks.api.dataflow.connectors.IConnectorPolicy)4