Search in sources :

Example 11 with EmptyResultFuture

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

the class TestBBoxDBCluster method testInsertAndBoundingBoxContinousQuery.

/**
 * Insert some tuples and start a bounding box query afterwards
 * @throws ExecutionException
 * @throws InterruptedException
 * @throws BBoxDBException
 */
@Test(timeout = 60000)
public void testInsertAndBoundingBoxContinousQuery() throws InterruptedException, ExecutionException, BBoxDBException {
    final BBoxDB bboxDBClient = connectToServer();
    final String table = DISTRIBUTION_GROUP + "_relation9991";
    // Create table
    final EmptyResultFuture resultCreateTable = bboxDBClient.createTable(table, new TupleStoreConfiguration());
    resultCreateTable.waitForAll();
    Assert.assertFalse(resultCreateTable.isFailed());
    // Execute query
    final TupleListFuture result = bboxDBClient.queryBoundingBoxContinuous(table, new BoundingBox(-1d, 2d, -1d, 2d));
    Assert.assertFalse(result.isFailed());
    disconnect(bboxDBClient);
}
Also used : BBoxDB(org.bboxdb.network.client.BBoxDB) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) BoundingBox(org.bboxdb.commons.math.BoundingBox) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture) Test(org.junit.Test)

Example 12 with EmptyResultFuture

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

the class TestHelper method recreateDistributionGroup.

/**
 * Recreate the given distribution group
 * @param client
 * @param DISTRIBUTION_GROUP
 * @throws InterruptedException
 * @throws BBoxDBException
 */
public static void recreateDistributionGroup(final BBoxDB client, final String DISTRIBUTION_GROUP) throws InterruptedException, BBoxDBException {
    // Delete distribution group
    final EmptyResultFuture resultDelete = client.deleteDistributionGroup(DISTRIBUTION_GROUP);
    resultDelete.waitForAll();
    Assert.assertFalse(resultDelete.isFailed());
    // Create distribution group
    final DistributionGroupConfiguration configuration = DistributionGroupConfigurationBuilder.create(2).withReplicationFactor((short) 1).build();
    final EmptyResultFuture resultCreate = client.createDistributionGroup(DISTRIBUTION_GROUP, configuration);
    resultCreate.waitForAll();
    Assert.assertFalse(resultCreate.isFailed());
}
Also used : DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 13 with EmptyResultFuture

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

the class DistributedSelftest method recreateDistributionGroup.

/**
 * Recreate the distribution group
 * @param bboxdbCluster
 * @throws BBoxDBException
 * @throws InterruptedException
 * @throws ExecutionException
 */
private static void recreateDistributionGroup(final BBoxDBCluster bboxdbCluster) throws BBoxDBException, InterruptedException, ExecutionException {
    logger.info("Delete old distribution group: " + DISTRIBUTION_GROUP);
    final EmptyResultFuture deleteFuture = bboxdbCluster.deleteDistributionGroup(DISTRIBUTION_GROUP);
    deleteFuture.waitForAll();
    if (deleteFuture.isFailed()) {
        logger.error("Unable to delete distribution group: " + DISTRIBUTION_GROUP);
        logger.error(deleteFuture.getAllMessages());
        System.exit(-1);
    }
    // Wait for distribution group to settle
    Thread.sleep(5000);
    logger.info("Create new distribution group: " + DISTRIBUTION_GROUP);
    final DistributionGroupConfiguration configuration = DistributionGroupConfigurationBuilder.create(2).withReplicationFactor((short) 2).build();
    final EmptyResultFuture createFuture = bboxdbCluster.createDistributionGroup(DISTRIBUTION_GROUP, configuration);
    createFuture.waitForAll();
    if (createFuture.isFailed()) {
        logger.error("Unable to create distribution group: " + DISTRIBUTION_GROUP);
        logger.error(createFuture.getAllMessages());
        System.exit(-1);
    }
    // Wait for distribution group to appear
    Thread.sleep(5000);
}
Also used : DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 14 with EmptyResultFuture

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

the class DistributedSelftest method deleteTuples.

/**
 * Delete the stored tuples
 * @param bboxdbClient
 * @throws InterruptedException
 * @throws BBoxDBException
 * @throws ExecutionException
 */
private static void deleteTuples(final BBoxDBCluster bboxdbClient) throws InterruptedException, BBoxDBException, ExecutionException {
    logger.info("Deleting tuples");
    for (int i = 0; i < NUMBER_OF_OPERATIONS; i++) {
        final String key = Integer.toString(i);
        final EmptyResultFuture deletionResult = bboxdbClient.deleteTuple(TABLE, key);
        deletionResult.waitForAll();
        if (deletionResult.isFailed()) {
            logger.error("Got an error while deleting: {} ", key);
            logger.error(deletionResult.getAllMessages());
            System.exit(-1);
        }
    }
}
Also used : EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 15 with EmptyResultFuture

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

the class DistributedSelftest method insertNewTuples.

/**
 * Insert new tuples
 * @param bboxdbClient
 * @throws InterruptedException
 * @throws ExecutionException
 * @throws BBoxDBException
 */
private static void insertNewTuples(final BBoxDBCluster bboxdbClient) throws InterruptedException, ExecutionException, BBoxDBException {
    logger.info("Inserting new tuples");
    for (int i = 0; i < NUMBER_OF_OPERATIONS; i++) {
        final String key = Integer.toString(i);
        final Tuple myTuple = new Tuple(key, new BoundingBox(1.0d, 2.0d, 1.0d, 2.0d), "test".getBytes());
        final EmptyResultFuture insertResult = bboxdbClient.insertTuple(TABLE, myTuple);
        insertResult.waitForAll();
        if (insertResult.isFailed()) {
            logger.error("Got an error during tuple insert: ", insertResult.getAllMessages());
            System.exit(-1);
        }
    }
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) Tuple(org.bboxdb.storage.entity.Tuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Aggregations

EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)43 Tuple (org.bboxdb.storage.entity.Tuple)17 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)15 BoundingBox (org.bboxdb.commons.math.BoundingBox)11 BBoxDBException (org.bboxdb.misc.BBoxDBException)11 Test (org.junit.Test)11 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)10 DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)9 BBoxDBClient (org.bboxdb.network.client.BBoxDBClient)8 BBoxDBConnection (org.bboxdb.network.client.BBoxDBConnection)8 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)8 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)7 NetworkOperationFuture (org.bboxdb.network.client.future.NetworkOperationFuture)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)3 FixedSizeFutureStore (org.bboxdb.network.client.tools.FixedSizeFutureStore)3 RoutingHeader (org.bboxdb.network.routing.RoutingHeader)3 List (java.util.List)2