Search in sources :

Example 6 with DistributionRegion

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

the class TestTupleSink method testTupleRedistribution1.

/**
 * Test the tuple redistribution
 * @throws Exception
 */
@Test(timeout = 60000)
public void testTupleRedistribution1() throws Exception {
    final DistributionRegion distributionRegion1 = new DistributionRegion(TEST_GROUP, DistributionRegion.ROOT_NODE_ROOT_POINTER, new BoundingBox(0.0, 1.0, 0.0, 1.0, 0.0, 1.0), 1);
    final TupleRedistributor tupleRedistributor = createTupleRedistributor();
    final AbstractTupleSink tupleSink1 = Mockito.mock(AbstractTupleSink.class);
    tupleRedistributor.registerRegion(distributionRegion1, Arrays.asList(tupleSink1));
    final Tuple tuple1 = new Tuple("abc", new BoundingBox(0.0, 1.0, 0.0, 1.0, 0.0, 1.0), "".getBytes());
    tupleRedistributor.redistributeTuple(tuple1);
    (Mockito.verify(tupleSink1, Mockito.times(1))).sinkTuple(Mockito.any(Tuple.class));
    tupleRedistributor.redistributeTuple(tuple1);
    (Mockito.verify(tupleSink1, Mockito.times(2))).sinkTuple(Mockito.any(Tuple.class));
    System.out.println(tupleRedistributor.getStatistics());
}
Also used : TupleRedistributor(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.TupleRedistributor) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BoundingBox(org.bboxdb.commons.math.BoundingBox) AbstractTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.AbstractTupleSink) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 7 with DistributionRegion

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

the class TestTupleSink method testTupleSink.

/**
 * Test the tuple sinks
 * @throws StorageManagerException
 * @throws BBoxDBException
 * @throws ZookeeperException
 * @throws InterruptedException
 */
@Test(timeout = 60000)
public void testTupleSink() throws StorageManagerException, BBoxDBException, ZookeeperException, InterruptedException {
    final DistributionRegion distributionRegion = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(TEST_GROUP).getRootNode();
    tupleStoreAdapter.deleteTable(TABLENAME);
    tupleStoreAdapter.writeTuplestoreConfiguration(TABLENAME, new TupleStoreConfiguration());
    final List<BBoxDBInstance> systems = Arrays.asList(new BBoxDBInstance("10.0.0.1:10000"), new BBoxDBInstance("10.0.0.2:10000"), ZookeeperClientFactory.getLocalInstanceName());
    distributionRegion.setSystems(systems);
    final TupleRedistributor tupleRedistributor = createTupleRedistributor();
    tupleRedistributor.registerRegion(distributionRegion);
    final Map<DistributionRegion, List<AbstractTupleSink>> map = tupleRedistributor.getRegionMap();
    Assert.assertEquals(1, map.size());
    final long networkSinks = map.values().stream().flatMap(e -> e.stream()).filter(s -> s instanceof NetworkTupleSink).count();
    Assert.assertEquals(2, networkSinks);
    final long localSinks = map.values().stream().flatMap(e -> e.stream()).filter(s -> s instanceof LocalTupleSink).count();
    Assert.assertEquals(1, localSinks);
}
Also used : TupleRedistributor(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.TupleRedistributor) Arrays(java.util.Arrays) BeforeClass(org.junit.BeforeClass) TupleStoreAdapter(org.bboxdb.distribution.zookeeper.TupleStoreAdapter) LocalTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.LocalTupleSink) Tuple(org.bboxdb.storage.entity.Tuple) BoundingBox(org.bboxdb.commons.math.BoundingBox) ArrayList(java.util.ArrayList) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) Map(java.util.Map) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) StorageManagerException(org.bboxdb.storage.StorageManagerException) DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) ZookeeperClientFactory(org.bboxdb.distribution.zookeeper.ZookeeperClientFactory) NetworkTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.NetworkTupleSink) DistributionGroupConfigurationBuilder(org.bboxdb.storage.entity.DistributionGroupConfigurationBuilder) Test(org.junit.Test) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) Mockito(org.mockito.Mockito) List(java.util.List) AbstractTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.AbstractTupleSink) BBoxDBException(org.bboxdb.misc.BBoxDBException) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) DistributionGroupAdapter(org.bboxdb.distribution.zookeeper.DistributionGroupAdapter) SpacePartitionerCache(org.bboxdb.distribution.partitioner.SpacePartitionerCache) TupleRedistributor(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.TupleRedistributor) Assert(org.junit.Assert) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) LocalTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.LocalTupleSink) NetworkTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.NetworkTupleSink) ArrayList(java.util.ArrayList) List(java.util.List) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Example 8 with DistributionRegion

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

