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());
}
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;
}
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);
}
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;
}
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();
}
Aggregations