Search in sources :

Example 61 with BBoxDBInstance

use of org.bboxdb.distribution.membership.BBoxDBInstance 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());
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Example 62 with BBoxDBInstance

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

the class TestCPUCoreUtilizationRessourcePlacement 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.setCpuCores(1);
    final BBoxDBInstance instance2 = new BBoxDBInstance("node2:123", "0.1", BBoxDBInstanceState.READY);
    systems.add(instance2);
    instance2.setCpuCores(4);
    final BBoxDBInstance instance3 = new BBoxDBInstance("node3:123", "0.1", BBoxDBInstanceState.READY);
    systems.add(instance3);
    instance3.setCpuCores(16);
    final BBoxDBInstance instance4 = new BBoxDBInstance("node4:123", "0.1", BBoxDBInstanceState.READY);
    systems.add(instance4);
    instance4.setCpuCores(64);
    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 cpu cores: 64 / 2 = 32
    instance2.setCpuCores(64);
    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 cpu information about instance4
    instance4.setCpuCores(-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)

Example 63 with BBoxDBInstance

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

the class TestRandomRessourcePlacement method testNonReadySystems2.

/**
 * No system is ready
 * @throws ResourceAllocationException
 */
@Test(expected = ResourceAllocationException.class)
public void testNonReadySystems2() throws ResourceAllocationException {
    final ResourcePlacementStrategy resourcePlacementStrategy = getPlacementStrategy();
    final List<BBoxDBInstance> systems = new ArrayList<BBoxDBInstance>();
    systems.add(new BBoxDBInstance("node1:123", "0.1", BBoxDBInstanceState.OUTDATED));
    systems.add(new BBoxDBInstance("node2:123", "0.1", BBoxDBInstanceState.FAILED));
    systems.add(new BBoxDBInstance("node3:123", "0.1", BBoxDBInstanceState.FAILED));
    systems.add(new BBoxDBInstance("node4:123", "0.1", BBoxDBInstanceState.FAILED));
    resourcePlacementStrategy.getInstancesForNewRessource(systems);
}
Also used : ArrayList(java.util.ArrayList) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Example 64 with BBoxDBInstance

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

the class TestRandomRessourcePlacement method testPlacement1.

/**
 * Test placement 1 (all systems are blacklisted)
 * @throws ResourceAllocationException
 */
@Test(expected = ResourceAllocationException.class)
public void testPlacement1() throws ResourceAllocationException {
    final ResourcePlacementStrategy resourcePlacementStrategy = getPlacementStrategy();
    final List<BBoxDBInstance> systems = new ArrayList<BBoxDBInstance>();
    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));
    Assert.assertEquals(systems.get(0), resourcePlacementStrategy.getInstancesForNewRessource(systems, systems));
}
Also used : ArrayList(java.util.ArrayList) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Example 65 with BBoxDBInstance

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

the class TestRandomRessourcePlacement method testNonReadySystems1.

/**
 * No system is ready
 * @throws ResourceAllocationException
 */
@Test(expected = ResourceAllocationException.class)
public void testNonReadySystems1() throws ResourceAllocationException {
    final ResourcePlacementStrategy resourcePlacementStrategy = getPlacementStrategy();
    final List<BBoxDBInstance> systems = new ArrayList<BBoxDBInstance>();
    systems.add(new BBoxDBInstance("node1:123", "0.1", BBoxDBInstanceState.OUTDATED));
    systems.add(new BBoxDBInstance("node2:123", "0.1", BBoxDBInstanceState.FAILED));
    systems.add(new BBoxDBInstance("node3:123", "0.1", BBoxDBInstanceState.FAILED));
    systems.add(new BBoxDBInstance("node4:123", "0.1", BBoxDBInstanceState.FAILED));
    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