the class TestTupleSink method testRegisterRegionDuplicate.

/**
 * Register region two times
 * @throws BBoxDBException
 * @throws InterruptedException
 * @throws Exception
 */
@Test(expected = StorageManagerException.class)
public void testRegisterRegionDuplicate() throws StorageManagerException, InterruptedException, BBoxDBException {
    final DistributionRegion distributionRegion = new DistributionRegion(TEST_GROUP, BoundingBox.createFullCoveringDimensionBoundingBox(3));
    final TupleRedistributor tupleRedistributor = createTupleRedistributor();
    tupleRedistributor.registerRegion(distributionRegion, new ArrayList<>());
    tupleRedistributor.registerRegion(distributionRegion, new ArrayList<>());
}
Also used : TupleRedistributor(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.TupleRedistributor) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) Test(org.junit.Test)

Example 9 with DistributionRegion

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

the class TestZookeeperIntegration method testSystemCheckpoint2.

/**
 * Test the set and get checkpoint methods
 * @throws Exception
 */
@Test(timeout = 60000)
public void testSystemCheckpoint2() throws Exception {
    final BBoxDBInstance systemName1 = new BBoxDBInstance("192.168.1.10:5050");
    final BBoxDBInstance systemName2 = new BBoxDBInstance("192.168.1.20:5050");
    final KDtreeSpacePartitioner distributionGroupAdapter = (KDtreeSpacePartitioner) getSpacePartitioner();
    final DistributionRegion region = distributionGroupAdapter.getRootNode();
    distributionGroupAdapter.splitNode(region, 50);
    final DistributionRegion region1 = region.getDirectChildren().get(0);
    final String path1 = distributionRegionAdapter.getZookeeperPathForDistributionRegion(region1);
    final DistributionRegion region2 = region.getDirectChildren().get(1);
    final String path2 = distributionRegionAdapter.getZookeeperPathForDistributionRegion(region2);
    distributionRegionAdapter.addSystemToDistributionRegion(path1, systemName1);
    distributionRegionAdapter.addSystemToDistributionRegion(path1, systemName2);
    distributionRegionAdapter.addSystemToDistributionRegion(path2, systemName1);
    distributionRegionAdapter.addSystemToDistributionRegion(path2, systemName2);
    distributionRegionAdapter.setCheckpointForDistributionRegion(region1, systemName1, 1);
    distributionRegionAdapter.setCheckpointForDistributionRegion(region1, systemName2, 2);
    distributionRegionAdapter.setCheckpointForDistributionRegion(region2, systemName1, 3);
    distributionRegionAdapter.setCheckpointForDistributionRegion(region2, systemName2, 4);
    final long checkpoint1 = distributionRegionAdapter.getCheckpointForDistributionRegion(region1, systemName1);
    final long checkpoint2 = distributionRegionAdapter.getCheckpointForDistributionRegion(region1, systemName2);
    final long checkpoint3 = distributionRegionAdapter.getCheckpointForDistributionRegion(region2, systemName1);
    final long checkpoint4 = distributionRegionAdapter.getCheckpointForDistributionRegion(region2, systemName2);
    Assert.assertEquals(1, checkpoint1);
    Assert.assertEquals(2, checkpoint2);
    Assert.assertEquals(3, checkpoint3);
    Assert.assertEquals(4, checkpoint4);
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) KDtreeSpacePartitioner(org.bboxdb.distribution.partitioner.KDtreeSpacePartitioner) Test(org.junit.Test)

Example 10 with DistributionRegion

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

the class TestZookeeperIntegration method testNameprefix1.

/**
 * Test the generation of the nameprefix
 * @throws ZookeeperException
 * @throws InterruptedException
 * @throws ZookeeperNotFoundException
 * @throws BBoxDBException
 */
@Test(timeout = 60000)
public void testNameprefix1() throws ZookeeperException, InterruptedException, ZookeeperNotFoundException, BBoxDBException {
    final DistributionRegion region = getSpacePartitioner().getRootNode();
    Assert.assertEquals(0, region.getRegionId());
}
Also used : 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