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);
}
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);
}
}
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);
}
}
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);
}
}
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");
}
Aggregations