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);
}
}
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();
}
}
}
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;
}
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);
}
}
}
}
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);
}
Aggregations