Search in sources :

Example 1 with PartitionRequest

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();
        }
    }
}
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) Pair(org.apache.commons.lang3.tuple.Pair)

Example 2 with PartitionRequest

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;
}
Also used : ArrayList(java.util.ArrayList) PartitionRequest(org.apache.hyracks.control.common.job.PartitionRequest) PartitionDescriptor(org.apache.hyracks.control.common.job.PartitionDescriptor) PartitionId(org.apache.hyracks.api.partitions.PartitionId) Pair(org.apache.commons.lang3.tuple.Pair)

Example 3 with PartitionRequest

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

Example 4 with PartitionRequest

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

Example 5 with PartitionRequest

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);
}
Also used : INodeManager(org.apache.hyracks.control.cc.cluster.INodeManager) NetworkAddress(org.apache.hyracks.api.comm.NetworkAddress) INodeController(org.apache.hyracks.control.common.base.INodeController) PartitionRequest(org.apache.hyracks.control.common.job.PartitionRequest) PartitionDescriptor(org.apache.hyracks.control.common.job.PartitionDescriptor) NodeControllerState(org.apache.hyracks.control.cc.NodeControllerState)

Aggregations

PartitionRequest (org.apache.hyracks.control.common.job.PartitionRequest)7 PartitionId (org.apache.hyracks.api.partitions.PartitionId)6 PartitionDescriptor (org.apache.hyracks.control.common.job.PartitionDescriptor)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 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