Search in sources :

Example 61 with BBoxDBException

use of org.bboxdb.misc.BBoxDBException 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 62 with BBoxDBException

use of org.bboxdb.misc.BBoxDBException 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 63 with BBoxDBException

use of org.bboxdb.misc.BBoxDBException 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)

Example 64 with BBoxDBException

use of org.bboxdb.misc.BBoxDBException in project bboxdb by jnidzwetzki.

the class BenchmarkFileInsertPerformance method handleLine.

/**
 * Handle a line from the input file
 * @param line
 * @throws BBoxDBException
 */
protected void handleLine(String line) {
    try {
        final Polygon polygon = Polygon.fromGeoJson(line);
        final byte[] tupleBytes = polygon.toGeoJson().getBytes();
        final Tuple tuple = new Tuple(Long.toString(polygon.getId()), polygon.getBoundingBox(), tupleBytes);
        final EmptyResultFuture insertFuture = bboxdbClient.insertTuple(table, tuple);
        // register pending future
        pendingFutures.put(insertFuture);
        insertedTuples.incrementAndGet();
    } catch (BBoxDBException e) {
        System.err.println("Got an exeption while reading file: " + e);
        System.exit(-1);
    }
}
Also used : Polygon(org.bboxdb.tools.converter.osm.util.Polygon) BBoxDBException(org.bboxdb.misc.BBoxDBException) Tuple(org.bboxdb.storage.entity.Tuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Aggregations

BBoxDBException (org.bboxdb.misc.BBoxDBException)64 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)24 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)22 BoundingBox (org.bboxdb.commons.math.BoundingBox)17 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)14 SpacePartitioner (org.bboxdb.distribution.partitioner.SpacePartitioner)13 ArrayList (java.util.ArrayList)12 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)12 StorageManagerException (org.bboxdb.storage.StorageManagerException)12 List (java.util.List)11 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)11 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)10 Tuple (org.bboxdb.storage.entity.Tuple)9 ResourceAllocationException (org.bboxdb.distribution.placement.ResourceAllocationException)7 RoutingHop (org.bboxdb.network.routing.RoutingHop)7 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)6 RoutingHeader (org.bboxdb.network.routing.RoutingHeader)6 RejectedException (org.bboxdb.commons.RejectedException)5 DistributionRegionIdMapper (org.bboxdb.distribution.region.DistributionRegionIdMapper)5 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)5