Search in sources :

Example 11 with ZookeeperNotFoundException

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);
    }
}
Also used : SamplingBasedSplitStrategy(org.bboxdb.distribution.partitioner.regionsplit.SamplingBasedSplitStrategy) DistributionRegionSyncerHelper(org.bboxdb.distribution.region.DistributionRegionSyncerHelper) Arrays(java.util.Arrays) Predicate(java.util.function.Predicate) Collection(java.util.Collection) SplitpointStrategy(org.bboxdb.distribution.partitioner.regionsplit.SplitpointStrategy) BoundingBox(org.bboxdb.commons.math.BoundingBox) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) ArrayList(java.util.ArrayList) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) List(java.util.List) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) InputParseException(org.bboxdb.commons.InputParseException) ResourceAllocationException(org.bboxdb.distribution.placement.ResourceAllocationException) BBoxDBException(org.bboxdb.misc.BBoxDBException) DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) MathUtil(org.bboxdb.commons.MathUtil) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BBoxDBException(org.bboxdb.misc.BBoxDBException) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) BoundingBox(org.bboxdb.commons.math.BoundingBox) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance)

Example 12 with ZookeeperNotFoundException

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);
    }
}
Also used : ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) BoundingBox(org.bboxdb.commons.math.BoundingBox) BBoxDBException(org.bboxdb.misc.BBoxDBException)

Example 13 with ZookeeperNotFoundException

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);
    }
}
Also used : DistributionGroupConfigurationCache(org.bboxdb.distribution.DistributionGroupConfigurationCache) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration)

Example 14 with ZookeeperNotFoundException

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);
    }
}
Also used : ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) BoundingBox(org.bboxdb.commons.math.BoundingBox) ResourceAllocationException(org.bboxdb.distribution.placement.ResourceAllocationException) BBoxDBException(org.bboxdb.misc.BBoxDBException)

Example 15 with ZookeeperNotFoundException

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);
    }
}
Also used : ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) DistributionRegionCallback(org.bboxdb.distribution.region.DistributionRegionCallback) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) BBoxDBException(org.bboxdb.misc.BBoxDBException)

Aggregations

ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)16 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)13 BBoxDBException (org.bboxdb.misc.BBoxDBException)8 BoundingBox (org.bboxdb.commons.math.BoundingBox)6 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)5 DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)5 ResourceAllocationException (org.bboxdb.distribution.placement.ResourceAllocationException)4 OptionalDouble (java.util.OptionalDouble)2 SamplingBasedSplitStrategy (org.bboxdb.distribution.partitioner.regionsplit.SamplingBasedSplitStrategy)2 SplitpointStrategy (org.bboxdb.distribution.partitioner.regionsplit.SplitpointStrategy)2 Cursor (java.awt.Cursor)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)1 Predicate (java.util.function.Predicate)1 Watcher (org.apache.zookeeper.Watcher)1