Search in sources :

Example 11 with NetworkOperationFuture

use of org.bboxdb.network.client.future.NetworkOperationFuture in project bboxdb by jnidzwetzki.

the class BBoxDBClient method sendKeepAlivePackage.

/**
 * Send a keep alive package with some gossip
 * @param tablename
 * @param tuples
 * @return
 */
public EmptyResultFuture sendKeepAlivePackage(final String tablename, final List<Tuple> tuples) {
    final NetworkOperationFuture future = getKeepAliveFuture(tablename, tuples);
    final EmptyResultFuture resultFuture = new EmptyResultFuture(future);
    // Unsuccesfull means only we have to send gossip data
    resultFuture.setRetryPolicy(FutureRetryPolicy.RETRY_POLICY_NONE);
    return resultFuture;
}
Also used : NetworkOperationFuture(org.bboxdb.network.client.future.NetworkOperationFuture) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 12 with NetworkOperationFuture

use of org.bboxdb.network.client.future.NetworkOperationFuture in project bboxdb by jnidzwetzki.

the class BBoxDBClient method getInsertTupleFuture.

/**
 * @param table
 * @param tuple
 * @param routingHeader
 * @return
 */
public NetworkOperationFuture getInsertTupleFuture(final String table, final Tuple tuple, final RoutingHeader routingHeader) {
    return new NetworkOperationFuture(connection, () -> {
        final TupleStoreName ssTableName = new TupleStoreName(table);
        final short sequenceNumber = connection.getNextSequenceNumber();
        return new InsertTupleRequest(sequenceNumber, routingHeader, ssTableName, tuple);
    });
}
Also used : NetworkOperationFuture(org.bboxdb.network.client.future.NetworkOperationFuture) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) InsertTupleRequest(org.bboxdb.network.packages.request.InsertTupleRequest)

Example 13 with NetworkOperationFuture

use of org.bboxdb.network.client.future.NetworkOperationFuture in project bboxdb by jnidzwetzki.

the class BBoxDBCluster method queryVersionTime.

@Override
public TupleListFuture queryVersionTime(final String table, final long timestamp) throws BBoxDBException {
    if (membershipConnectionService.getNumberOfConnections() == 0) {
        throw new BBoxDBException("queryTime called, but connection list is empty");
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Query by for timestamp {} in table {}", timestamp, table);
    }
    final DistributionRegion distributionRegion = getRootNode(table);
    final Supplier<List<NetworkOperationFuture>> futureProvider = () -> {
        final List<RoutingHop> hops = RoutingHopHelper.getRoutingHopsForRead(distributionRegion, BoundingBox.FULL_SPACE);
        final List<NetworkOperationFuture> futures = new ArrayList<>();
        for (final RoutingHop hop : hops) {
            final BBoxDBInstance instance = hop.getDistributedInstance();
            final BBoxDBConnection connection = membershipConnectionService.getConnectionForInstance(instance);
            final RoutingHeader routingHeader = new RoutingHeader((short) 0, Arrays.asList(hop));
            final NetworkOperationFuture future = connection.getBboxDBClient().getVersionTimeFuture(table, timestamp, routingHeader);
            futures.add(future);
        }
        return futures;
    };
    return new TupleListFuture(futureProvider, new DoNothingDuplicateResolver(), table);
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) JoinedTupleListFuture(org.bboxdb.network.client.future.JoinedTupleListFuture) NetworkOperationFuture(org.bboxdb.network.client.future.NetworkOperationFuture) RoutingHeader(org.bboxdb.network.routing.RoutingHeader) DoNothingDuplicateResolver(org.bboxdb.storage.sstable.duplicateresolver.DoNothingDuplicateResolver) ArrayList(java.util.ArrayList) List(java.util.List) RoutingHop(org.bboxdb.network.routing.RoutingHop) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) BBoxDBException(org.bboxdb.misc.BBoxDBException)

Example 14 with NetworkOperationFuture

use of org.bboxdb.network.client.future.NetworkOperationFuture in project bboxdb by jnidzwetzki.

the class BBoxDBCluster method lockTuple.

