Search in sources :

Example 46 with BBoxDBException

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

the class CLI method actionDeleteTable.

/**
 * Delete an existing table
 * @param line
 */
protected void actionDeleteTable(final CommandLine line) {
    if (!line.hasOption(CLIParameter.TABLE)) {
        System.err.println("Delete table should be performed, but no table was specified");
        printHelpAndExit();
    }
    try {
        final String table = line.getOptionValue(CLIParameter.TABLE);
        final EmptyResultFuture resultFuture = bboxDbConnection.deleteTable(table);
        resultFuture.waitForAll();
        if (resultFuture.isFailed()) {
            System.err.println("Unable to delete table: " + resultFuture.getAllMessages());
            System.exit(-1);
        }
    } catch (BBoxDBException e) {
        System.err.println("Got an exception while deleting table: " + e);
        System.exit(-1);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        return;
    }
}
Also used : BBoxDBException(org.bboxdb.misc.BBoxDBException) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 47 with BBoxDBException

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

the class CLI method actionDeleteDgroup.

/**
 * Delete a distribution group
 * @param line
 */
protected void actionDeleteDgroup(final CommandLine line) {
    final List<String> requiredArgs = Arrays.asList(CLIParameter.DISTRIBUTION_GROUP);
    checkRequiredArgs(requiredArgs);
    final String distributionGroup = line.getOptionValue(CLIParameter.DISTRIBUTION_GROUP);
    System.out.println("Deleting distribution group: " + distributionGroup);
    try {
        final EmptyResultFuture future = bboxDbConnection.deleteDistributionGroup(distributionGroup);
        future.waitForAll();
        if (future.isFailed()) {
            System.err.println("Got an error during distribution group deletion: " + future.getAllMessages());
        }
    } catch (BBoxDBException e) {
        System.err.println("Got an exception during distribution group creation: " + e);
        System.exit(-1);
    } catch (InterruptedException e) {
        System.err.println("Waiting was interrupted");
        System.exit(-1);
    }
}
Also used : BBoxDBException(org.bboxdb.misc.BBoxDBException) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 48 with BBoxDBException

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

the class TupleStoreZookeeperObserver method registerTable.

/**
 * Register a new table, a callback is registered on the space partitioner
 * to delete the table when it is split or merged
 *
 * @param tupleStoreName
 */
public void registerTable(final TupleStoreName tupleStoreName) {
    if (!tupleStoreName.isDistributedTable()) {
        return;
    }
    final String distributionGroup = tupleStoreName.getDistributionGroup();
    final DistributionRegionEntity tableEntity = new DistributionRegionEntity(distributionGroup, tupleStoreName.getRegionId().getAsLong());
    synchronized (knownRegions) {
        if (knownRegions.contains(tableEntity)) {
            return;
        }
        // Register callback
        final DistributionRegionCallback callback = (e, r) -> {
            handleCallback(tableEntity, e, r);
        };
        try {
            final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(distributionGroup);
            spacePartitioner.registerCallback(callback);
            knownRegions.add(tableEntity);
        } catch (BBoxDBException e) {
            logger.error("Unable to register callback", e);
        }
    }
}
Also used : DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner) ZookeeperClientFactory(org.bboxdb.distribution.zookeeper.ZookeeperClientFactory) Logger(org.slf4j.Logger) TupleStoreAdapter(org.bboxdb.distribution.zookeeper.TupleStoreAdapter) Collection(java.util.Collection) DistributionRegionCallback(org.bboxdb.distribution.region.DistributionRegionCallback) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) TupleStoreConfigurationCache(org.bboxdb.distribution.TupleStoreConfigurationCache) DistributionRegionState(org.bboxdb.distribution.partitioner.DistributionRegionState) WatchedEvent(org.apache.zookeeper.WatchedEvent) ZookeeperClient(org.bboxdb.distribution.zookeeper.ZookeeperClient) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) HashSet(java.util.HashSet) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) List(java.util.List) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) DistributionRegionEvent(org.bboxdb.distribution.region.DistributionRegionEvent) BBoxDBException(org.bboxdb.misc.BBoxDBException) DistributionGroupAdapter(org.bboxdb.distribution.zookeeper.DistributionGroupAdapter) SpacePartitionerCache(org.bboxdb.distribution.partitioner.SpacePartitionerCache) StorageManagerException(org.bboxdb.storage.StorageManagerException) DistributionRegionCallback(org.bboxdb.distribution.region.DistributionRegionCallback) BBoxDBException(org.bboxdb.misc.BBoxDBException) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner)

Example 49 with BBoxDBException

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

the class TestZookeeperIntegration method testCreateAndDeleteDistributionGroup.

/**
 * Test the deletion and the creation of an instance
 * @throws Exception
 */
@Test(timeout = 60000)
public void testCreateAndDeleteDistributionGroup() throws Exception {
    final KDtreeSpacePartitioner cacheGroup = (KDtreeSpacePartitioner) SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(TEST_GROUP);
    Assert.assertTrue(cacheGroup.getRootNode().isLeafRegion());
    System.out.println("---> Split");
    final KDtreeSpacePartitioner kdTreeAdapter = (KDtreeSpacePartitioner) getSpacePartitioner();
    kdTreeAdapter.splitNode(kdTreeAdapter.getRootNode(), (float) 20.0);
    System.out.println("---> Split done");
    // Test fresh copy
    final SpacePartitioner freshGroup = getSpacePartitioner();
    final DistributionRegion firstChildFresh = freshGroup.getRootNode().getDirectChildren().get(0);
    Assert.assertEquals(20.0, firstChildFresh.getConveringBox().getCoordinateHigh(0), DELTA);
    distributionGroupZookeeperAdapter.deleteDistributionGroup(TEST_GROUP);
    // Test cached instance
    try {
        cacheGroup.getRootNode().getDirectChildren().get(0);
        // This should not happen
        Assert.assertFalse(true);
    } catch (BBoxDBException e) {
    // Unable to get root on a space partitioner after shutdown
    }
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) KDtreeSpacePartitioner(org.bboxdb.distribution.partitioner.KDtreeSpacePartitioner) BBoxDBException(org.bboxdb.misc.BBoxDBException) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner) KDtreeSpacePartitioner(org.bboxdb.distribution.partitioner.KDtreeSpacePartitioner) Test(org.junit.Test)

Example 50 with BBoxDBException

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

the class OSMOverlayPainter method drawKDTree.

/**
 * Draw the KD Tree
 * @param graphicsContext
 * @param map
 */
protected void drawKDTree(final Graphics2D graphicsContext, final JXMapViewer map) {
    try {
        // No distribution group is selected
        if (guiModel.getTreeAdapter() == null || guiModel.getTreeAdapter().getRootNode() == null) {
            return;
        }
        final DistributionRegion distributionRegion = guiModel.getTreeAdapter().getRootNode();
        final BoundingBox bbox = distributionRegion.getConveringBox();
        if (bbox.getDimension() != 2) {
            System.err.println("Unable to print dimensions: " + bbox.getDimension());
            return;
        }
        drawBoundingBox(graphicsContext, map, distributionRegion);
    } catch (BBoxDBException e) {
        logger.error("Got an exception", e);
    }
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BoundingBox(org.bboxdb.commons.math.BoundingBox) BBoxDBException(org.bboxdb.misc.BBoxDBException)

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