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;
}
}
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);
}
}
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);
}
}
}
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
}
}
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);
}
}
Aggregations