Search in sources :

Example 21 with BBoxDBInstance

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));
}
Also used : ArrayList(java.util.ArrayList) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Example 22 with BBoxDBInstance

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));
    }
}
Also used : ArrayList(java.util.ArrayList) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Example 23 with BBoxDBInstance

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));
}
Also used : ArrayList(java.util.ArrayList) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Example 24 with BBoxDBInstance

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));
}
Also used : ArrayList(java.util.ArrayList) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Example 25 with BBoxDBInstance

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);
    }
}
Also used : ZookeeperClient(org.bboxdb.distribution.zookeeper.ZookeeperClient) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) ZookeeperBBoxDBInstanceAdapter(org.bboxdb.distribution.membership.ZookeeperBBoxDBInstanceAdapter) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance)

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