Search in sources :

Example 6 with PartitionDescriptor

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;
}
Also used : PartitionRequest(org.apache.hyracks.control.common.job.PartitionRequest) PartitionDescriptor(org.apache.hyracks.control.common.job.PartitionDescriptor) PartitionId(org.apache.hyracks.api.partitions.PartitionId)

Example 7 with PartitionDescriptor

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();
        }
    }
}
Also used : PartitionRequest(org.apache.hyracks.control.common.job.PartitionRequest) PartitionDescriptor(org.apache.hyracks.control.common.job.PartitionDescriptor) IJobManager(org.apache.hyracks.control.cc.job.IJobManager) PartitionMatchMaker(org.apache.hyracks.control.cc.partitions.PartitionMatchMaker) PartitionId(org.apache.hyracks.api.partitions.PartitionId) JobRun(org.apache.hyracks.control.cc.job.JobRun)

Aggregations

PartitionDescriptor (org.apache.hyracks.control.common.job.PartitionDescriptor)7 PartitionId (org.apache.hyracks.api.partitions.PartitionId)5 PartitionRequest (org.apache.hyracks.control.common.job.PartitionRequest)5 Pair (org.apache.commons.lang3.tuple.Pair)2 IJobManager (org.apache.hyracks.control.cc.job.IJobManager)2 JobRun (org.apache.hyracks.control.cc.job.JobRun)2 PartitionMatchMaker (org.apache.hyracks.control.cc.partitions.PartitionMatchMaker)2 ArrayList (java.util.ArrayList)1 NetworkAddress (org.apache.hyracks.api.comm.NetworkAddress)1 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)1 HyracksException (org.apache.hyracks.api.exceptions.HyracksException)1 NodeControllerState (org.apache.hyracks.control.cc.NodeControllerState)1 INodeManager (org.apache.hyracks.control.cc.cluster.INodeManager)1 INodeController (org.apache.hyracks.control.common.base.INodeController)1