use of org.bboxdb.distribution.partitioner.regionsplit.tuplesink.AbstractTupleSink 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());
}
use of org.bboxdb.distribution.partitioner.regionsplit.tuplesink.AbstractTupleSink 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);
}
use of org.bboxdb.distribution.partitioner.regionsplit.tuplesink.AbstractTupleSink in project bboxdb by jnidzwetzki.
the class TestTupleSink method testTupleRedistribution2.
/**
* Test the tuple redistribution
* @throws Exception
*/
@Test(timeout = 60000)
public void testTupleRedistribution2() 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 DistributionRegion distributionRegion2 = new DistributionRegion(TEST_GROUP, DistributionRegion.ROOT_NODE_ROOT_POINTER, new BoundingBox(5.0, 6.0, 5.0, 6.0, 5.0, 6.0), 1);
final TupleRedistributor tupleRedistributor = createTupleRedistributor();
final AbstractTupleSink tupleSink1 = Mockito.mock(AbstractTupleSink.class);
tupleRedistributor.registerRegion(distributionRegion1, Arrays.asList(tupleSink1));
final AbstractTupleSink tupleSink2 = Mockito.mock(AbstractTupleSink.class);
tupleRedistributor.registerRegion(distributionRegion2, Arrays.asList(tupleSink2));
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));
(Mockito.verify(tupleSink2, Mockito.never())).sinkTuple(Mockito.any(Tuple.class));
final Tuple tuple2 = new Tuple("abc", new BoundingBox(5.0, 6.0, 5.0, 6.0, 5.0, 6.0), "".getBytes());
tupleRedistributor.redistributeTuple(tuple2);
(Mockito.verify(tupleSink1, Mockito.times(1))).sinkTuple(Mockito.any(Tuple.class));
(Mockito.verify(tupleSink2, Mockito.times(1))).sinkTuple(Mockito.any(Tuple.class));
final Tuple tuple3 = new Tuple("abc", new BoundingBox(0.0, 6.0, 0.0, 6.0, 0.0, 6.0), "".getBytes());
tupleRedistributor.redistributeTuple(tuple3);
(Mockito.verify(tupleSink1, Mockito.atLeast(2))).sinkTuple(Mockito.any(Tuple.class));
(Mockito.verify(tupleSink2, Mockito.atLeast(2))).sinkTuple(Mockito.any(Tuple.class));
final Tuple tuple4 = new DeletedTuple("abc");
tupleRedistributor.redistributeTuple(tuple4);
(Mockito.verify(tupleSink1, Mockito.atLeast(3))).sinkTuple(Mockito.any(Tuple.class));
(Mockito.verify(tupleSink2, Mockito.atLeast(3))).sinkTuple(Mockito.any(Tuple.class));
System.out.println(tupleRedistributor.getStatistics());
}
Aggregations