use of org.bboxdb.network.client.BBoxDBClient in project bboxdb by jnidzwetzki.
the class TestNetworkCommunication method testEmptyBoundingBoxQuery.
/**
* Start a bounding box query without inserted tuples
* @throws ExecutionException
* @throws InterruptedException
* @throws BBoxDBException
*/
@Test(timeout = 60000)
public void testEmptyBoundingBoxQuery() throws InterruptedException, ExecutionException, BBoxDBException {
final BBoxDBConnection bboxdbConnection = connectToServer();
final BBoxDBClient bboxDBClient = bboxdbConnection.getBboxDBClient();
NetworkQueryHelper.testBoundingBoxQuery(bboxDBClient, DISTRIBUTION_GROUP, false);
disconnect(bboxDBClient);
}
use of org.bboxdb.network.client.BBoxDBClient in project bboxdb by jnidzwetzki.
the class MembershipConnectionService method createConnection.
/**
* Create a new connection to the given instance
* @param distributedInstance
*/
private void createConnection(final BBoxDBInstance distributedInstance) {
final String instanceName = distributedInstance.getStringValue();
if (serverConnections.containsKey(distributedInstance.getInetSocketAddress())) {
logger.info("We have already a connection to: {}", instanceName);
return;
}
if (blacklist.contains(distributedInstance.getInetSocketAddress())) {
logger.info("Not creating a connection to the blacklisted system: {}", instanceName);
return;
}
logger.info("Opening connection to instance: {}", instanceName);
final BBoxDBConnection connection = new BBoxDBConnection(distributedInstance.getInetSocketAddress());
final BBoxDBClient client = connection.getBboxDBClient();
client.setPagingEnabled(pagingEnabled);
client.setTuplesPerPage(tuplesPerPage);
client.setTupleStoreManagerRegistry(tupleStoreManagerRegistry);
final boolean result = connection.connect();
if (!result) {
logger.info("Unable to open connection to: {}", instanceName);
} else {
logger.info("Connection successfully established: {}", instanceName);
serverConnections.put(distributedInstance.getInetSocketAddress(), connection);
knownInstances.put(distributedInstance.getInetSocketAddress(), distributedInstance);
}
}
use of org.bboxdb.network.client.BBoxDBClient in project bboxdb by jnidzwetzki.
the class PackageRouter method sendInsertPackage.
/**
* @param insertTupleRequest
* @return
* @throws InterruptedException
* @throws PackageEncodeException
* @throws TimeoutException
* @throws ExecutionException
*/
protected boolean sendInsertPackage(final InsertTupleRequest insertTupleRequest) throws InterruptedException, PackageEncodeException {
final RoutingHeader routingHeader = insertTupleRequest.getRoutingHeader();
final RoutingHop routingHop = routingHeader.getRoutingHop();
final BBoxDBInstance receiverInstance = routingHop.getDistributedInstance();
final BBoxDBConnection connection = MembershipConnectionService.getInstance().getConnectionForInstance(receiverInstance);
if (connection == null) {
logger.error("Unable to get a connection to system: {}", receiverInstance);
return false;
}
final BBoxDBClient bboxDBClient = connection.getBboxDBClient();
final EmptyResultFuture insertFuture = bboxDBClient.insertTuple(insertTupleRequest.getTable().getFullname(), insertTupleRequest.getTuple(), routingHeader);
try {
insertFuture.waitForAll(ROUTING_TIMEOUT_IN_SEC, TimeUnit.SECONDS);
} catch (TimeoutException e) {
logger.warn("Routing timeout, retry routing: {}", connection);
return false;
}
final boolean operationSuccess = (!insertFuture.isFailed());
return operationSuccess;
}
use of org.bboxdb.network.client.BBoxDBClient in project bboxdb by jnidzwetzki.
the class TupleListFuture method performReadRepairForResult.
/**
* Perform read repair for the given result
*
* @param allTuples
* @param resultId
* @throws InterruptedException
* @throws BBoxDBException
* @throws ZookeeperException
*/
private void performReadRepairForResult(final List<Tuple> allTuples, int resultId) throws InterruptedException, BBoxDBException, ZookeeperException {
final List<Tuple> tupleResult = get(resultId);
final BBoxDBConnection bboxDBConnection = getConnection(resultId);
if (bboxDBConnection == null) {
// Unable to perform read repair when the connection is not known
return;
}
for (final Tuple tuple : allTuples) {
final RoutingHeader routingHeader = RoutingHeaderHelper.getRoutingHeaderForLocalSystem(tablename, tuple.getBoundingBox(), true, bboxDBConnection.getServerAddress(), true);
// System is not responsible for the tuple
if (routingHeader.getHopCount() == 0) {
return;
}
if (!tupleResult.contains(tuple)) {
logger.info("Tuple {} is not contained in result {} from server {}, " + "performing read repair", tuple, tupleResult, bboxDBConnection.getConnectionName());
final BBoxDBClient bboxDBClient = bboxDBConnection.getBboxDBClient();
bboxDBClient.insertTuple(tablename, tuple, routingHeader);
}
}
}
use of org.bboxdb.network.client.BBoxDBClient in project bboxdb by jnidzwetzki.
the class TestNetworkCommunication method testCreateDistributionGroupTwoTimes.
/**
* Test create a distribution group two times
* @throws BBoxDBException
* @throws InterruptedException
*/
@Test(timeout = 60000)
public void testCreateDistributionGroupTwoTimes() throws BBoxDBException, InterruptedException {
final BBoxDBConnection bboxdbConnection = connectToServer();
final BBoxDBClient bboxDBClient = bboxdbConnection.getBboxDBClient();
// Create distribution group
final DistributionGroupConfiguration configuration = DistributionGroupConfigurationBuilder.create(2).withReplicationFactor((short) 1).build();
final EmptyResultFuture resultCreate = bboxDBClient.createDistributionGroup(DISTRIBUTION_GROUP, configuration);
// Prevent retries
resultCreate.setRetryPolicy(FutureRetryPolicy.RETRY_POLICY_NONE);
resultCreate.waitForAll();
Assert.assertTrue(resultCreate.isFailed());
Assert.assertEquals(ErrorMessages.ERROR_DGROUP_EXISTS, resultCreate.getMessage(0));
Assert.assertTrue(bboxdbConnection.getConnectionState().isInRunningState());
disconnect(bboxDBClient);
}
Aggregations