use of org.bboxdb.distribution.membership.BBoxDBInstance in project bboxdb by jnidzwetzki.
the class TestDistributedInstanceManager method testRegisterUnregister2.
/**
* test unregister
*/
@Test(timeout = 60000)
public void testRegisterUnregister2() throws InterruptedException {
final BBoxDBInstance instance = new BBoxDBInstance("node1:5050");
final ZookeeperClient zookeeperClient = getNewZookeeperClient(instance);
BBoxDBInstanceManager.getInstance().startMembershipObserver(zookeeperClient);
Assert.assertTrue(zookeeperClient.isConnected());
Thread.sleep(1000);
final BBoxDBInstanceManager distributedInstanceManager = BBoxDBInstanceManager.getInstance();
Assert.assertFalse(distributedInstanceManager.getInstances().isEmpty());
Assert.assertEquals(1, distributedInstanceManager.getInstances().size());
Assert.assertEquals(instance.getInetSocketAddress(), distributedInstanceManager.getInstances().get(0).getInetSocketAddress());
zookeeperClient.shutdown();
Assert.assertTrue(distributedInstanceManager.getInstances().isEmpty());
final BBoxDBInstance instance2 = new BBoxDBInstance("node1:5050");
final ZookeeperClient zookeeperClient2 = getNewZookeeperClient(instance2);
BBoxDBInstanceManager.getInstance().startMembershipObserver(zookeeperClient2);
Assert.assertTrue(zookeeperClient2.isConnected());
Thread.sleep(1000);
Assert.assertFalse(distributedInstanceManager.getInstances().isEmpty());
Assert.assertEquals(1, distributedInstanceManager.getInstances().size());
Assert.assertEquals(instance.getInetSocketAddress(), distributedInstanceManager.getInstances().get(0).getInetSocketAddress());
zookeeperClient2.shutdown();
}
use of org.bboxdb.distribution.membership.BBoxDBInstance in project bboxdb by jnidzwetzki.
the class TestDistributedInstanceManager method testWriteSystemInfo.
/**
* Test write the system info
*/
@Test(timeout = 60000)
public void testWriteSystemInfo() {
final BBoxDBInstance instance1 = new BBoxDBInstance("node6:5050");
final ZookeeperClient zookeeperClient1 = getNewZookeeperClient(instance1);
BBoxDBInstanceManager.getInstance().startMembershipObserver(zookeeperClient1);
final List<BBoxDBInstance> distributedInstances = BBoxDBInstanceManager.getInstance().getInstances();
Assert.assertEquals(1, distributedInstances.size());
final BBoxDBInstance instance = distributedInstances.get(0);
Assert.assertEquals(SystemInfo.getAvailableMemory(), instance.getMemory());
Assert.assertEquals(SystemInfo.getCPUCores(), instance.getCpuCores());
final BBoxDBConfiguration bboxDBConfiguration = BBoxDBConfigurationManager.getConfiguration();
final List<String> directories = bboxDBConfiguration.getStorageDirectories();
Assert.assertEquals(directories.size(), instance.getNumberOfStorages());
Assert.assertEquals(directories.size(), instance.getAllTotalSpaceLocations().size());
Assert.assertEquals(directories.size(), instance.getAllFreeSpaceLocations().size());
for (final String directory : directories) {
final File path = new File(directory);
Assert.assertEquals(SystemInfo.getFreeDiskspace(path), (long) instance.getAllFreeSpaceLocations().get(directory), 1000000);
Assert.assertEquals(SystemInfo.getTotalDiskspace(path), (long) instance.getAllTotalSpaceLocations().get(directory), 1000000);
}
zookeeperClient1.shutdown();
}
use of org.bboxdb.distribution.membership.BBoxDBInstance in project bboxdb by jnidzwetzki.
the class TestRegionSyncer method waitForSystemsCallback.
@Test(timeout = 10000)
public void waitForSystemsCallback() throws ZookeeperException, InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final DistributionRegionSyncer distributionRegionSyncer = buildSyncer();
final DistributionRegion root = distributionRegionSyncer.getRootNode();
Assert.assertEquals(0, root.getHighestChildNumber());
final DistributionRegionCallback callback = (e, r) -> {
if (r.equals(root)) {
latch.countDown();
}
};
distributionRegionSyncer.registerCallback(callback);
final BBoxDBInstance newInstance = new BBoxDBInstance("localhost:8443");
final String path = distributionRegionAdapter.getZookeeperPathForDistributionRegion(root);
distributionRegionAdapter.addSystemToDistributionRegion(path, newInstance);
latch.await();
distributionRegionSyncer.unregisterCallback(callback);
Assert.assertTrue(root.getSystems().contains(newInstance));
}
use of org.bboxdb.distribution.membership.BBoxDBInstance 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.membership.BBoxDBInstance 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);
}
Aggregations