Search in sources :

Example 31 with TupleListFuture

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);
}
Also used : TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) Tuple(org.bboxdb.storage.entity.Tuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Example 32 with TupleListFuture

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);
    }
}
Also used : BBoxDBClient(org.bboxdb.network.client.BBoxDBClient) BoundingBox(org.bboxdb.commons.math.BoundingBox) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) BBoxDBConnection(org.bboxdb.network.client.BBoxDBConnection) StorageManagerException(org.bboxdb.storage.StorageManagerException) Tuple(org.bboxdb.storage.entity.Tuple)

Aggregations

TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)32 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)18 Tuple (org.bboxdb.storage.entity.Tuple)18 BoundingBox (org.bboxdb.commons.math.BoundingBox)11 NetworkOperationFuture (org.bboxdb.network.client.future.NetworkOperationFuture)11 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)10 RoutingHeader (org.bboxdb.network.routing.RoutingHeader)10 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)10 DoNothingDuplicateResolver (org.bboxdb.storage.sstable.duplicateresolver.DoNothingDuplicateResolver)9 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)8 ArrayList (java.util.ArrayList)6 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)6 List (java.util.List)5 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)5 BBoxDBException (org.bboxdb.misc.BBoxDBException)5 BBoxDBConnection (org.bboxdb.network.client.BBoxDBConnection)5 RoutingHop (org.bboxdb.network.routing.RoutingHop)5 Test (org.junit.Test)5 BBoxDBClient (org.bboxdb.network.client.BBoxDBClient)4 BBoxDB (org.bboxdb.network.client.BBoxDB)2