use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestZookeeperIntegration method testSystems.
/**
* Test the systems field
* @throws ZookeeperException
* @throws InterruptedException
* @throws ZookeeperNotFoundException
* @throws BBoxDBException
*/
@Test(timeout = 60000)
public void testSystems() throws ZookeeperException, InterruptedException, ZookeeperNotFoundException, BBoxDBException {
final BBoxDBInstance systemName = new BBoxDBInstance("192.168.1.10:5050");
final DistributionRegion region = getSpacePartitioner().getRootNode();
final String path = distributionRegionAdapter.getZookeeperPathForDistributionRegion(region);
Assert.assertEquals(1, region.getSystems().size());
distributionRegionAdapter.addSystemToDistributionRegion(path, systemName);
// Sleep 2 seconds to wait for the update
Thread.sleep(2000);
Assert.assertEquals(2, region.getSystems().size());
Assert.assertTrue(region.getSystems().contains(systemName));
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestKDtreeSpacePartitioner method testDistributionRegionSplitAndMerge.
/**
* Test the split of a distribution region
* @throws Exception
*/
@Test(timeout = 60000)
public void testDistributionRegionSplitAndMerge() throws Exception {
final DistributionRegionAdapter distributionRegionAdapter = ZookeeperClientFactory.getZookeeperClient().getDistributionRegionAdapter();
// Split and update
System.out.println("---> Get space partitioner");
final KDtreeSpacePartitioner spacePartitioner = (KDtreeSpacePartitioner) getSpacePartitioner();
System.out.println("---> Get space partitioner - DONE");
final DistributionRegion rootNode = spacePartitioner.getRootNode();
System.out.println("---> Get root node - DONE");
Assert.assertEquals(0, rootNode.getRegionId());
Assert.assertEquals(TEST_GROUP, rootNode.getDistributionGroupName());
final DistributionRegionState stateForDistributionRegion1 = distributionRegionAdapter.getStateForDistributionRegion(rootNode);
Assert.assertEquals(DistributionRegionState.ACTIVE, stateForDistributionRegion1);
System.out.println("--> Set split for node");
spacePartitioner.splitNode(rootNode, 10);
spacePartitioner.waitForSplitCompleteZookeeperCallback(rootNode, 2);
final DistributionRegion firstChild = rootNode.getDirectChildren().get(0);
Assert.assertEquals(10.0, firstChild.getConveringBox().getCoordinateHigh(0), DELTA);
final DistributionRegionState stateForDistributionRegion2 = distributionRegionAdapter.getStateForDistributionRegion(rootNode);
Assert.assertEquals(DistributionRegionState.SPLITTING, stateForDistributionRegion2);
// Reread group from zookeeper
final DistributionRegion newDistributionGroup = spacePartitioner.getRootNode();
final DistributionRegion firstChildNew = newDistributionGroup.getDirectChildren().get(0);
Assert.assertEquals(10.0, firstChildNew.getConveringBox().getCoordinateHigh(0), DELTA);
final DistributionRegionState stateForDistributionRegion3 = distributionRegionAdapter.getStateForDistributionRegion(newDistributionGroup);
Assert.assertEquals(DistributionRegionState.SPLITTING, stateForDistributionRegion3);
Assert.assertEquals(1, rootNode.getDirectChildren().get(0).getRegionId());
Assert.assertEquals(2, rootNode.getDirectChildren().get(1).getRegionId());
// Delete children
System.out.println("---> Calling prepare merge");
spacePartitioner.prepareMerge(spacePartitioner.getRootNode().getDirectChildren(), spacePartitioner.getRootNode());
System.out.println("---> Calling merge complete");
spacePartitioner.mergeComplete(spacePartitioner.getRootNode().getDirectChildren(), spacePartitioner.getRootNode());
final DistributionRegion newDistributionGroup2 = spacePartitioner.getRootNode();
final DistributionRegionState stateForDistributionRegion4 = distributionRegionAdapter.getStateForDistributionRegion(newDistributionGroup2);
Assert.assertEquals(DistributionRegionState.ACTIVE, stateForDistributionRegion4);
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestKDtreeSpacePartitioner method testDimensionsOfRootNode.
/**
* Test the root node dimensions
* @throws ZookeeperException
* @throws InterruptedException
* @throws ZookeeperNotFoundException
* @throws BBoxDBException
*/
@Test(timeout = 60000)
public void testDimensionsOfRootNode() throws ZookeeperException, InterruptedException, ZookeeperNotFoundException, BBoxDBException {
for (int i = 1; i < 2; i++) {
createNewDistributionGroup(i);
final KDtreeSpacePartitioner spacepartitionier = getSpacePartitioner();
final DistributionRegion rootNode = spacepartitionier.getRootNode();
Assert.assertEquals(i, rootNode.getConveringBox().getDimension());
}
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestKDtreeSpacePartitioner method testDistributionRegionSplitWithZookeeperPropergate.
/**
* Test the distribution of changes in the zookeeper structure (reading data from the second object)
*/
@Test(timeout = 60000)
public void testDistributionRegionSplitWithZookeeperPropergate() throws Exception {
final KDtreeSpacePartitioner adapter1 = (KDtreeSpacePartitioner) getSpacePartitioner();
final DistributionRegion distributionGroup1 = adapter1.getRootNode();
final KDtreeSpacePartitioner adapter2 = (KDtreeSpacePartitioner) getSpacePartitioner();
final DistributionRegion distributionGroup2 = adapter2.getRootNode();
// Update object 1
adapter1.splitNode(distributionGroup1, 10);
// Sleep some seconds to wait for the update
adapter2.waitForSplitCompleteZookeeperCallback(distributionGroup1, 2);
// Read update from the second object
final DistributionRegion firstChild = distributionGroup2.getDirectChildren().get(0);
Assert.assertEquals(10.0, firstChild.getConveringBox().getCoordinateHigh(0), DELTA);
// Check region ids
Assert.assertEquals(0, distributionGroup2.getRegionId());
Assert.assertEquals(1, distributionGroup2.getDirectChildren().get(0).getRegionId());
Assert.assertEquals(2, distributionGroup2.getDirectChildren().get(1).getRegionId());
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestKDtreeSpacePartitioner method testDistributionRegionLevel.
/**
* Test the distribution region level
* @throws Exception
*/
@Test(timeout = 60000)
public void testDistributionRegionLevel() throws Exception {
final KDtreeSpacePartitioner kdTreeAdapter = (KDtreeSpacePartitioner) SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(TEST_GROUP);
final DistributionRegion rootNode = kdTreeAdapter.getRootNode();
Assert.assertEquals(1, rootNode.getTotalLevel());
Assert.assertEquals(0, rootNode.getLevel());
kdTreeAdapter.splitNode(rootNode, (float) 20.0);
kdTreeAdapter.waitForSplitCompleteZookeeperCallback(rootNode, 2);
Assert.assertEquals(2, rootNode.getTotalLevel());
for (final DistributionRegion region : rootNode.getAllChildren()) {
Assert.assertEquals(2, region.getTotalLevel());
Assert.assertEquals(1, region.getLevel());
}
}
Aggregations