use of org.bboxdb.distribution.placement.ResourceAllocationException in project bboxdb by jnidzwetzki.
the class QuadtreeSpacePartitioner method splitRegion.
@Override
public List<DistributionRegion> splitRegion(final DistributionRegion regionToSplit, final Collection<BoundingBox> samples) throws BBoxDBException {
try {
logger.info("Splitting region {}", regionToSplit.getIdentifier());
final String parentPath = distributionRegionZookeeperAdapter.getZookeeperPathForDistributionRegion(regionToSplit);
final BoundingBox box = regionToSplit.getConveringBox();
final List<BoundingBox> childBoxes = createBoundingBoxes(box);
final int numberOfChilden = childBoxes.size();
for (int i = 0; i < numberOfChilden; i++) {
final BoundingBox childBox = childBoxes.get(i);
distributionRegionZookeeperAdapter.createNewChild(parentPath, i, childBox, distributionGroupName);
}
// Update state
distributionRegionZookeeperAdapter.setStateForDistributionGroup(parentPath, DistributionRegionState.SPLITTING);
waitUntilChildrenAreCreated(regionToSplit, numberOfChilden);
allocateSystems(regionToSplit, numberOfChilden);
setStateToRedistributionActiveAndWait(regionToSplit, numberOfChilden);
return regionToSplit.getDirectChildren();
} catch (ZookeeperException | ZookeeperNotFoundException | ResourceAllocationException e) {
throw new BBoxDBException(e);
}
}
Aggregations