use of org.bboxdb.distribution.region.DistributionRegion 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.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestDynamicgridSpacePartitioner method testRootElement.
@Test(timeout = 60000)
public void testRootElement() throws ZookeeperException, ZookeeperNotFoundException, BBoxDBException {
final DynamicgridSpacePartitioner spacePartitioner = getSpacePartitioner();
final DistributionRegion rootElement = spacePartitioner.getRootNode();
Assert.assertEquals(rootElement.getState(), DistributionRegionState.SPLIT);
final BoundingBox box = rootElement.getConveringBox();
Assert.assertEquals(new BoundingBox(0.0, 5.0, 0.0, 6.0), box);
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestDynamicgridSpacePartitioner method createGridCells.
@Test(timeout = 60000)
public void createGridCells() throws ZookeeperException, ZookeeperNotFoundException, BBoxDBException {
final DynamicgridSpacePartitioner spacePartitioner = getSpacePartitioner();
final DistributionRegion rootElement = spacePartitioner.getRootNode();
final long regions = rootElement.getThisAndChildRegions().stream().map(r -> r.getState()).filter(DistributionRegionHelper.PREDICATE_REGIONS_FOR_WRITE).count();
Assert.assertEquals(12, regions);
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestKDtreeSpacePartitioner method testGetMergeCandidates.
/**
* Test get merge candidates
* @throws BBoxDBException
* @throws ZookeeperException
* @throws ZookeeperNotFoundException
* @throws ResourceAllocationException
*/
@Test(timeout = 60000)
public void testGetMergeCandidates() throws ZookeeperException, BBoxDBException, ZookeeperNotFoundException, ResourceAllocationException {
createNewDistributionGroup(2);
final KDtreeSpacePartitioner spacepartitionier = getSpacePartitioner();
final DistributionRegion rootNode = spacepartitionier.getRootNode();
spacepartitionier.splitNode(rootNode, 10);
spacepartitionier.waitForSplitCompleteZookeeperCallback(rootNode, 2);
spacepartitionier.splitComplete(rootNode, rootNode.getDirectChildren());
spacepartitionier.waitUntilNodeStateIs(rootNode, DistributionRegionState.SPLIT);
Assert.assertEquals(rootNode.getState(), DistributionRegionState.SPLIT);
final DistributionRegion childNumber0 = rootNode.getChildNumber(0);
final DistributionRegion childNumber1 = rootNode.getChildNumber(1);
Assert.assertTrue(spacepartitionier.getMergeCandidates(childNumber0).isEmpty());
Assert.assertTrue(spacepartitionier.getMergeCandidates(childNumber1).isEmpty());
spacepartitionier.splitNode(childNumber0, 10);
spacepartitionier.waitForSplitCompleteZookeeperCallback(childNumber0, 2);
spacepartitionier.splitComplete(childNumber0, childNumber0.getDirectChildren());
spacepartitionier.waitUntilNodeStateIs(childNumber0, DistributionRegionState.SPLIT);
Assert.assertEquals(childNumber0.getState(), DistributionRegionState.SPLIT);
Assert.assertTrue(spacepartitionier.getMergeCandidates(childNumber0.getChildNumber(0)).isEmpty());
Assert.assertTrue(spacepartitionier.getMergeCandidates(childNumber0.getChildNumber(1)).isEmpty());
final List<List<DistributionRegion>> mergeCandidates0 = spacepartitionier.getMergeCandidates(childNumber0);
Assert.assertFalse(mergeCandidates0.isEmpty());
Assert.assertTrue(spacepartitionier.getMergeCandidates(childNumber1).isEmpty());
for (final List<DistributionRegion> regions : mergeCandidates0) {
Assert.assertTrue(regions.size() == 2);
}
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestQuadtreeSpacePartitioner method testRestrictedSpace.
/**
* Test the restricted space
* @throws ZookeeperException
* @throws BBoxDBException
* @throws ZookeeperNotFoundException
*/
@Test(timeout = 60000)
public void testRestrictedSpace() throws ZookeeperException, BBoxDBException, ZookeeperNotFoundException {
final BoundingBox completeSpace = new BoundingBox(0d, 10d, 0d, 10d);
final DistributionGroupConfiguration configuration = DistributionGroupConfigurationBuilder.create(2).withSpacePartitioner("org.bboxdb.distribution.partitioner.QuadtreeSpacePartitioner", completeSpace.toCompactString()).withPlacementStrategy("org.bboxdb.distribution.placement.DummyResourcePlacementStrategy", "").build();
distributionGroupZookeeperAdapter.deleteDistributionGroup(TEST_GROUP);
distributionGroupZookeeperAdapter.createDistributionGroup(TEST_GROUP, configuration);
final QuadtreeSpacePartitioner spacepartitionier = getSpacePartitioner();
final DistributionRegion rootNode = spacepartitionier.getRootNode();
Assert.assertEquals(completeSpace, rootNode.getConveringBox());
spacepartitionier.splitRegion(rootNode, new HashSet<>());
Assert.assertEquals("[[0.0,5.0):[0.0,5.0)]", rootNode.getChildNumber(0).getConveringBox().toCompactString());
Assert.assertEquals("[[5.0,10.0]:[0.0,5.0)]", rootNode.getChildNumber(1).getConveringBox().toCompactString());
Assert.assertEquals("[[0.0,5.0):[5.0,10.0]]", rootNode.getChildNumber(2).getConveringBox().toCompactString());
Assert.assertEquals("[[5.0,10.0]:[5.0,10.0]]", rootNode.getChildNumber(3).getConveringBox().toCompactString());
}
Aggregations