use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestRegionSyncer method createSplittedRoot.
/**
* Create a splitted root
* @param distributionRegionSyncer
* @param root
* @return
* @throws ZookeeperException
* @throws InterruptedException
*/
private String createSplittedRoot(final DistributionRegionSyncer distributionRegionSyncer, final DistributionRegion root) throws ZookeeperException, InterruptedException {
final BoundingBox leftBoundingBox = root.getConveringBox().splitAndGetLeft(0, 0, true);
final BoundingBox rightBoundingBox = root.getConveringBox().splitAndGetRight(0, 0, true);
final String regionPath = distributionRegionAdapter.getZookeeperPathForDistributionRegion(root);
final CountDownLatch latchLevel0 = new CountDownLatch(1);
final DistributionRegionCallback level0Callback = (e, r) -> {
if (root.getDirectChildren().size() == 2) {
latchLevel0.countDown();
}
};
distributionRegionSyncer.registerCallback(level0Callback);
distributionRegionAdapter.createNewChild(regionPath, 0, leftBoundingBox, GROUP);
distributionRegionAdapter.createNewChild(regionPath, 1, rightBoundingBox, GROUP);
latchLevel0.await();
distributionRegionSyncer.unregisterCallback(level0Callback);
Assert.assertEquals(2, root.getDirectChildren().size());
Assert.assertTrue(root.getChildNumber(0) != null);
Assert.assertTrue(root.getChildNumber(1) != null);
return GROUP;
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestRegionSyncer method getExistingRoot.
@Test(timeout = 60000)
public void getExistingRoot() throws ZookeeperException {
final DistributionRegionSyncer distributionRegionSyncer = buildSyncer();
final DistributionRegion root = distributionRegionSyncer.getRootNode();
Assert.assertTrue(root != null);
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestRegionSyncer method getNonExistingRoot.
@Test(timeout = 60000)
public void getNonExistingRoot() throws ZookeeperException {
distributionGroupAdapter.deleteDistributionGroup(GROUP);
final DistributionRegionSyncer distributionRegionSyncer = buildSyncer();
final DistributionRegion root = distributionRegionSyncer.getRootNode();
Assert.assertEquals(null, root);
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestRegionSyncer method waitForSystemsCallback.
@Test(timeout = 10000)
public void waitForSystemsCallback() throws ZookeeperException, InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final DistributionRegionSyncer distributionRegionSyncer = buildSyncer();
final DistributionRegion root = distributionRegionSyncer.getRootNode();
Assert.assertEquals(0, root.getHighestChildNumber());
final DistributionRegionCallback callback = (e, r) -> {
if (r.equals(root)) {
latch.countDown();
}
};
distributionRegionSyncer.registerCallback(callback);
final BBoxDBInstance newInstance = new BBoxDBInstance("localhost:8443");
final String path = distributionRegionAdapter.getZookeeperPathForDistributionRegion(root);
distributionRegionAdapter.addSystemToDistributionRegion(path, newInstance);
latch.await();
distributionRegionSyncer.unregisterCallback(callback);
Assert.assertTrue(root.getSystems().contains(newInstance));
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestSampling method testSampling2.
/**
* Test the sampling (without tuples)
* @throws RejectedException
* @throws StorageManagerException
* @throws BBoxDBException
*/
@Test(timeout = 60000)
public void testSampling2() throws StorageManagerException, RejectedException, BBoxDBException {
storageRegistry.createTable(TEST_RELATION, new TupleStoreConfiguration());
final DistributionRegion rootNode = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(TEST_GROUP).getRootNode();
final Collection<BoundingBox> samples = SamplingHelper.getSamplesForRegion(rootNode, storageRegistry);
Assert.assertTrue(samples.isEmpty());
}
Aggregations