Search in sources :

Example 1 with BBoxDBInstance

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

the class RoutingHeader method setRoutingList.

/**
 * Set the list with hops (as string list)
 * @param stringRoutingList
 */
public void setRoutingList(final String stringRoutingList) {
    routingList.clear();
    // Routing list is empty
    if (stringRoutingList == null || stringRoutingList.length() == 0) {
        return;
    }
    final String[] hostParts = stringRoutingList.split(SEPARATOR_CHAR_HOST);
    for (final String hostPart : hostParts) {
        try {
            final String[] regionParts = hostPart.split(SEPARATOR_CHAR_REGION);
            assert (regionParts.length > 1) : "Unable to split into regions: " + hostPart;
            final BBoxDBInstance distributedInstance = new BBoxDBInstance(regionParts[0]);
            final List<Long> distributionRegions = new ArrayList<>();
            for (int i = 1; i < regionParts.length; i++) {
                final long distributionRegion = Long.parseLong(regionParts[i]);
                distributionRegions.add(distributionRegion);
            }
            final RoutingHop routingHop = new RoutingHop(distributedInstance, distributionRegions);
            routingList.add(routingHop);
        } catch (IllegalArgumentException e) {
            logger.warn("Unable to parse as distributed instance: " + hostPart);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance)

Example 2 with BBoxDBInstance

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

the class PackageRouter method checkLocalSystemNameMatchesAndThrowException.

/**
 * Ensure that the package is routed to the correct system
 * @param localHop
 * @throws BBoxDBException
 */
public static void checkLocalSystemNameMatchesAndThrowException(final RoutingHop localHop) throws BBoxDBException {
    final BBoxDBInstance localInstanceName = ZookeeperClientFactory.getLocalInstanceName();
    final BBoxDBInstance routingInstanceName = localHop.getDistributedInstance();
    if (!checkLocalSystemNameMatches(localHop)) {
        throw new BBoxDBException("Routing hop " + routingInstanceName + " does not match local host " + localInstanceName);
    }
}
Also used : BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) BBoxDBException(org.bboxdb.misc.BBoxDBException)

Example 3 with BBoxDBInstance

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

the class TestBBoxDBInstance method testCompare.

@Test(timeout = 60000)
public void testCompare() {
    final BBoxDBInstance bBoxDBInstance1 = new BBoxDBInstance("127.0.0.1:10000");
    final BBoxDBInstance bBoxDBInstance2 = new BBoxDBInstance("127.0.0.2:10000");
    Assert.assertTrue(bBoxDBInstance1.compareTo(bBoxDBInstance2) < 0);
    Assert.assertTrue(bBoxDBInstance2.compareTo(bBoxDBInstance1) > 0);
    Assert.assertTrue(bBoxDBInstance1.compareTo(bBoxDBInstance1) == 0);
}
Also used : BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Example 4 with BBoxDBInstance

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

the class TestBBoxDBInstance method testGetter.

@Test(timeout = 60000)
public void testGetter() {
    final BBoxDBInstance bBoxDBInstance1 = new BBoxDBInstance("127.0.0.1:10000");
    Assert.assertEquals("127.0.0.1", bBoxDBInstance1.getIp());
    Assert.assertEquals(10000, bBoxDBInstance1.getPort());
    Assert.assertEquals(BBoxDBInstance.UNKOWN_PROPERTY, bBoxDBInstance1.getVersion());
}
Also used : BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Example 5 with BBoxDBInstance

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

the class TestBBoxDBInstance method testSocketEquals.

@Test(timeout = 60000)
public void testSocketEquals() {
    final BBoxDBInstance bBoxDBInstance1 = new BBoxDBInstance("127.0.0.1:10000");
    Assert.assertFalse(bBoxDBInstance1.socketAddressEquals(null));
}
Also used : 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