use of org.apache.hyracks.control.common.job.PartitionRequest in project asterixdb by apache.
the class RegisterPartitionAvailibilityWork method run.
@Override
public void run() {
final PartitionId pid = partitionDescriptor.getPartitionId();
IJobManager jobManager = ccs.getJobManager();
JobRun run = jobManager.get(pid.getJobId());
if (run == null) {
return;
}
PartitionMatchMaker pmm = run.getPartitionMatchMaker();
List<Pair<PartitionDescriptor, PartitionRequest>> matches = pmm.registerPartitionDescriptor(partitionDescriptor);
for (Pair<PartitionDescriptor, PartitionRequest> match : matches) {
try {
PartitionUtils.reportPartitionMatch(ccs, pid, match);
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of org.apache.hyracks.control.common.job.PartitionRequest in project asterixdb by apache.
the class PartitionMatchMaker method registerPartitionDescriptor.
public List<Pair<PartitionDescriptor, PartitionRequest>> registerPartitionDescriptor(PartitionDescriptor partitionDescriptor) {
List<Pair<PartitionDescriptor, PartitionRequest>> matches = new ArrayList<Pair<PartitionDescriptor, PartitionRequest>>();
PartitionId pid = partitionDescriptor.getPartitionId();
boolean matched = false;
List<PartitionRequest> requests = partitionRequests.get(pid);
if (requests != null) {
Iterator<PartitionRequest> i = requests.iterator();
while (i.hasNext()) {
PartitionRequest req = i.next();
if (partitionDescriptor.getState().isAtLeast(req.getMinimumState())) {
matches.add(Pair.<PartitionDescriptor, PartitionRequest>of(partitionDescriptor, req));
i.remove();
matched = true;
if (!partitionDescriptor.isReusable()) {
break;
}
}
}
if (requests.isEmpty()) {
partitionRequests.remove(pid);
}
}
if (!matched) {
List<PartitionDescriptor> descriptors = partitionDescriptors.get(pid);
if (descriptors == null) {
descriptors = new ArrayList<PartitionDescriptor>();
partitionDescriptors.put(pid, descriptors);
}
descriptors.add(partitionDescriptor);
}
return matches;
}
use of org.apache.hyracks.control.common.job.PartitionRequest in project asterixdb by apache.
the class PartitionMatchMaker method removePartitionRequests.
public void removePartitionRequests(Set<PartitionId> partitionIds, final Set<TaskAttemptId> taIds) {
LOGGER.info("Removing partition requests: " + partitionIds);
IEntryFilter<PartitionRequest> filter = new IEntryFilter<PartitionRequest>() {
@Override
public boolean matches(PartitionRequest o) {
return taIds.contains(o.getRequestingTaskAttemptId());
}
};
for (PartitionId pid : partitionIds) {
List<PartitionRequest> requests = partitionRequests.get(pid);
if (requests != null) {
removeEntries(requests, filter);
if (requests.isEmpty()) {
partitionRequests.remove(pid);
}
}
}
}
use of org.apache.hyracks.control.common.job.PartitionRequest in project asterixdb by apache.
the class Joblet method advertisePartitionRequest.
public synchronized void advertisePartitionRequest(TaskAttemptId taId, Collection<PartitionId> pids, IPartitionCollector collector, PartitionState minState) throws Exception {
for (PartitionId pid : pids) {
partitionRequestMap.put(pid, collector);
PartitionRequest req = new PartitionRequest(pid, nodeController.getId(), taId, minState);
nodeController.getClusterController().registerPartitionRequest(req);
}
}
use of org.apache.hyracks.control.common.job.PartitionRequest in project asterixdb by apache.
the class PartitionUtils method reportPartitionMatch.
public static void reportPartitionMatch(ClusterControllerService ccs, final PartitionId pid, Pair<PartitionDescriptor, PartitionRequest> match) throws Exception {
PartitionDescriptor desc = match.getLeft();
PartitionRequest req = match.getRight();
INodeManager nodeManager = ccs.getNodeManager();
NodeControllerState producerNCS = nodeManager.getNodeControllerState(desc.getNodeId());
NodeControllerState requestorNCS = nodeManager.getNodeControllerState(req.getNodeId());
final NetworkAddress dataport = producerNCS.getDataPort();
final INodeController requestorNC = requestorNCS.getNodeController();
requestorNC.reportPartitionAvailability(pid, dataport);
}
Aggregations