Search in sources :

Example 16 with DistributionRegionIdMapper

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

the class TestRegionIdMapper method testGetTableNames1.

/**
 * Test the tablename result
 */
@Test(timeout = 60000)
public void testGetTableNames1() {
    final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
    regionIdMapper.addMapping(1, new BoundingBox(1d, 2d, 1d, 2d));
    regionIdMapper.addMapping(2, new BoundingBox(10d, 20d, 10d, 20d));
    regionIdMapper.addMapping(3, new BoundingBox(15d, 18d, 15d, 18d));
    final Collection<TupleStoreName> mappingResult = regionIdMapper.getLocalTablesForRegion(new BoundingBox(1.5d, 55d, 1.5d, 55d), DEFAULT_SSTABLE_NAME);
    Assert.assertTrue(mappingResult.contains(new TupleStoreName(DEFAULT_TABLE_NAME + "_1")));
    Assert.assertTrue(mappingResult.contains(new TupleStoreName(DEFAULT_TABLE_NAME + "_2")));
    Assert.assertTrue(mappingResult.contains(new TupleStoreName(DEFAULT_TABLE_NAME + "_3")));
    Assert.assertFalse(mappingResult.contains(new TupleStoreName(DEFAULT_TABLE_NAME + "_4")));
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) Test(org.junit.Test)

Example 17 with DistributionRegionIdMapper

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

the class TestRegionIdMapper method testMappingAppears2.

/**
 * Wait until mapping appears
 * @throws InterruptedException
 * @throws TimeoutException
 */
@Test(timeout = 10000, expected = TimeoutException.class)
public void testMappingAppears2() throws TimeoutException, InterruptedException {
    final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
    regionIdMapper.waitUntilMappingAppears(3, 5, TimeUnit.SECONDS);
}
Also used : DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) Test(org.junit.Test)

Example 18 with DistributionRegionIdMapper

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

the class TestRegionIdMapper method testThreeMapping.

/**
 * Test the mapping with three entries
 */
@Test(timeout = 60000)
public void testThreeMapping() {
    final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
    regionIdMapper.addMapping(1, new BoundingBox(1d, 2d, 1d, 2d));
    regionIdMapper.addMapping(2, new BoundingBox(10d, 20d, 10d, 20d));
    regionIdMapper.addMapping(3, new BoundingBox(15d, 18d, 15d, 18d));
    Assert.assertEquals(3, regionIdMapper.getLocalTablesForRegion(new BoundingBox(1.5d, 55d, 1.5d, 55d), DEFAULT_SSTABLE_NAME).size());
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) Test(org.junit.Test)

Example 19 with DistributionRegionIdMapper

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

the class TestRegionIdMapper method testGetTableNames2.

/**
 * Test the tablename result
 */
@Test(timeout = 60000)
public void testGetTableNames2() {
    final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
    regionIdMapper.addMapping(1, new BoundingBox(1d, 2d, 1d, 2d));
    regionIdMapper.addMapping(2, new BoundingBox(10d, 20d, 10d, 20d));
    regionIdMapper.addMapping(3, new BoundingBox(15d, 18d, 15d, 18d));
    final Collection<TupleStoreName> mappingResult = regionIdMapper.getLocalTablesForRegion(new BoundingBox(1.5d, 1.5d, 1.5d, 1.5d), DEFAULT_SSTABLE_NAME);
    Assert.assertTrue(mappingResult.contains(new TupleStoreName(DEFAULT_TABLE_NAME + "_1")));
    Assert.assertFalse(mappingResult.contains(new TupleStoreName(DEFAULT_TABLE_NAME + "_2")));
    Assert.assertFalse(mappingResult.contains(new TupleStoreName(DEFAULT_TABLE_NAME + "_3")));
    Assert.assertFalse(mappingResult.contains(new TupleStoreName(DEFAULT_TABLE_NAME + "_4")));
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) Test(org.junit.Test)

Example 20 with DistributionRegionIdMapper

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

the class TestRegionIdMapper method testTwoMapping.

/**
 * Test the mapping with two entries
 */
@Test(timeout = 60000)
public void testTwoMapping() {
    final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
    regionIdMapper.addMapping(1, new BoundingBox(1d, 2d, 1d, 2d));
    regionIdMapper.addMapping(2, new BoundingBox(10d, 20d, 10d, 20d));
    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());
    Assert.assertEquals(2, regionIdMapper.getLocalTablesForRegion(new BoundingBox(1.5d, 55d, 1.5d, 55d), 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)

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