use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestKDtreeSpacePartitioner method testDistributionRegionSplitWithZookeeperPropergate2.
/**
* Test the distribution of changes in the zookeeper structure (reading data from the second object)
* @throws ZookeeperException
* @throws InterruptedException
* @throws ZookeeperNotFoundException
* @throws BBoxDBException
* @throws ResourceAllocationException
*/
@Test(timeout = 60000)
public void testDistributionRegionSplitWithZookeeperPropergate2() throws Exception {
System.out.println("== Build KD adapter 1");
final KDtreeSpacePartitioner adapter1 = (KDtreeSpacePartitioner) getSpacePartitioner();
final DistributionRegion distributionGroup1 = adapter1.getRootNode();
Assert.assertEquals(2, distributionGroup1.getConveringBox().getDimension());
System.out.println("== Build KD adapter 2");
final KDtreeSpacePartitioner adapter2 = (KDtreeSpacePartitioner) getSpacePartitioner();
final DistributionRegion distributionGroup2 = adapter2.getRootNode();
Assert.assertEquals(2, distributionGroup2.getConveringBox().getDimension());
Assert.assertEquals(0, distributionGroup1.getLevel());
// Update object 1
adapter1.splitNode(distributionGroup1, 10);
final DistributionRegion leftChild = distributionGroup1.getDirectChildren().get(0);
Assert.assertEquals(1, leftChild.getLevel());
Assert.assertEquals(1, adapter2.getSplitDimension(leftChild));
adapter1.splitNode(leftChild, 50);
// Sleep 2 seconds to wait for the update
adapter2.waitForSplitCompleteZookeeperCallback(leftChild, 2);
// Read update from the second object
final DistributionRegion firstChild = distributionGroup2.getDirectChildren().get(0);
Assert.assertEquals(10.0, firstChild.getConveringBox().getCoordinateHigh(0), DELTA);
final DistributionRegion secondChild = firstChild.getDirectChildren().get(0);
Assert.assertEquals(50.0, secondChild.getConveringBox().getCoordinateHigh(1), DELTA);
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestQuadtreeSpacePartitioner method testSplit0.
@Test(timeout = 60000)
public void testSplit0() throws ZookeeperException, ZookeeperNotFoundException, BBoxDBException, ResourceAllocationException {
final QuadtreeSpacePartitioner spacepartitionier = getSpacePartitioner();
final DistributionRegion rootNode = spacepartitionier.getRootNode();
Assert.assertEquals(0, rootNode.getDirectChildren().size());
spacepartitionier.splitRegion(rootNode, new HashSet<>());
Assert.assertEquals(4, rootNode.getDirectChildren().size());
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestQuadtreeSpacePartitioner method testSplit1.
@Test(timeout = 60000)
public void testSplit1() throws ZookeeperException, ZookeeperNotFoundException, BBoxDBException, ResourceAllocationException {
final QuadtreeSpacePartitioner spacepartitionier = getSpacePartitioner();
final DistributionRegion rootNode = spacepartitionier.getRootNode();
Assert.assertEquals(0, rootNode.getDirectChildren().size());
spacepartitionier.splitRegion(rootNode, new HashSet<>());
Assert.assertEquals(4, rootNode.getDirectChildren().size());
final DistributionRegion child1 = rootNode.getChildNumber(1);
spacepartitionier.splitRegion(child1, new HashSet<>());
Assert.assertEquals(4, child1.getDirectChildren().size());
Assert.assertEquals(8, rootNode.getAllChildren().size());
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestStaticgridSpacePartitioner method testRootElement.
@Test(timeout = 60000)
public void testRootElement() throws ZookeeperException, ZookeeperNotFoundException, BBoxDBException {
final StaticgridSpacePartitioner 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 TestStaticgridSpacePartitioner method createGridCells.
@Test(timeout = 60000)
public void createGridCells() throws ZookeeperException, ZookeeperNotFoundException, BBoxDBException {
final StaticgridSpacePartitioner 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(120, regions);
}
Aggregations