Search in sources :

Example 21 with EmptyResultFuture

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

the class BenchmarkInsertPerformance method runBenchmark.

@Override
public void runBenchmark() throws InterruptedException, ExecutionException, BBoxDBException {
    // Number of tuples
    final int tuples = 5000000;
    // Remove old data
    final EmptyResultFuture deleteResult = bboxdbClient.deleteDistributionGroup(DISTRIBUTION_GROUP);
    deleteResult.waitForAll();
    // Create a new distribution group
    final DistributionGroupConfiguration config = DistributionGroupConfigurationBuilder.create(3).withReplicationFactor((short) 3).build();
    final EmptyResultFuture createResult = bboxdbClient.createDistributionGroup(DISTRIBUTION_GROUP, config);
    createResult.waitForAll();
    final Random bbBoxRandom = new Random();
    // Insert the tuples
    for (; insertedTuples.get() < tuples; insertedTuples.incrementAndGet()) {
        final double x = Math.abs(bbBoxRandom.nextFloat() % 100000.0 * 1000);
        final double y = Math.abs(bbBoxRandom.nextFloat() % 100000.0 * 1000);
        final double z = Math.abs(bbBoxRandom.nextFloat() % 100000.0 * 1000);
        final BoundingBox boundingBox = new BoundingBox(x, x + 1, y, y + 1, z, z + 1);
        final EmptyResultFuture insertFuture = bboxdbClient.insertTuple(TABLE, new Tuple(Integer.toString(insertedTuples.get()), boundingBox, "abcdef".getBytes()));
        // register pending future
        pendingFutures.put(insertFuture);
    }
}
Also used : Random(java.util.Random) BoundingBox(org.bboxdb.commons.math.BoundingBox) DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) Tuple(org.bboxdb.storage.entity.Tuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 22 with EmptyResultFuture

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

the class BenchmarkKeyQueryPerformance method prepare.

@Override
protected void prepare() throws Exception {
    super.prepare();
    // Remove old data
    final EmptyResultFuture deleteResult = bboxdbClient.deleteDistributionGroup(DISTRIBUTION_GROUP);
    deleteResult.waitForAll();
    // Create a new distribution group
    final DistributionGroupConfiguration config = DistributionGroupConfigurationBuilder.create(3).withReplicationFactor((short) 3).build();
    final EmptyResultFuture createResult = bboxdbClient.createDistributionGroup(DISTRIBUTION_GROUP, config);
    createResult.waitForAll();
    logger.info("Inserting {} tuples", tuplesToInsert);
    // Insert the tuples
    for (; insertedTuples.get() < tuplesToInsert; insertedTuples.incrementAndGet()) {
        bboxdbClient.insertTuple(TABLE, new Tuple(Integer.toString(insertedTuples.get()), BoundingBox.FULL_SPACE, "abcdef".getBytes()));
    }
    // Wait for requests to settle
    logger.info("Wait for insert requests to settle");
    while (bboxdbClient.getInFlightCalls() != 0) {
        logger.info("{} tuples are pending", bboxdbClient.getInFlightCalls());
        Thread.sleep(1000);
    }
    logger.info("All insert requests are settled");
}
Also used : DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) Tuple(org.bboxdb.storage.entity.Tuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 23 with EmptyResultFuture

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

the class DataRedistributionLoader method loadFile.

/**
 * Load the given file
 * @param id
 * @return
 * @throws InterruptedException
 */
private boolean loadFile(final int fileid) throws InterruptedException {
    final String filename = files[fileid];
    if (loadedFiles.contains(filename)) {
        System.err.println("File " + filename + " is already loaded");
        return false;
    }
    System.out.println("Loading content from: " + filename);
    final AtomicInteger lineNumber = new AtomicInteger(0);
    final String prefix = Integer.toString(fileid) + "_";
    try (final Stream<String> lines = Files.lines(Paths.get(filename))) {
        lines.forEach(l -> {
            final String key = prefix + lineNumber.getAndIncrement();
            final Tuple tuple = tupleBuilder.buildTuple(key, l);
            try {
                if (tuple != null) {
                    final EmptyResultFuture insertFuture = bboxDBCluster.insertTuple(TABLE, tuple);
                    pendingFutures.put(insertFuture);
                }
            } catch (BBoxDBException e) {
                logger.error("Got error while inserting tuple", e);
            }
            if (lineNumber.get() % 1000 == 0) {
                System.out.format("Loaded %d elements\n", lineNumber.get());
            }
        });
    } catch (IOException e) {
        System.err.println("Got an exeption while reading file: " + e);
        System.exit(-1);
    }
    pendingFutures.waitForCompletion();
    loadedFiles.add(filename);
    System.out.println("Loaded content from: " + filename);
    return true;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IOException(java.io.IOException) BBoxDBException(org.bboxdb.misc.BBoxDBException) Tuple(org.bboxdb.storage.entity.Tuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 24 with EmptyResultFuture

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

the class BenchmarkFileInsertPerformance method prepare.

@Override
protected void prepare() throws Exception {
    super.prepare();
    // Remove old data
    final EmptyResultFuture deleteResult = bboxdbClient.deleteDistributionGroup(DISTRIBUTION_GROUP);
    deleteResult.waitForAll();
    // Create a new distribution group
    final DistributionGroupConfiguration config = DistributionGroupConfigurationBuilder.create(2).withReplicationFactor(replicationFactor).build();
    final EmptyResultFuture createResult = bboxdbClient.createDistributionGroup(DISTRIBUTION_GROUP, config);
    createResult.waitForAll();
}
Also used : DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 25 with EmptyResultFuture

use of org.bboxdb.network.client.future.EmptyResultFuture 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)

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