Search in sources :

Example 16 with BBoxDBInstance

use of org.bboxdb.distribution.membership.BBoxDBInstance in project bboxdb by jnidzwetzki.

the class TestZookeeperIntegration method testSystemCheckpoint1.

/**
 * Test the set and get checkpoint methods
 * @throws ZookeeperException
 * @throws InterruptedException
 * @throws ZookeeperNotFoundException
 * @throws BBoxDBException
 */
@Test(timeout = 60000)
public void testSystemCheckpoint1() throws ZookeeperException, InterruptedException, ZookeeperNotFoundException, BBoxDBException {
    final BBoxDBInstance systemName1 = new BBoxDBInstance("192.168.1.10:5050");
    final BBoxDBInstance systemName2 = new BBoxDBInstance("192.168.1.20:5050");
    final DistributionRegion region = getSpacePartitioner().getRootNode();
    final String path = distributionRegionAdapter.getZookeeperPathForDistributionRegion(region);
    distributionRegionAdapter.addSystemToDistributionRegion(path, systemName1);
    distributionRegionAdapter.addSystemToDistributionRegion(path, systemName2);
    final long checkpoint1 = distributionRegionAdapter.getCheckpointForDistributionRegion(region, systemName1);
    Assert.assertEquals(-1, checkpoint1);
    distributionRegionAdapter.setCheckpointForDistributionRegion(region, systemName1, 5000);
    final long checkpoint2 = distributionRegionAdapter.getCheckpointForDistributionRegion(region, systemName1);
    Assert.assertEquals(5000, checkpoint2);
    // System 2
    final long checkpoint3 = distributionRegionAdapter.getCheckpointForDistributionRegion(region, systemName2);
    Assert.assertEquals(-1, checkpoint3);
    distributionRegionAdapter.setCheckpointForDistributionRegion(region, systemName2, 9000);
    final long checkpoint4 = distributionRegionAdapter.getCheckpointForDistributionRegion(region, systemName2);
    Assert.assertEquals(9000, checkpoint4);
    distributionRegionAdapter.setCheckpointForDistributionRegion(region, systemName2, 9001);
    final long checkpoint5 = distributionRegionAdapter.getCheckpointForDistributionRegion(region, systemName2);
    Assert.assertEquals(9001, checkpoint5);
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Example 17 with BBoxDBInstance

use of org.bboxdb.distribution.membership.BBoxDBInstance in project bboxdb by jnidzwetzki.

the class TestZookeeperIntegration method testSystems.

/**
 * Test the systems field
 * @throws ZookeeperException
 * @throws InterruptedException
 * @throws ZookeeperNotFoundException
 * @throws BBoxDBException
 */
@Test(timeout = 60000)
public void testSystems() throws ZookeeperException, InterruptedException, ZookeeperNotFoundException, BBoxDBException {
    final BBoxDBInstance systemName = new BBoxDBInstance("192.168.1.10:5050");
    final DistributionRegion region = getSpacePartitioner().getRootNode();
    final String path = distributionRegionAdapter.getZookeeperPathForDistributionRegion(region);
    Assert.assertEquals(1, region.getSystems().size());
    distributionRegionAdapter.addSystemToDistributionRegion(path, systemName);
    // Sleep 2 seconds to wait for the update
    Thread.sleep(2000);
    Assert.assertEquals(2, region.getSystems().size());
    Assert.assertTrue(region.getSystems().contains(systemName));
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Example 18 with BBoxDBInstance

use of org.bboxdb.distribution.membership.BBoxDBInstance in project bboxdb by jnidzwetzki.

the class TestFreeDiskspaceRessourcePlacement method testUtilPlacement.

/**
 * Test round robin placement 1
 * @throws ResourceAllocationException
 */
@Test(timeout = 60000)
public void testUtilPlacement() throws ResourceAllocationException {
    final ResourcePlacementStrategy resourcePlacementStrategy = getPlacementStrategy();
    final List<BBoxDBInstance> systems = new ArrayList<>();
    final BBoxDBInstance instance1 = new BBoxDBInstance("node1:123", "0.1", BBoxDBInstanceState.READY);
    systems.add(instance1);
    instance1.addFreeSpace("/tmp", 1000);
    final BBoxDBInstance instance2 = new BBoxDBInstance("node2:123", "0.1", BBoxDBInstanceState.READY);
    systems.add(instance2);
    instance2.addFreeSpace("/tmp", 4000);
    final BBoxDBInstance instance3 = new BBoxDBInstance("node3:123", "0.1", BBoxDBInstanceState.READY);
    systems.add(instance3);
    instance3.addFreeSpace("/tmp", 16000);
    final BBoxDBInstance instance4 = new BBoxDBInstance("node4:123", "0.1", BBoxDBInstanceState.READY);
    systems.add(instance4);
    instance4.addFreeSpace("/tmp", 64000);
    Assert.assertEquals(systems.get(3), resourcePlacementStrategy.getInstancesForNewRessource(systems));
    instance2.addFreeSpace("/diskb", 64000);
    Assert.assertEquals(systems.get(1), resourcePlacementStrategy.getInstancesForNewRessource(systems));
    // Remove information about instance2
    instance2.getAllFreeSpaceLocations().clear();
    Assert.assertEquals(systems.get(3), resourcePlacementStrategy.getInstancesForNewRessource(systems));
}
Also used : ArrayList(java.util.ArrayList) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Example 19 with BBoxDBInstance

use of org.bboxdb.distribution.membership.BBoxDBInstance in project bboxdb by jnidzwetzki.

the class TestLowUtilizationRessourcePlacement method testUtilPlacement.

/**
 * Test round robin placement 1
 * @throws ResourceAllocationException
 */
@Test(timeout = 60000)
public void testUtilPlacement() throws ResourceAllocationException {
    final ResourcePlacementStrategy resourcePlacementStrategy = getPlacementStrategy();
    final List<BBoxDBInstance> systems = new ArrayList<>();
    systems.add(new BBoxDBInstance("node1:123", "0.1", BBoxDBInstanceState.READY));
    systems.add(new BBoxDBInstance("node2:123", "0.1", BBoxDBInstanceState.READY));
    systems.add(new BBoxDBInstance("node3:123", "0.1", BBoxDBInstanceState.READY));
    systems.add(new BBoxDBInstance("node4:123", "0.1", BBoxDBInstanceState.READY));
    utilization.clear();
    utilization.setCount(systems.get(0), 1);
    utilization.setCount(systems.get(1), 1);
    utilization.setCount(systems.get(2), 1);
    Assert.assertEquals(systems.get(3), resourcePlacementStrategy.getInstancesForNewRessource(systems));
    utilization.clear();
    utilization.setCount(systems.get(0), 1);
    utilization.setCount(systems.get(1), 2);
    utilization.setCount(systems.get(2), 3);
    utilization.setCount(systems.get(3), 4);
    Assert.assertEquals(systems.get(0), resourcePlacementStrategy.getInstancesForNewRessource(systems));
    utilization.clear();
    utilization.setCount(systems.get(0), 4);
    utilization.setCount(systems.get(1), 3);
    utilization.setCount(systems.get(2), 2);
    utilization.setCount(systems.get(3), 1);
    Assert.assertEquals(systems.get(3), resourcePlacementStrategy.getInstancesForNewRessource(systems));
}
Also used : ArrayList(java.util.ArrayList) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Example 20 with BBoxDBInstance

use of org.bboxdb.distribution.membership.BBoxDBInstance in project bboxdb by jnidzwetzki.

the class TestMemoryUtilizationRessourcePlacement method testUtilPlacement.

/**
 * Test round robin placement 1
 * @throws ResourceAllocationException
 */
@Test(timeout = 60000)
public void testUtilPlacement() throws ResourceAllocationException {
    final ResourcePlacementStrategy resourcePlacementStrategy = getPlacementStrategy();
    final List<BBoxDBInstance> systems = new ArrayList<>();
    final BBoxDBInstance instance1 = new BBoxDBInstance("node1:123", "0.1", BBoxDBInstanceState.READY);
    systems.add(instance1);
    instance1.setMemory(1000);
    final BBoxDBInstance instance2 = new BBoxDBInstance("node2:123", "0.1", BBoxDBInstanceState.READY);
    systems.add(instance2);
    instance2.setMemory(4000);
    final BBoxDBInstance instance3 = new BBoxDBInstance("node3:123", "0.1", BBoxDBInstanceState.READY);
    systems.add(instance3);
    instance3.setMemory(16000);
    final BBoxDBInstance instance4 = new BBoxDBInstance("node4:123", "0.1", BBoxDBInstanceState.READY);
    systems.add(instance4);
    instance4.setMemory(64000);
    utilization.clear();
    utilization.setCount(systems.get(0), 1);
    utilization.setCount(systems.get(1), 1);
    utilization.setCount(systems.get(2), 1);
    Assert.assertEquals(systems.get(3), resourcePlacementStrategy.getInstancesForNewRessource(systems));
    utilization.clear();
    // 1 / 1 = 1
    utilization.setCount(systems.get(0), 1);
    // 4 / 2 = 2
    utilization.setCount(systems.get(1), 2);
    // 16 / 3 = 5,3
    utilization.setCount(systems.get(2), 3);
    // 64 / 4 = 16
    utilization.setCount(systems.get(3), 4);
    Assert.assertEquals(systems.get(3), resourcePlacementStrategy.getInstancesForNewRessource(systems));
    // Upgrade memory 64 / 2 = 32
    instance2.setMemory(64000);
    Assert.assertEquals(systems.get(1), resourcePlacementStrategy.getInstancesForNewRessource(systems));
    // Assign a lot of tables
    // 64 / 64 = 1
    utilization.setCount(systems.get(1), 64);
    Assert.assertEquals(systems.get(3), resourcePlacementStrategy.getInstancesForNewRessource(systems));
    // Remove memory information about instance4
    instance4.setMemory(-1);
    Assert.assertEquals(systems.get(2), resourcePlacementStrategy.getInstancesForNewRessource(systems));
}
Also used : ArrayList(java.util.ArrayList) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Aggregations

BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)78 Test (org.junit.Test)36 ArrayList (java.util.ArrayList)28 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)25 BBoxDBException (org.bboxdb.misc.BBoxDBException)16 ZookeeperClient (org.bboxdb.distribution.zookeeper.ZookeeperClient)14 List (java.util.List)13 RoutingHop (org.bboxdb.network.routing.RoutingHop)13 BBoxDBInstanceManager (org.bboxdb.distribution.membership.BBoxDBInstanceManager)11 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)11 RoutingHeader (org.bboxdb.network.routing.RoutingHeader)11 BoundingBox (org.bboxdb.commons.math.BoundingBox)9 NetworkOperationFuture (org.bboxdb.network.client.future.NetworkOperationFuture)8 Map (java.util.Map)7 HashMap (java.util.HashMap)6 ZookeeperBBoxDBInstanceAdapter (org.bboxdb.distribution.membership.ZookeeperBBoxDBInstanceAdapter)6 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)6 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)6 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)6 OptionalDouble (java.util.OptionalDouble)4