Search in sources :

Example 6 with SpacePartitioner

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);
    }
}
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 7 with SpacePartitioner

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);
    }
}
Also used : DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) BBoxDBException(org.bboxdb.misc.BBoxDBException) StorageManagerException(org.bboxdb.storage.StorageManagerException) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner)

Example 8 with SpacePartitioner

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);
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner)

Example 9 with SpacePartitioner

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);
}
Also used : SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner)

Example 10 with SpacePartitioner

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<>();
    }
}
Also used : BBoxDBException(org.bboxdb.misc.BBoxDBException) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner)

Aggregations

SpacePartitioner (org.bboxdb.distribution.partitioner.SpacePartitioner)29 BBoxDBException (org.bboxdb.misc.BBoxDBException)16 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)15 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)14 DistributionRegionIdMapper (org.bboxdb.distribution.region.DistributionRegionIdMapper)10 StorageManagerException (org.bboxdb.storage.StorageManagerException)9 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)8 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 RejectedException (org.bboxdb.commons.RejectedException)3 KDtreeSpacePartitioner (org.bboxdb.distribution.partitioner.KDtreeSpacePartitioner)3 SpacePartitionerCache (org.bboxdb.distribution.partitioner.SpacePartitionerCache)3 DistributionGroupAdapter (org.bboxdb.distribution.zookeeper.DistributionGroupAdapter)3 DistributionRegionAdapter (org.bboxdb.distribution.zookeeper.DistributionRegionAdapter)3 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)3 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)3 TupleStoreManagerRegistry (org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry)3 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2