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());
}
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));
}
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);
}
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));
}
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);
}
Aggregations