use of org.apache.hyracks.control.common.job.PartitionDescriptor in project asterixdb by apache.
the class PartitionMatchMaker method matchPartitionRequest.
public Pair<PartitionDescriptor, PartitionRequest> matchPartitionRequest(PartitionRequest partitionRequest) {
Pair<PartitionDescriptor, PartitionRequest> match = null;
PartitionId pid = partitionRequest.getPartitionId();
List<PartitionDescriptor> descriptors = partitionDescriptors.get(pid);
if (descriptors != null) {
Iterator<PartitionDescriptor> i = descriptors.iterator();
while (i.hasNext()) {
PartitionDescriptor descriptor = i.next();
if (descriptor.getState().isAtLeast(partitionRequest.getMinimumState())) {
match = Pair.<PartitionDescriptor, PartitionRequest>of(descriptor, partitionRequest);
if (!descriptor.isReusable()) {
i.remove();
}
break;
}
}
if (descriptors.isEmpty()) {
partitionDescriptors.remove(pid);
}
}
if (match == null) {
List<PartitionRequest> requests = partitionRequests.get(pid);
if (requests == null) {
requests = new ArrayList<PartitionRequest>();
partitionRequests.put(pid, requests);
}
requests.add(partitionRequest);
}
return match;
}
use of org.apache.hyracks.control.common.job.PartitionDescriptor in project asterixdb by apache.
the class RegisterPartitionRequestWork method run.
@Override
public void run() {
PartitionId pid = partitionRequest.getPartitionId();
IJobManager jobManager = ccs.getJobManager();
JobRun run = jobManager.get(pid.getJobId());
if (run == null) {
return;
}
PartitionMatchMaker pmm = run.getPartitionMatchMaker();
Pair<PartitionDescriptor, PartitionRequest> match = pmm.matchPartitionRequest(partitionRequest);
if (match != null) {
try {
PartitionUtils.reportPartitionMatch(ccs, pid, match);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Aggregations