Search in sources :

Example 21 with DistributionRegion

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);
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) KDtreeSpacePartitioner(org.bboxdb.distribution.partitioner.KDtreeSpacePartitioner) Test(org.junit.Test)

Example 22 with DistributionRegion

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());
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) QuadtreeSpacePartitioner(org.bboxdb.distribution.partitioner.QuadtreeSpacePartitioner) Test(org.junit.Test)

Example 23 with DistributionRegion

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());
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) QuadtreeSpacePartitioner(org.bboxdb.distribution.partitioner.QuadtreeSpacePartitioner) Test(org.junit.Test)

Example 24 with DistributionRegion

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);
}
Also used : StaticgridSpacePartitioner(org.bboxdb.distribution.partitioner.StaticgridSpacePartitioner) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BoundingBox(org.bboxdb.commons.math.BoundingBox) Test(org.junit.Test)

Example 25 with DistributionRegion

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);
}
Also used : StaticgridSpacePartitioner(org.bboxdb.distribution.partitioner.StaticgridSpacePartitioner) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) Test(org.junit.Test)

Aggregations

DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)91 Test (org.junit.Test)45 BBoxDBException (org.bboxdb.misc.BBoxDBException)34 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)33 BoundingBox (org.bboxdb.commons.math.BoundingBox)27 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)23 ArrayList (java.util.ArrayList)17 List (java.util.List)17 SpacePartitioner (org.bboxdb.distribution.partitioner.SpacePartitioner)16 DistributionRegionAdapter (org.bboxdb.distribution.zookeeper.DistributionRegionAdapter)15 DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)15 KDtreeSpacePartitioner (org.bboxdb.distribution.partitioner.KDtreeSpacePartitioner)14 DistributionGroupAdapter (org.bboxdb.distribution.zookeeper.DistributionGroupAdapter)11 ZookeeperClientFactory (org.bboxdb.distribution.zookeeper.ZookeeperClientFactory)11 DistributionRegionState (org.bboxdb.distribution.partitioner.DistributionRegionState)10 DistributionRegionIdMapper (org.bboxdb.distribution.region.DistributionRegionIdMapper)10 DistributionRegionSyncer (org.bboxdb.distribution.region.DistributionRegionSyncer)10 RoutingHeader (org.bboxdb.network.routing.RoutingHeader)10 RoutingHop (org.bboxdb.network.routing.RoutingHop)10 DistributionGroupConfigurationBuilder (org.bboxdb.storage.entity.DistributionGroupConfigurationBuilder)10