use of org.bboxdb.distribution.partitioner.KDtreeSpacePartitioner 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.partitioner.KDtreeSpacePartitioner in project bboxdb by jnidzwetzki.
the class TestSpacePartitionerCache method testRootNodeRefresh.
@Test(timeout = 60000)
public void testRootNodeRefresh() throws Exception {
final DistributionGroupConfiguration configuration = DistributionGroupConfigurationBuilder.create(2).withPlacementStrategy("org.bboxdb.distribution.placement.DummyResourcePlacementStrategy", "").build();
distributionGroupZookeeperAdapter.deleteDistributionGroup(TEST_GROUP);
distributionGroupZookeeperAdapter.createDistributionGroup(TEST_GROUP, configuration);
final KDtreeSpacePartitioner oldSpacepartitionier = (KDtreeSpacePartitioner) SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(TEST_GROUP);
final DistributionRegion oldRootNode = oldSpacepartitionier.getRootNode();
final DistributionRegionIdMapper mapper = oldSpacepartitionier.getDistributionRegionIdMapper();
Assert.assertEquals(0, mapper.getAllRegionIds().size());
mapper.addMapping(3, BoundingBox.FULL_SPACE);
Assert.assertEquals(1, mapper.getAllRegionIds().size());
distributionGroupZookeeperAdapter.deleteDistributionGroup(TEST_GROUP);
distributionGroupZookeeperAdapter.createDistributionGroup(TEST_GROUP, configuration);
final KDtreeSpacePartitioner newSpacepartitionier1 = (KDtreeSpacePartitioner) SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(TEST_GROUP);
final DistributionRegion newRootNode = newSpacepartitionier1.getRootNode();
Assert.assertFalse(oldRootNode == newRootNode);
Assert.assertEquals(0, mapper.getAllRegionIds().size());
distributionGroupZookeeperAdapter.deleteDistributionGroup(TEST_GROUP);
distributionGroupZookeeperAdapter.createDistributionGroup(TEST_GROUP, configuration);
Thread.sleep(1000);
final KDtreeSpacePartitioner newSpacepartitionier2 = (KDtreeSpacePartitioner) SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(TEST_GROUP);
final DistributionRegion newRootNode2 = newSpacepartitionier2.getRootNode();
Assert.assertFalse(newRootNode2 == newRootNode);
}
Aggregations