use of org.bboxdb.distribution.partitioner.SpacePartitioner 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.distribution.partitioner.SpacePartitioner in project bboxdb by jnidzwetzki.
the class StatisticsUpdateRunnable method updateRegionStatistics.
/**
* Update the statistics of the region
*/
private void updateRegionStatistics() {
try {
final List<String> allDistributionGroups = groupAdapter.getDistributionGroups();
for (final String distributionGroup : allDistributionGroups) {
final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(distributionGroup);
final DistributionRegionIdMapper regionIdMapper = spacePartitioner.getDistributionRegionIdMapper();
final Collection<Long> allIds = regionIdMapper.getRegionIdsForRegion(BoundingBox.FULL_SPACE);
for (final long id : allIds) {
updateRegionStatistics(distributionGroup, id);
}
}
} catch (Exception e) {
logger.error("Got exception while updating statistics", e);
}
}
use of org.bboxdb.distribution.partitioner.SpacePartitioner in project bboxdb by jnidzwetzki.
the class StatisticsUpdateRunnable method updateRegionStatistics.
/**
* Update region statistics
*
* @param distributionGroup
* @param regionId
* @throws ZookeeperException
* @throws StorageManagerException
* @throws InterruptedException
*/
private void updateRegionStatistics(final String distributionGroup, final long regionId) throws BBoxDBException, ZookeeperException, StorageManagerException, InterruptedException {
final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(distributionGroup);
final DistributionRegion distributionRegion = spacePartitioner.getRootNode();
final DistributionRegion regionToSplit = DistributionRegionHelper.getDistributionRegionForNamePrefix(distributionRegion, regionId);
final long totalSize = TupleStoreUtil.getSizeOfDistributionGroupAndRegionId(storageRegistry, distributionGroup, regionId);
final long totalTuples = TupleStoreUtil.getTuplesInDistributionGroupAndRegionId(storageRegistry, distributionGroup, regionId);
final long totalSizeInMb = totalSize / (1024 * 1024);
logger.info("Updating region statistics: {} / {}. Size in MB: {} / Tuples: {}", distributionGroup, regionId, totalSizeInMb, totalTuples);
regionAdapter.updateRegionStatistics(regionToSplit, ZookeeperClientFactory.getLocalInstanceName(), totalSizeInMb, totalTuples);
}
use of org.bboxdb.distribution.partitioner.SpacePartitioner in project bboxdb by jnidzwetzki.
the class DistributionGroupAdapter method createDistributionGroup.
/**
* Create a new distribution group
* @param distributionGroup
* @param replicationFactor
* @throws ZookeeperException
* @throws BBoxDBException
*/
public void createDistributionGroup(final String distributionGroup, final DistributionGroupConfiguration configuration) throws ZookeeperException, BBoxDBException {
final String path = getDistributionGroupPath(distributionGroup);
zookeeperClient.createDirectoryStructureRecursive(path);
zookeeperClient.createPersistentNode(path + "/" + ZookeeperNodeNames.NAME_DIMENSIONS, Integer.toString(configuration.getDimensions()).getBytes());
zookeeperClient.createPersistentNode(path + "/" + ZookeeperNodeNames.NAME_REPLICATION, Short.toString(configuration.getReplicationFactor()).getBytes());
setRegionSizeForDistributionGroup(distributionGroup, configuration.getMaximumRegionSize(), configuration.getMinimumRegionSize());
// Placement
final String placementPath = path + "/" + ZookeeperNodeNames.NAME_PLACEMENT_STRATEGY;
zookeeperClient.replacePersistentNode(placementPath, configuration.getPlacementStrategy().getBytes());
final String placementConfigPath = path + "/" + ZookeeperNodeNames.NAME_PLACEMENT_CONFIG;
zookeeperClient.replacePersistentNode(placementConfigPath, configuration.getPlacementStrategyConfig().getBytes());
// Space partitioner
final String spacePartitionerPath = path + "/" + ZookeeperNodeNames.NAME_SPACEPARTITIONER;
zookeeperClient.replacePersistentNode(spacePartitionerPath, configuration.getSpacePartitioner().getBytes());
final String spacePartitionerConfigPath = path + "/" + ZookeeperNodeNames.NAME_SPACEPARTITIONER_CONFIG;
zookeeperClient.replacePersistentNode(spacePartitionerConfigPath, configuration.getSpacePartitionerConfig().getBytes());
final TupleStoreAdapter tupleStoreAdapter = new TupleStoreAdapter(zookeeperClient);
tupleStoreAdapter.createTupleStoreConfigNode(distributionGroup);
NodeMutationHelper.markNodeMutationAsComplete(zookeeperClient, path);
final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(distributionGroup);
spacePartitioner.createRootNode(configuration);
}
use of org.bboxdb.distribution.partitioner.SpacePartitioner in project bboxdb by jnidzwetzki.
the class RegionMergeHelper method getMergingCandidates.
/**
* Is the merging by the space partitioner allowed?
* @param region
* @return
*/
public static List<List<DistributionRegion>> getMergingCandidates(final DistributionRegion region) {
try {
final String distributionGroupName = region.getDistributionGroupName();
final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(distributionGroupName);
return spacePartitioner.getMergeCandidates(region);
} catch (BBoxDBException e) {
logger.error("Got exception while testing for merge", e);
return new ArrayList<>();
}
}
Aggregations