Search in sources :

Example 16 with DistributionRegion

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

Example 17 with DistributionRegion

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

Example 18 with DistributionRegion

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

Example 19 with DistributionRegion

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

Example 20 with DistributionRegion

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