use of org.bboxdb.network.client.future.TupleListFuture in project bboxdb by jnidzwetzki.
the class DistributedRecoveryService method runRecoveryForTable.
/**
* Run the recovery for a given table
* @param ssTableName
* @param outdatedDistributionRegion
* @param connection
* @throws StorageManagerException
* @throws InterruptedException
* @throws ExecutionException
* @throws RejectedException
*/
protected void runRecoveryForTable(final TupleStoreName ssTableName, final OutdatedDistributionRegion outdatedDistributionRegion, final BBoxDBClient connection) throws StorageManagerException, InterruptedException, ExecutionException, RejectedException {
final String sstableName = ssTableName.getFullname();
logger.info("Recovery: starting recovery for table {}", sstableName);
final TupleStoreManager tableManager = storageRegistry.getTupleStoreManager(ssTableName);
// Even with NTP, the clock of the nodes can have a delta.
// We subtract this delta from the checkpoint timestamp to ensure
// that all tuples for the recovery are requested
final long requestTupleTimestamp = outdatedDistributionRegion.getLocalVersion() - Const.MAX_NODE_CLOCK_DELTA;
final TupleListFuture result = connection.queryInsertedTime(sstableName, requestTupleTimestamp);
result.waitForAll();
if (result.isFailed()) {
logger.warn("Recovery: Failed result for table {} - Some tuples could not be received!", sstableName);
return;
}
long insertedTuples = 0;
for (final Tuple tuple : result) {
tableManager.put(tuple);
insertedTuples++;
}
logger.info("Recovery: successfully inserted {} tuples into table {}", insertedTuples, sstableName);
}
use of org.bboxdb.network.client.future.TupleListFuture 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);
}
}
Aggregations