use of org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException in project bboxdb by jnidzwetzki.
the class DynamicgridSpacePartitioner method splitNode.
/**
* Split the node at the given split point
* @param regionToSplit
* @param splitPosition
* @throws BBoxDBException
* @throws ResourceAllocationException
*/
public void splitNode(final DistributionRegion regionToSplit, final double splitPosition) throws BBoxDBException, ResourceAllocationException {
try {
logger.debug("Write split at pos {} into zookeeper", splitPosition);
final DistributionRegion parent = regionToSplit.getParent();
final String sourcePath = distributionRegionZookeeperAdapter.getZookeeperPathForDistributionRegion(regionToSplit);
final String parentPath = distributionRegionZookeeperAdapter.getZookeeperPathForDistributionRegion(parent);
// Calculate the covering bounding boxes
final BoundingBox parentBox = regionToSplit.getConveringBox();
final BoundingBox leftBoundingBox = parentBox.splitAndGetLeft(splitPosition, 0, true);
final BoundingBox rightBoundingBox = parentBox.splitAndGetRight(splitPosition, 0, false);
final String fullname = distributionGroupName;
// Only one system executes the split, therefore we can determine the child ids
final int oldNumberOfhildren = parent.getDirectChildren().size();
final long childNumber = parent.getHighestChildNumber();
final String child1Path = distributionRegionZookeeperAdapter.createNewChild(parentPath, (int) childNumber + 1, leftBoundingBox, fullname);
final String child2Path = distributionRegionZookeeperAdapter.createNewChild(parentPath, (int) childNumber + 2, rightBoundingBox, fullname);
// Update state
distributionRegionZookeeperAdapter.setStateForDistributionGroup(sourcePath, DistributionRegionState.SPLITTING);
final Predicate<DistributionRegion> predicate = (r) -> r.getDirectChildren().size() == oldNumberOfhildren + 2;
DistributionRegionSyncerHelper.waitForPredicate(predicate, regionToSplit, distributionRegionSyncer);
// The first child is stored on the same systems as the parent
SpacePartitionerHelper.copySystemsToRegion(regionToSplit.getSystems(), child1Path, zookeeperClient);
final List<BBoxDBInstance> blacklistSystems = regionToSplit.getSystems();
SpacePartitionerHelper.allocateSystemsToRegion(child2Path, fullname, blacklistSystems, zookeeperClient);
} catch (ZookeeperException | ZookeeperNotFoundException e) {
throw new BBoxDBException(e);
}
}
use of org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException in project bboxdb by jnidzwetzki.
the class KDtreeSpacePartitioner method splitNode.
/**
* Split the node at the given split point
* @param regionToSplit
* @param splitPosition
* @throws BBoxDBException
* @throws ResourceAllocationException
*/
public void splitNode(final DistributionRegion regionToSplit, final double splitPosition) throws BBoxDBException, ResourceAllocationException {
try {
logger.debug("Write split at pos {} into zookeeper", splitPosition);
final String parentPath = distributionRegionZookeeperAdapter.getZookeeperPathForDistributionRegion(regionToSplit);
// Calculate the covering bounding boxes
final BoundingBox parentBox = regionToSplit.getConveringBox();
final int splitDimension = getSplitDimension(regionToSplit);
final BoundingBox leftBoundingBox = parentBox.splitAndGetLeft(splitPosition, splitDimension, true);
final BoundingBox rightBoundingBox = parentBox.splitAndGetRight(splitPosition, splitDimension, false);
// Only one system executes the split, therefore we can determine the child ids
distributionRegionZookeeperAdapter.createNewChild(parentPath, 0, leftBoundingBox, distributionGroupName);
distributionRegionZookeeperAdapter.createNewChild(parentPath, 1, rightBoundingBox, distributionGroupName);
// Update state
distributionRegionZookeeperAdapter.setStateForDistributionGroup(parentPath, DistributionRegionState.SPLITTING);
waitUntilChildrenAreCreated(regionToSplit, 2);
allocateSystems(regionToSplit, 2);
setStateToRedistributionActiveAndWait(regionToSplit, 2);
} catch (ZookeeperException | ZookeeperNotFoundException e) {
throw new BBoxDBException(e);
}
}
use of org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException in project bboxdb by jnidzwetzki.
the class KDtreeSpacePartitioner method getDimension.
/**
* Get the dimension of the distribution region
* @return
*/
private int getDimension() {
try {
final DistributionGroupConfigurationCache instance = DistributionGroupConfigurationCache.getInstance();
final DistributionGroupConfiguration config = instance.getDistributionGroupConfiguration(distributionGroupName);
return config.getDimensions();
} catch (ZookeeperNotFoundException e) {
throw new RuntimeException(e);
}
}
use of org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException 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);
}
}
use of org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException in project bboxdb by jnidzwetzki.
the class SpacePartitionerCache method getSpacePartitionerForGroupName.
/**
* Get the distribution region for the given group name
* @param groupName
* @return
* @throws BBoxDBException
* @throws ZookeeperException
* @throws ZookeeperNotFoundException
*/
public synchronized SpacePartitioner getSpacePartitionerForGroupName(final String groupName) throws BBoxDBException {
try {
if (!spacePartitioner.containsKey(groupName)) {
final String path = zookeeperClient.getDistributionGroupAdapter().getDistributionGroupPath(groupName);
final long version = NodeMutationHelper.getNodeMutationVersion(zookeeperClient, path, this);
// Create callback list
if (!callbacks.containsKey(groupName)) {
final Set<DistributionRegionCallback> callback = new CopyOnWriteArraySet<>();
callbacks.put(groupName, callback);
}
// Create region id mapper
if (!distributionRegionIdMapper.containsKey(groupName)) {
final DistributionRegionIdMapper mapper = new DistributionRegionIdMapper(groupName);
distributionRegionIdMapper.put(groupName, mapper);
}
final SpacePartitioner adapter = zookeeperClient.getDistributionGroupAdapter().getSpaceparitioner(groupName, callbacks.get(groupName), distributionRegionIdMapper.get(groupName));
partitionerVersions.put(groupName, version);
spacePartitioner.put(groupName, adapter);
}
return spacePartitioner.get(groupName);
} catch (ZookeeperException | ZookeeperNotFoundException e) {
throw new BBoxDBException(e);
}
}
Aggregations