use of org.bboxdb.distribution.membership.BBoxDBInstance in project bboxdb by jnidzwetzki.
the class TestRandomRessourcePlacement method testPlacement2.
/**
* Test placement 2 (only one system)
* @throws ResourceAllocationException
*/
@Test(timeout = 60000)
public void testPlacement2() throws ResourceAllocationException {
final ResourcePlacementStrategy resourcePlacementStrategy = getPlacementStrategy();
final List<BBoxDBInstance> systems = new ArrayList<BBoxDBInstance>();
systems.add(new BBoxDBInstance("node1:123", "0.1", BBoxDBInstanceState.READY));
Assert.assertEquals(systems.get(0), resourcePlacementStrategy.getInstancesForNewRessource(systems));
Assert.assertEquals(systems.get(0), resourcePlacementStrategy.getInstancesForNewRessource(systems));
Assert.assertEquals(systems.get(0), resourcePlacementStrategy.getInstancesForNewRessource(systems));
Assert.assertEquals(systems.get(0), resourcePlacementStrategy.getInstancesForNewRessource(systems));
}
use of org.bboxdb.distribution.membership.BBoxDBInstance in project bboxdb by jnidzwetzki.
the class TestRandomRessourcePlacement method testNonReadySystems3.
/**
* Only ready systems should be returned
* @throws ResourceAllocationException
*/
@Test(timeout = 60000)
public void testNonReadySystems3() 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.READY));
for (int i = 0; i < 100; i++) {
Assert.assertEquals(systems.get(3), resourcePlacementStrategy.getInstancesForNewRessource(systems));
}
}
use of org.bboxdb.distribution.membership.BBoxDBInstance in project bboxdb by jnidzwetzki.
the class TestRoundRobinRessourcePlacement method testRoundRobinPlacement2.
/**
* Test round robin placement 2 (removed system)
* @throws ResourceAllocationException
*/
@Test(timeout = 60000)
public void testRoundRobinPlacement2() 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));
Assert.assertEquals(systems.get(1), resourcePlacementStrategy.getInstancesForNewRessource(systems));
systems.remove(1);
Assert.assertEquals(systems.get(0), resourcePlacementStrategy.getInstancesForNewRessource(systems));
}
use of org.bboxdb.distribution.membership.BBoxDBInstance in project bboxdb by jnidzwetzki.
the class TestRoundRobinRessourcePlacement method testRoundRobinPlacement1.
/**
* Test round robin placement 1
* @throws ResourceAllocationException
*/
@Test(timeout = 60000)
public void testRoundRobinPlacement1() 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));
Assert.assertEquals(systems.get(1), resourcePlacementStrategy.getInstancesForNewRessource(systems));
Assert.assertEquals(systems.get(2), resourcePlacementStrategy.getInstancesForNewRessource(systems));
Assert.assertEquals(systems.get(3), resourcePlacementStrategy.getInstancesForNewRessource(systems));
Assert.assertEquals(systems.get(0), resourcePlacementStrategy.getInstancesForNewRessource(systems));
}
use of org.bboxdb.distribution.membership.BBoxDBInstance in project bboxdb by jnidzwetzki.
the class DistributedRecoveryService method init.
@Override
public void init() {
try {
final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
final ZookeeperBBoxDBInstanceAdapter zookeeperBBoxDBInstanceAdapter = new ZookeeperBBoxDBInstanceAdapter(zookeeperClient);
final BBoxDBInstance distributedInstance = ZookeeperClientFactory.getLocalInstanceName();
zookeeperBBoxDBInstanceAdapter.updateStateData(distributedInstance, BBoxDBInstanceState.OUTDATED);
logger.info("Running recovery for local stored data");
runRecovery();
logger.info("Running recovery for local stored data DONE");
zookeeperBBoxDBInstanceAdapter.updateStateData(distributedInstance, BBoxDBInstanceState.READY);
} catch (ZookeeperException | ZookeeperNotFoundException e) {
logger.error("Got an exception during recovery: ", e);
}
}
Aggregations