Search in sources :

Example 11 with DistributionGroupConfiguration

use of org.bboxdb.storage.entity.DistributionGroupConfiguration 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 12 with DistributionGroupConfiguration

use of org.bboxdb.storage.entity.DistributionGroupConfiguration in project bboxdb by jnidzwetzki.

the class CLI method actionCreateDgroup.

/**
 * Create a new distribution group
 * @param line
 */
protected void actionCreateDgroup(final CommandLine line) {
    final List<String> requiredArgs = Arrays.asList(CLIParameter.DISTRIBUTION_GROUP, CLIParameter.DIMENSIONS, CLIParameter.REPLICATION_FACTOR);
    checkRequiredArgs(requiredArgs);
    final String maxRegionSizeString = CLIHelper.getParameterOrDefault(line, CLIParameter.MAX_REGION_SIZE, Integer.toString(Const.DEFAULT_MAX_REGION_SIZE));
    final String minRegionSizeString = CLIHelper.getParameterOrDefault(line, CLIParameter.MIN_REGION_SIZE, Integer.toString(Const.DEFAULT_MIN_REGION_SIZE));
    final int maxRegionSize = MathUtil.tryParseIntOrExit(maxRegionSizeString, () -> "Unable to parse the max region size: " + maxRegionSizeString);
    final int minRegionSize = MathUtil.tryParseIntOrExit(minRegionSizeString, () -> "Unable to parse the min region size: " + minRegionSizeString);
    final String resourcePlacement = CLIHelper.getParameterOrDefault(line, CLIParameter.RESOURCE_PLACEMENT, Const.DEFAULT_PLACEMENT_STRATEGY);
    final String resourcePlacementConfig = CLIHelper.getParameterOrDefault(line, CLIParameter.RESOURCE_PLACEMENT_CONFIG, Const.DEFAULT_PLACEMENT_CONFIG);
    final String spacePartitioner = CLIHelper.getParameterOrDefault(line, CLIParameter.SPACE_PARTITIONER, Const.DEFAULT_SPACE_PARTITIONER);
    final String spacePartitionerConfig = CLIHelper.getParameterOrDefault(line, CLIParameter.SPACE_PARTITIONER_CONFIG, Const.DEFAULT_SPACE_PARTITIONER_CONFIG);
    final String distributionGroup = line.getOptionValue(CLIParameter.DISTRIBUTION_GROUP);
    final String replicationFactorString = line.getOptionValue(CLIParameter.REPLICATION_FACTOR);
    final int replicationFactor = MathUtil.tryParseIntOrExit(replicationFactorString, () -> "This is not a valid replication factor: " + replicationFactorString);
    final String dimensionsString = line.getOptionValue(CLIParameter.DIMENSIONS);
    final int dimensions = MathUtil.tryParseIntOrExit(dimensionsString, () -> "This is not a valid dimension: " + dimensionsString);
    System.out.println("Create new distribution group: " + distributionGroup);
    try {
        final DistributionGroupConfiguration configuration = DistributionGroupConfigurationBuilder.create(dimensions).withReplicationFactor((short) replicationFactor).withMaximumRegionSize(maxRegionSize).withMinimumRegionSize(minRegionSize).withPlacementStrategy(resourcePlacement, resourcePlacementConfig).withSpacePartitioner(spacePartitioner, spacePartitionerConfig).build();
        final EmptyResultFuture future = bboxDbConnection.createDistributionGroup(distributionGroup, configuration);
        future.waitForAll();
        if (future.isFailed()) {
            System.err.println("Got an error during distribution group creation: " + future.getAllMessages());
        }
    } catch (BBoxDBException e) {
        System.err.println("Got an exception during distribution group creation: " + e);
        System.exit(-1);
    } catch (InterruptedException e) {
        System.err.println("Waiting was interrupted");
        System.exit(-1);
    }
}
Also used : DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) BBoxDBException(org.bboxdb.misc.BBoxDBException) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 13 with DistributionGroupConfiguration

use of org.bboxdb.storage.entity.DistributionGroupConfiguration in project bboxdb by jnidzwetzki.

the class CLI method actionShowDgroup.

/**
 * Show a distribution group
 * @param line
 */
protected void actionShowDgroup(final CommandLine line) {
    final List<String> requiredArgs = Arrays.asList(CLIParameter.DISTRIBUTION_GROUP);
    checkRequiredArgs(requiredArgs);
    final String distributionGroup = line.getOptionValue(CLIParameter.DISTRIBUTION_GROUP);
    System.out.println("Show distribution group: " + distributionGroup);
    try {
        final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(distributionGroup);
        final DistributionGroupConfiguration config = DistributionGroupConfigurationCache.getInstance().getDistributionGroupConfiguration(distributionGroup);
        final short replicationFactor = config.getReplicationFactor();
        System.out.println("Replication factor is: " + replicationFactor);
        printDistributionRegionRecursive(spacePartitioner.getRootNode());
    } catch (BBoxDBException | ZookeeperNotFoundException e) {
        System.err.println("Got an exception during reading distribution group:" + e);
        System.exit(-1);
    }
}
Also used : ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) BBoxDBException(org.bboxdb.misc.BBoxDBException) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner)

Example 14 with DistributionGroupConfiguration

use of org.bboxdb.storage.entity.DistributionGroupConfiguration 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 15 with DistributionGroupConfiguration

use of org.bboxdb.storage.entity.DistributionGroupConfiguration 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)

Aggregations

DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)43 Test (org.junit.Test)12 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)9 Before (org.junit.Before)7 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)4 BeforeClass (org.junit.BeforeClass)4 BoundingBox (org.bboxdb.commons.math.BoundingBox)3 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)3 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)3 BBoxDBException (org.bboxdb.misc.BBoxDBException)3 Tuple (org.bboxdb.storage.entity.Tuple)3 DistributionGroupAdapter (org.bboxdb.distribution.zookeeper.DistributionGroupAdapter)2 ZookeeperClient (org.bboxdb.distribution.zookeeper.ZookeeperClient)2 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)2 Cursor (java.awt.Cursor)1 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 HashSet (java.util.HashSet)1 Random (java.util.Random)1 InputParseException (org.bboxdb.commons.InputParseException)1