@Override
public EmptyResultFuture lockTuple(final String table, final Tuple tuple) throws BBoxDBException {
    final DistributionRegion distributionRegion = getRootNode(table);
    final Supplier<List<NetworkOperationFuture>> supplier = () -> {
        final List<RoutingHop> hops = RoutingHopHelper.getRoutingHopsForWrite(distributionRegion, tuple.getBoundingBox());
        final List<NetworkOperationFuture> futures = new ArrayList<>();
        for (final RoutingHop hop : hops) {
            final BBoxDBInstance instance = hop.getDistributedInstance();
            final BBoxDBConnection connection = membershipConnectionService.getConnectionForInstance(instance);
            final RoutingHeader routingHeader = new RoutingHeader((short) 0, Arrays.asList(hop));
            final NetworkOperationFuture future = connection.getBboxDBClient().createLockTupleFuture(table, tuple, routingHeader);
            futures.add(future);
        }
        return futures;
    };
    // When version locking fails, try again with another version
    return new EmptyResultFuture(supplier, FutureRetryPolicy.RETRY_POLICY_NONE);
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) NetworkOperationFuture(org.bboxdb.network.client.future.NetworkOperationFuture) RoutingHeader(org.bboxdb.network.routing.RoutingHeader) ArrayList(java.util.ArrayList) List(java.util.List) RoutingHop(org.bboxdb.network.routing.RoutingHop) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 15 with NetworkOperationFuture

use of org.bboxdb.network.client.future.NetworkOperationFuture in project bboxdb by jnidzwetzki.

the class BBoxDBCluster method queryBoundingBox.

@Override
public TupleListFuture queryBoundingBox(final String table, final BoundingBox boundingBox) throws BBoxDBException {
    if (logger.isDebugEnabled()) {
        logger.debug("Query by for bounding box {} in table {}", boundingBox, table);
    }
    final DistributionRegion distributionRegion = getRootNode(table);
    final Supplier<List<NetworkOperationFuture>> futureProvider = () -> {
        final List<RoutingHop> hops = RoutingHopHelper.getRoutingHopsForRead(distributionRegion, boundingBox);
        final List<NetworkOperationFuture> futures = new ArrayList<>();
        for (final RoutingHop hop : hops) {
            final BBoxDBInstance instance = hop.getDistributedInstance();
            final BBoxDBConnection connection = membershipConnectionService.getConnectionForInstance(instance);
            final RoutingHeader routingHeader = new RoutingHeader((short) 0, Arrays.asList(hop));
            final NetworkOperationFuture future = connection.getBboxDBClient().getQueryBoundingBoxFuture(table, boundingBox, routingHeader);
            futures.add(future);
        }
        return futures;
    };
    return new TupleListFuture(futureProvider, new DoNothingDuplicateResolver(), table);
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) JoinedTupleListFuture(org.bboxdb.network.client.future.JoinedTupleListFuture) NetworkOperationFuture(org.bboxdb.network.client.future.NetworkOperationFuture) RoutingHeader(org.bboxdb.network.routing.RoutingHeader) DoNothingDuplicateResolver(org.bboxdb.storage.sstable.duplicateresolver.DoNothingDuplicateResolver) ArrayList(java.util.ArrayList) List(java.util.List) RoutingHop(org.bboxdb.network.routing.RoutingHop) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance)

Aggregations

NetworkOperationFuture (org.bboxdb.network.client.future.NetworkOperationFuture)31 RoutingHeader (org.bboxdb.network.routing.RoutingHeader)16 List (java.util.List)12 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)12 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)11 DoNothingDuplicateResolver (org.bboxdb.storage.sstable.duplicateresolver.DoNothingDuplicateResolver)9 ArrayList (java.util.ArrayList)8 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)8 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)8 RoutingHop (org.bboxdb.network.routing.RoutingHop)8 Test (org.junit.Test)8 OperationFutureImpl (org.bboxdb.network.client.future.OperationFutureImpl)6 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)5 BBoxDBException (org.bboxdb.misc.BBoxDBException)4 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)3 BBoxDBConnection (org.bboxdb.network.client.BBoxDBConnection)2 NetworkRequestPackage (org.bboxdb.network.packages.NetworkRequestPackage)2 Tuple (org.bboxdb.storage.entity.Tuple)2 IOException (java.io.IOException)1 SocketException (java.net.SocketException)1