use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestZookeeperIntegration method testStatistics1.
/**
* Test the statistics for a given region
* @throws ZookeeperException
* @throws ZookeeperNotFoundException
* @throws BBoxDBException
*/
@Test(timeout = 60000)
public void testStatistics1() throws ZookeeperException, ZookeeperNotFoundException, BBoxDBException {
final BBoxDBInstance system1 = new BBoxDBInstance("192.168.1.10:5050");
final BBoxDBInstance system2 = new BBoxDBInstance("192.168.1.11:5050");
final DistributionRegion region = getSpacePartitioner().getRootNode();
final OptionalDouble size1 = StatisticsHelper.getAndUpdateStatistics(region);
Assert.assertFalse(size1.isPresent());
final Map<BBoxDBInstance, Map<String, Long>> statistics1 = distributionRegionAdapter.getRegionStatistics(region);
Assert.assertTrue(statistics1.isEmpty());
distributionRegionAdapter.updateRegionStatistics(region, system1, 12, 999);
final Map<BBoxDBInstance, Map<String, Long>> statistics2 = distributionRegionAdapter.getRegionStatistics(region);
Assert.assertEquals(1, statistics2.size());
Assert.assertEquals(12, statistics2.get(system1).get(ZookeeperNodeNames.NAME_STATISTICS_TOTAL_SIZE).longValue());
Assert.assertEquals(999, statistics2.get(system1).get(ZookeeperNodeNames.NAME_STATISTICS_TOTAL_TUPLES).longValue());
final OptionalDouble size2 = StatisticsHelper.getAndUpdateStatistics(region);
Assert.assertEquals(12, size2.getAsDouble(), DELTA);
distributionRegionAdapter.updateRegionStatistics(region, system2, 33, 1234);
final Map<BBoxDBInstance, Map<String, Long>> statistics3 = distributionRegionAdapter.getRegionStatistics(region);
Assert.assertEquals(2, statistics3.size());
Assert.assertEquals(12, statistics3.get(system1).get(ZookeeperNodeNames.NAME_STATISTICS_TOTAL_SIZE).longValue());
Assert.assertEquals(999, statistics3.get(system1).get(ZookeeperNodeNames.NAME_STATISTICS_TOTAL_TUPLES).longValue());
Assert.assertEquals(33, statistics3.get(system2).get(ZookeeperNodeNames.NAME_STATISTICS_TOTAL_SIZE).longValue());
Assert.assertEquals(1234, statistics3.get(system2).get(ZookeeperNodeNames.NAME_STATISTICS_TOTAL_TUPLES).longValue());
final OptionalDouble size3 = StatisticsHelper.getAndUpdateStatistics(region);
Assert.assertEquals(33, size3.getAsDouble(), DELTA);
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class CLI method printDistributionRegionRecursive.
/**
* Print the content of the distribution region recursive
* @param distributionRegion
*/
protected void printDistributionRegionRecursive(final DistributionRegion distributionRegion) {
if (distributionRegion == null) {
return;
}
final BoundingBox boundingBox = distributionRegion.getConveringBox();
final String bboxString = IntStream.range(0, boundingBox.getDimension()).mapToObj(i -> "Dimension:" + i + " " + boundingBox.getIntervalForDimension(i).toString()).collect(Collectors.joining(", "));
final String systemsString = distributionRegion.getSystems().stream().map(s -> s.getIp() + ":" + s.getPort()).collect(Collectors.joining(", ", "[", "]"));
System.out.format("Region %d, Bounding Box=%s, State=%s, Systems=%s%n", distributionRegion.getRegionId(), bboxString, distributionRegion.getState(), systemsString);
for (final DistributionRegion region : distributionRegion.getDirectChildren()) {
printDistributionRegionRecursive(region);
}
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestDistributionGroup method createDistributionGroup.
/**
* @param dimensions
* @return
*/
private DistributionRegion createDistributionGroup(final int dimensions) {
final String name = "foo";
DistributionGroupConfigurationCache.getInstance().clear();
final DistributionGroupConfiguration config = new DistributionGroupConfiguration();
config.setDimensions(dimensions);
DistributionGroupConfigurationCache.getInstance().addNewConfiguration(name, config);
final DistributionRegion level0 = new DistributionRegion(name, BoundingBox.createFullCoveringDimensionBoundingBox(dimensions));
return level0;
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestZookeeperIntegration method testStatistics2.
/**
* Test the statistics of child regions
* @throws Exception
*/
@Test(timeout = 60000)
public void testStatistics2() throws Exception {
final BBoxDBInstance system1 = new BBoxDBInstance("192.168.1.10:5050");
final KDtreeSpacePartitioner spaceparitioner = (KDtreeSpacePartitioner) getSpacePartitioner();
final DistributionRegion region = spaceparitioner.getRootNode();
final OptionalDouble totalSize1 = RegionMergeHelper.getTotalRegionSize(region.getDirectChildren());
Assert.assertFalse(totalSize1.isPresent());
spaceparitioner.splitNode(region, 12);
spaceparitioner.waitForSplitCompleteZookeeperCallback(region, 2);
distributionRegionAdapter.updateRegionStatistics(region.getDirectChildren().get(0), system1, 12, 999);
distributionRegionAdapter.updateRegionStatistics(region.getDirectChildren().get(1), system1, 33, 999);
StatisticsHelper.clearHistory();
final OptionalDouble totalSizeAfterClear = RegionMergeHelper.getTotalRegionSize(region.getDirectChildren());
Assert.assertFalse(totalSizeAfterClear.isPresent());
// Update complete history
for (int i = 0; i < StatisticsHelper.HISTORY_LENGTH; i++) {
RegionMergeHelper.getTotalRegionSize(region.getDirectChildren());
}
final OptionalDouble totalSize2 = RegionMergeHelper.getTotalRegionSize(region.getDirectChildren());
Assert.assertEquals(45, totalSize2.getAsDouble(), DELTA);
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class TestZookeeperIntegration method testSystemRegisterAndUnregister.
/**
* Test the system register and unregister methods
* @throws ZookeeperException
* @throws ZookeeperNotFoundException
* @throws BBoxDBException
*/
@Test(timeout = 60000)
public void testSystemRegisterAndUnregister() throws ZookeeperException, ZookeeperNotFoundException, BBoxDBException {
final BBoxDBInstance systemName = new BBoxDBInstance("192.168.1.10:5050");
final DistributionRegion region = getSpacePartitioner().getRootNode();
final Collection<BBoxDBInstance> systems1 = distributionRegionAdapter.getSystemsForDistributionRegion(region);
Assert.assertEquals(1, systems1.size());
// Add a system
final String path = distributionRegionAdapter.getZookeeperPathForDistributionRegion(region);
distributionRegionAdapter.addSystemToDistributionRegion(path, systemName);
final Collection<BBoxDBInstance> systems2 = distributionRegionAdapter.getSystemsForDistributionRegion(region);
Assert.assertEquals(2, systems2.size());
Assert.assertTrue(systems2.contains(systemName));
distributionRegionAdapter.deleteSystemFromDistributionRegion(region, systemName);
final Collection<BBoxDBInstance> systems3 = distributionRegionAdapter.getSystemsForDistributionRegion(region);
Assert.assertEquals(1, systems3.size());
}
Aggregations