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