use of org.bboxdb.network.client.BBoxDBConnection in project bboxdb by jnidzwetzki.
the class RegionMerger method mergeDataByNetworkRead.
/**
* Merge the region by a network read
*
* @param region
* @param tupleStoreName
* @param tupleRedistributor
* @param childRegion
* @throws InterruptedException
* @throws StorageManagerException
* @throws Exception
*/
private void mergeDataByNetworkRead(final DistributionRegion region, final TupleStoreName tupleStoreName, final TupleRedistributor tupleRedistributor, final DistributionRegion childRegion) throws InterruptedException, StorageManagerException {
final List<BBoxDBInstance> systems = childRegion.getSystems();
assert (!systems.isEmpty()) : "Systems can not be empty";
final BBoxDBInstance firstSystem = systems.get(0);
final BBoxDBConnection connection = MembershipConnectionService.getInstance().getConnectionForInstance(firstSystem);
assert (connection != null) : "Connection can not be null: " + firstSystem.getStringValue();
final BoundingBox bbox = childRegion.getConveringBox();
final String fullname = tupleStoreName.getFullname();
final BBoxDBClient bboxDBClient = connection.getBboxDBClient();
final TupleListFuture result = bboxDBClient.queryBoundingBox(fullname, bbox);
result.waitForAll();
if (result.isFailed()) {
throw new StorageManagerException("Exception while fetching tuples: " + result.getAllMessages());
}
for (final Tuple tuple : result) {
tupleRedistributor.redistributeTuple(tuple);
}
}
use of org.bboxdb.network.client.BBoxDBConnection in project bboxdb by jnidzwetzki.
the class MembershipConnectionService method terminateConnection.
/**
* Terminate the connection to a missing bboxdb system
* @param distributedInstance
*/
private synchronized void terminateConnection(final BBoxDBInstance distributedInstance) {
final String instanceName = distributedInstance.getStringValue();
if (!serverConnections.containsKey(distributedInstance.getInetSocketAddress())) {
return;
}
logger.info("Closing connection to dead instance: {}", instanceName);
knownInstances.remove(distributedInstance.getInetSocketAddress());
final BBoxDBConnection connection = serverConnections.remove(distributedInstance.getInetSocketAddress());
connection.terminateConnection();
}
Aggregations