Search in sources :

Example 6 with DistributionRegionIdMapper

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

the class TestRegionIdMapper method testMappingDisappears2.

/**
 * Wait until mapping disappears
 * @throws InterruptedException
 * @throws TimeoutException
 */
@Test(timeout = 15000, expected = TimeoutException.class)
public void testMappingDisappears2() throws TimeoutException, InterruptedException {
    final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
    regionIdMapper.addMapping(3, new BoundingBox(15d, 18d, 15d, 18d));
    regionIdMapper.waitUntilMappingDisappears(3, 5, TimeUnit.SECONDS);
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) Test(org.junit.Test)

Example 7 with DistributionRegionIdMapper

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

the class TestRegionIdMapper method testZeroMapping.

/**
 * Test the mapping with no entries
 */
@Test(timeout = 60000)
public void testZeroMapping() {
    final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
    Assert.assertEquals(0, regionIdMapper.getLocalTablesForRegion(new BoundingBox(2.5d, 2.5d, 1.5d, 1.5d), DEFAULT_SSTABLE_NAME).size());
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) Test(org.junit.Test)

Example 8 with DistributionRegionIdMapper

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

the class TestRegionIdMapper method testMappingAppears3.

/**
 * Wait until mapping appears
 * @throws InterruptedException
 * @throws TimeoutException
 */
@Test(timeout = 15000)
public void testMappingAppears3() throws TimeoutException, InterruptedException {
    final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
    final Runnable runable = new Runnable() {

        @Override
        public void run() {
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            regionIdMapper.addMapping(3, new BoundingBox(15d, 18d, 15d, 18d));
        }
    };
    final Thread thread = new Thread(runable);
    thread.start();
    regionIdMapper.waitUntilMappingAppears(3, 5, TimeUnit.SECONDS);
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) Test(org.junit.Test)

Example 9 with DistributionRegionIdMapper

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

the class TestRegionIdMapper method testOneMapping.

/**
 * Test the mapping with one entry
 */
@Test(timeout = 60000)
public void testOneMapping() {
    final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
    regionIdMapper.addMapping(1, new BoundingBox(1d, 2d, 1d, 2d));
    Assert.assertEquals(0, regionIdMapper.getLocalTablesForRegion(new BoundingBox(2.5d, 2.5d, 1.5d, 1.5d), DEFAULT_SSTABLE_NAME).size());
    Assert.assertEquals(1, regionIdMapper.getLocalTablesForRegion(new BoundingBox(1.5d, 1.5d, 1.5d, 1.5d), DEFAULT_SSTABLE_NAME).size());
    regionIdMapper.clear();
    Assert.assertEquals(0, regionIdMapper.getLocalTablesForRegion(new BoundingBox(1.5d, 1.5d, 1.5d, 1.5d), DEFAULT_SSTABLE_NAME).size());
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) Test(org.junit.Test)

Example 10 with DistributionRegionIdMapper

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

the class TestRegionSyncer method buildSyncer.

/**
 * Build a new syncer
 */
private DistributionRegionSyncer buildSyncer() {
    final Set<DistributionRegionCallback> callbacks = new CopyOnWriteArraySet<>();
    final DistributionRegionIdMapper distributionRegionIdMapper = new DistributionRegionIdMapper(GROUP);
    final SpacePartitionerContext spacePartitionerContext = new SpacePartitionerContext("", GROUP, ZookeeperClientFactory.getZookeeperClient(), callbacks, distributionRegionIdMapper);
    return new DistributionRegionSyncer(spacePartitionerContext);
}
Also used : SpacePartitionerContext(org.bboxdb.distribution.partitioner.SpacePartitionerContext) DistributionRegionCallback(org.bboxdb.distribution.region.DistributionRegionCallback) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) DistributionRegionSyncer(org.bboxdb.distribution.region.DistributionRegionSyncer)

Aggregations

DistributionRegionIdMapper (org.bboxdb.distribution.region.DistributionRegionIdMapper)25 Test (org.junit.Test)14 BoundingBox (org.bboxdb.commons.math.BoundingBox)11 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)11 SpacePartitioner (org.bboxdb.distribution.partitioner.SpacePartitioner)9 BBoxDBException (org.bboxdb.misc.BBoxDBException)6 StorageManagerException (org.bboxdb.storage.StorageManagerException)5 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)3 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)3 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)2 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)2 DistributionRegionCallback (org.bboxdb.distribution.region.DistributionRegionCallback)2 Tuple (org.bboxdb.storage.entity.Tuple)2 RejectedException (org.bboxdb.commons.RejectedException)1 KDtreeSpacePartitioner (org.bboxdb.distribution.partitioner.KDtreeSpacePartitioner)1 SpacePartitionerContext (org.bboxdb.distribution.partitioner.SpacePartitionerContext)1 TupleRedistributor (org.bboxdb.distribution.partitioner.regionsplit.tuplesink.TupleRedistributor)1 DistributionRegionSyncer (org.bboxdb.distribution.region.DistributionRegionSyncer)1 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)1 DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)1