Search in sources :

Example 11 with DistributionRegion

use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.

the class TestZookeeperIntegration method testMergingSupported.

/**
 * Test merging supported
 * @throws ZookeeperException
 * @throws BBoxDBException
 */
@Test(timeout = 60000)
public void testMergingSupported() throws ZookeeperException, BBoxDBException {
    final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(TEST_GROUP);
    final DistributionRegion rootNode = spacePartitioner.getRootNode();
    Assert.assertTrue(distributionRegionAdapter.isMergingSupported(rootNode));
    distributionRegionAdapter.setMergingSupported(rootNode, false);
    Assert.assertFalse(distributionRegionAdapter.isMergingSupported(rootNode));
    distributionRegionAdapter.setMergingSupported(rootNode, true);
    Assert.assertTrue(distributionRegionAdapter.isMergingSupported(rootNode));
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner) KDtreeSpacePartitioner(org.bboxdb.distribution.partitioner.KDtreeSpacePartitioner) Test(org.junit.Test)

Example 12 with DistributionRegion

use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.

the class TestZookeeperIntegration method testTableCreateDelete.

/**
 * Test the table deletion and creation
 * @throws ZookeeperException
 * @throws BBoxDBException
 * @throws InterruptedException
 */
@Test(timeout = 60000)
public void testTableCreateDelete() throws Exception {
    final TupleStoreAdapter tupleStoreAdapter = zookeeperClient.getTupleStoreAdapter();
    final SpacePartitioner spacePartitioner = getSpacePartitioner();
    final DistributionRegion rootNode = spacePartitioner.getRootNode();
    final String rootPath = distributionRegionAdapter.getZookeeperPathForDistributionRegion(rootNode);
    distributionRegionAdapter.addSystemToDistributionRegion(rootPath, ZookeeperClientFactory.getLocalInstanceName());
    final TupleStoreName tupleStoreName = new TupleStoreName(TEST_GROUP + "_tabletest");
    final TupleStoreName tupleStoreName0 = new TupleStoreName(TEST_GROUP + "_tabletest_0");
    final TupleStoreConfiguration configuration = TupleStoreConfigurationBuilder.create().build();
    tupleStoreAdapter.writeTuplestoreConfiguration(tupleStoreName, configuration);
    final TupleStoreManagerRegistry storageRegistry = new TupleStoreManagerRegistry();
    storageRegistry.init();
    storageRegistry.deleteTable(tupleStoreName0, true);
    storageRegistry.createTable(tupleStoreName0, configuration);
    storageRegistry.getTupleStoreManager(tupleStoreName0);
    Assert.assertTrue(storageRegistry.isStorageManagerKnown(tupleStoreName0));
    System.out.println("=== Executing deletion");
    tupleStoreAdapter.deleteTable(tupleStoreName0);
    Thread.sleep(5000);
    Assert.assertFalse(storageRegistry.isStorageManagerKnown(tupleStoreName0));
    storageRegistry.shutdown();
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) TupleStoreAdapter(org.bboxdb.distribution.zookeeper.TupleStoreAdapter) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner) KDtreeSpacePartitioner(org.bboxdb.distribution.partitioner.KDtreeSpacePartitioner) Test(org.junit.Test)

Example 13 with DistributionRegion

use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.

the class TestZookeeperIntegration method testNameprefix2.

/**
 * Test the generation of the nameprefix
 * @throws Exception
 */
@Test(timeout = 60000)
public void testNameprefix2() throws Exception {
    final KDtreeSpacePartitioner distributionGroupAdapter = (KDtreeSpacePartitioner) getSpacePartitioner();
    final DistributionRegion region = distributionGroupAdapter.getRootNode();
    distributionGroupAdapter.splitNode(region, 10);
    final DistributionRegion leftChild = region.getDirectChildren().get(0);
    final DistributionRegion rightChild = region.getDirectChildren().get(1);
    Assert.assertEquals(DistributionRegionState.REDISTRIBUTION_ACTIVE, leftChild.getState());
    Assert.assertEquals(DistributionRegionState.REDISTRIBUTION_ACTIVE, rightChild.getState());
    Assert.assertEquals(0, region.getRegionId());
    Assert.assertEquals(1, leftChild.getRegionId());
    Assert.assertEquals(2, rightChild.getRegionId());
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) KDtreeSpacePartitioner(org.bboxdb.distribution.partitioner.KDtreeSpacePartitioner) Test(org.junit.Test)

Example 14 with DistributionRegion

use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.

the class TestZookeeperIntegration method testPathDecodeAndEncode.

/**
 * Test the path decoding and encoding
 * @throws ZookeeperException
 * @throws BBoxDBException
 * @throws ZookeeperNotFoundException
 * @throws ResourceAllocationException
 */
