Search in sources :

Example 21 with TupleListFuture

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

the class BBoxDBClient method queryBoundingBoxAndTime.

/* (non-Javadoc)
	 * @see org.bboxdb.network.client.BBoxDB#queryBoundingBoxAndTime(java.lang.String, org.bboxdb.storage.entity.BoundingBox)
	 */
@Override
public TupleListFuture queryBoundingBoxAndTime(final String table, final BoundingBox boundingBox, final long timestamp) {
    final RoutingHeader routingHeader = RoutingHeaderHelper.getRoutingHeaderForLocalSystemReadNE(table, boundingBox, false, connection.getServerAddress());
    final NetworkOperationFuture future = getBoundingBoxAndTimeFuture(table, boundingBox, timestamp, routingHeader);
    return new TupleListFuture(future, new DoNothingDuplicateResolver(), table);
}
Also used : 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)

Example 22 with TupleListFuture

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

the class BBoxDBCluster method queryInsertedTime.

@Override
public TupleListFuture queryInsertedTime(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().getInsertedTimeFuture(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 23 with TupleListFuture

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

the class BBoxDBCluster method queryKey.

@Override
public TupleListFuture queryKey(final String table, final String key) throws BBoxDBException {
    if (logger.isDebugEnabled()) {
        logger.debug("Query by for key {} in table {}", key, table);
    }
    final DeletedTuple tuple = new DeletedTuple(key);
    final DistributionRegion distributionRegion = getRootNode(table);
    final Supplier<List<NetworkOperationFuture>> futureProvider = () -> {
        final List<RoutingHop> hops = RoutingHopHelper.getRoutingHopsForRead(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().getQueryKeyFuture(table, key, routingHeader);
            futures.add(future);
        }
        return futures;
    };
    final DuplicateResolver<Tuple> duplicateResolver = TupleStoreConfigurationCache.getInstance().getDuplicateResolverForTupleStore(table);
    return new TupleListFuture(futureProvider, duplicateResolver, 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) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) ArrayList(java.util.ArrayList) List(java.util.List) RoutingHop(org.bboxdb.network.routing.RoutingHop) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple)

Example 24 with TupleListFuture

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

the class BBoxDBCluster method queryBoundingBoxAndTime.

@Override
public TupleListFuture queryBoundingBoxAndTime(final String table, final BoundingBox boundingBox, final long timestamp) throws BBoxDBException {
    if (membershipConnectionService.getNumberOfConnections() == 0) {
        throw new BBoxDBException("queryBoundingBoxAndTime called, but connection list is empty");
    }
    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().getBoundingBoxAndTimeFuture(table, boundingBox, 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 25 with TupleListFuture

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

the class DistributedSelftest method queryForExistingTuplesByTime.

/**
 * Execute a time query
 * @param bboxdbClient
 * @throws ExecutionException
 * @throws InterruptedException
 * @throws BBoxDBException
 */
private static void queryForExistingTuplesByTime(final BBoxDBCluster bboxdbClient) throws InterruptedException, ExecutionException, BBoxDBException {
    logger.info("Executing time query");
    final TupleListFuture queryResult = bboxdbClient.queryVersionTime(TABLE, 0);
    queryResult.waitForAll();
    if (queryResult.isFailed()) {
        logger.error("Time query result is failed");
        logger.error(queryResult.getAllMessages());
        System.exit(-1);
    }
    final int totalTuples = Iterators.size(queryResult.iterator());
    if (totalTuples != NUMBER_OF_OPERATIONS) {
        logger.error("Got {} tuples back, but expected {}", totalTuples, NUMBER_OF_OPERATIONS);
        System.exit(-1);
    }
}
Also used : TupleListFuture(org.bboxdb.network.client.future.TupleListFuture)

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