Search in sources :

Example 1 with PartitionDescriptor

use of org.apache.hyracks.control.common.job.PartitionDescriptor in project asterixdb by apache.

the class PartitionManager method updatePartitionState.

public void updatePartitionState(PartitionId pid, TaskAttemptId taId, IPartition partition, PartitionState state) throws HyracksDataException {
    PartitionDescriptor desc = new PartitionDescriptor(pid, ncs.getId(), taId, partition.isReusable());
    desc.setState(state);
    try {
        ncs.getClusterController().registerPartitionProvider(desc);
    } catch (Exception e) {
        throw new HyracksDataException(e);
    }
}
Also used : PartitionDescriptor(org.apache.hyracks.control.common.job.PartitionDescriptor) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) HyracksException(org.apache.hyracks.api.exceptions.HyracksException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 2 with PartitionDescriptor

use of org.apache.hyracks.control.common.job.PartitionDescriptor 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 3 with PartitionDescriptor

use of org.apache.hyracks.control.common.job.PartitionDescriptor 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 4 with PartitionDescriptor

use of org.apache.hyracks.control.common.job.PartitionDescriptor in project asterixdb by apache.

the class PartitionMatchMaker method removeUncommittedPartitions.

public void removeUncommittedPartitions(Set<PartitionId> partitionIds, final Set<TaskAttemptId> taIds) {
    LOGGER.info("Removing uncommitted partitions: " + partitionIds);
    IEntryFilter<PartitionDescriptor> filter = new IEntryFilter<PartitionDescriptor>() {

        @Override
        public boolean matches(PartitionDescriptor o) {
            return o.getState() != PartitionState.COMMITTED && taIds.contains(o.getProducingTaskAttemptId());
        }
    };
    for (PartitionId pid : partitionIds) {
        List<PartitionDescriptor> descriptors = partitionDescriptors.get(pid);
        if (descriptors != null) {
            removeEntries(descriptors, filter);
            if (descriptors.isEmpty()) {
                partitionDescriptors.remove(pid);
            }
        }
    }
}
Also used : PartitionDescriptor(org.apache.hyracks.control.common.job.PartitionDescriptor) PartitionId(org.apache.hyracks.api.partitions.PartitionId)

Example 5 with PartitionDescriptor

use of org.apache.hyracks.control.common.job.PartitionDescriptor 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

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