@Test(timeout = 60000)
public void testPathDecodeAndEncode() throws ZookeeperException, BBoxDBException, ZookeeperNotFoundException, ResourceAllocationException {
    final KDtreeSpacePartitioner spacepartitionier = (KDtreeSpacePartitioner) getSpacePartitioner();
    final DistributionRegion level0 = spacepartitionier.getRootNode();
    spacepartitionier.splitNode(level0, 50);
    level0.makeChildsActive();
    // Level 1
    final DistributionRegion level1l = level0.getDirectChildren().get(0);
    spacepartitionier.splitNode(level1l, 40);
    level1l.makeChildsActive();
    final DistributionRegion level1r = level0.getDirectChildren().get(1);
    spacepartitionier.splitNode(level1r, 50);
    level1r.makeChildsActive();
    // Level 2
    final DistributionRegion level2ll = level1l.getDirectChildren().get(0);
    spacepartitionier.splitNode(level2ll, 30);
    level2ll.makeChildsActive();
    final DistributionRegion level2rl = level1r.getDirectChildren().get(0);
    spacepartitionier.splitNode(level2rl, 60);
    level2rl.makeChildsActive();
    final DistributionRegion level2lr = level1l.getDirectChildren().get(1);
    spacepartitionier.splitNode(level2lr, 30);
    level2lr.makeChildsActive();
    final DistributionRegion level2rr = level1r.getDirectChildren().get(1);
    spacepartitionier.splitNode(level2rr, 60);
    level2rr.makeChildsActive();
    // Level 3
    final DistributionRegion level3lll = level2ll.getDirectChildren().get(0);
    spacepartitionier.splitNode(level3lll, 35);
    level3lll.makeChildsActive();
    final String path0 = distributionRegionAdapter.getZookeeperPathForDistributionRegion(level0);
    final String path1 = distributionRegionAdapter.getZookeeperPathForDistributionRegion(level1l);
    final String path2 = distributionRegionAdapter.getZookeeperPathForDistributionRegion(level1r);
    final String path3 = distributionRegionAdapter.getZookeeperPathForDistributionRegion(level2ll);
    final String path4 = distributionRegionAdapter.getZookeeperPathForDistributionRegion(level2rl);
    final String path5 = distributionRegionAdapter.getZookeeperPathForDistributionRegion(level2lr);
    final String path6 = distributionRegionAdapter.getZookeeperPathForDistributionRegion(level2rr);
    final String path7 = distributionRegionAdapter.getZookeeperPathForDistributionRegion(level3lll);
    Assert.assertEquals(level0, distributionRegionAdapter.getNodeForPath(level0, path0));
    Assert.assertEquals(level1l, distributionRegionAdapter.getNodeForPath(level0, path1));
    Assert.assertEquals(level1r, distributionRegionAdapter.getNodeForPath(level0, path2));
    Assert.assertEquals(level2ll, distributionRegionAdapter.getNodeForPath(level0, path3));
    Assert.assertEquals(level2rl, distributionRegionAdapter.getNodeForPath(level0, path4));
    Assert.assertEquals(level2lr, distributionRegionAdapter.getNodeForPath(level0, path5));
    Assert.assertEquals(level2rr, distributionRegionAdapter.getNodeForPath(level0, path6));
    Assert.assertEquals(level3lll, distributionRegionAdapter.getNodeForPath(level0, path7));
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) KDtreeSpacePartitioner(org.bboxdb.distribution.partitioner.KDtreeSpacePartitioner) Test(org.junit.Test)

Example 15 with DistributionRegion

use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.

the class TestZookeeperIntegration method testSystemCheckpoint1.

/**
 * Test the set and get checkpoint methods
 * @throws ZookeeperException
 * @throws InterruptedException
 * @throws ZookeeperNotFoundException
 * @throws BBoxDBException
 */
@Test(timeout = 60000)
public void testSystemCheckpoint1() throws ZookeeperException, InterruptedException, ZookeeperNotFoundException, BBoxDBException {
    final BBoxDBInstance systemName1 = new BBoxDBInstance("192.168.1.10:5050");
    final BBoxDBInstance systemName2 = new BBoxDBInstance("192.168.1.20:5050");
    final DistributionRegion region = getSpacePartitioner().getRootNode();
    final String path = distributionRegionAdapter.getZookeeperPathForDistributionRegion(region);
    distributionRegionAdapter.addSystemToDistributionRegion(path, systemName1);
    distributionRegionAdapter.addSystemToDistributionRegion(path, systemName2);
    final long checkpoint1 = distributionRegionAdapter.getCheckpointForDistributionRegion(region, systemName1);
    Assert.assertEquals(-1, checkpoint1);
    distributionRegionAdapter.setCheckpointForDistributionRegion(region, systemName1, 5000);
    final long checkpoint2 = distributionRegionAdapter.getCheckpointForDistributionRegion(region, systemName1);
    Assert.assertEquals(5000, checkpoint2);
    // System 2
    final long checkpoint3 = distributionRegionAdapter.getCheckpointForDistributionRegion(region, systemName2);
    Assert.assertEquals(-1, checkpoint3);
    distributionRegionAdapter.setCheckpointForDistributionRegion(region, systemName2, 9000);
    final long checkpoint4 = distributionRegionAdapter.getCheckpointForDistributionRegion(region, systemName2);
    Assert.assertEquals(9000, checkpoint4);
    distributionRegionAdapter.setCheckpointForDistributionRegion(region, systemName2, 9001);
    final long checkpoint5 = distributionRegionAdapter.getCheckpointForDistributionRegion(region, systemName2);
    Assert.assertEquals(9001, checkpoint5);
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) 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