Search in sources :

Example 86 with DistributionRegion

use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.

the class AbstractSpacePartitioner method allocateSystems.

/**
 * Allocate systems to the children
 * @param regionToSplit
 * @param numberOfChilden
 * @throws ZookeeperException
 * @throws ResourceAllocationException
 * @throws ZookeeperNotFoundException
 */
protected void allocateSystems(final DistributionRegion regionToSplit, final int numberOfChilden) throws ZookeeperException, ZookeeperNotFoundException, ResourceAllocationException {
    // The first child is stored on the same systems as the parent
    final DistributionRegion firstRegion = regionToSplit.getDirectChildren().get(0);
    final String firstRegionPath = distributionRegionZookeeperAdapter.getZookeeperPathForDistributionRegion(firstRegion);
    SpacePartitionerHelper.copySystemsToRegion(regionToSplit.getSystems(), firstRegionPath, zookeeperClient);
    final List<BBoxDBInstance> blacklistSystems = regionToSplit.getSystems();
    // For the remaining node, a new resource allocation is performed
    for (int i = 1; i < numberOfChilden; i++) {
        final DistributionRegion region = regionToSplit.getDirectChildren().get(i);
        final String path = distributionRegionZookeeperAdapter.getZookeeperPathForDistributionRegion(region);
        final String fullname = region.getDistributionGroupName();
        SpacePartitionerHelper.allocateSystemsToRegion(path, fullname, blacklistSystems, zookeeperClient);
    }
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance)

Example 87 with DistributionRegion

use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.

the class AbstractTreeSpacePartitoner method setStateToRedistributionActiveAndWait.

/**
 * Set children to active and wait
 * @param numberOfChilden2
 */
protected void setStateToRedistributionActiveAndWait(final DistributionRegion regionToSplit, final int numberOfChilden) throws ZookeeperException {
    // update state
    for (final DistributionRegion region : regionToSplit.getAllChildren()) {
        final String childPath = distributionRegionZookeeperAdapter.getZookeeperPathForDistributionRegion(region);
        distributionRegionZookeeperAdapter.setStateForDistributionGroup(childPath, DistributionRegionState.REDISTRIBUTION_ACTIVE);
    }
    waitForSplitCompleteZookeeperCallback(regionToSplit, numberOfChilden);
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion)

Example 88 with DistributionRegion

use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.

the class DynamicgridSpacePartitioner method getMergeCandidates.

@Override
public List<List<DistributionRegion>> getMergeCandidates(final DistributionRegion distributionRegion) {
    final List<List<DistributionRegion>> result = new ArrayList<>();
    final List<DistributionRegion> children = distributionRegion.getParent().getDirectChildren();
    children.sort((e1, e2) -> e1.getConveringBox().getIntervalForDimension(0).compareTo(e2.getConveringBox().getIntervalForDimension(0)));
    for (int pos = 0; pos < children.size(); pos++) {
        final DistributionRegion region = children.get(pos);
        // Use the left and the right region as merge candidates
        if (region.equals(distributionRegion)) {
            if (pos - 1 >= 0) {
                result.add(Arrays.asList(distributionRegion, children.get(pos - 1)));
            }
            if (pos + 1 < children.size()) {
                result.add(Arrays.asList(distributionRegion, children.get(pos + 1)));
            }
            break;
        }
    }
    return result;
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 89 with DistributionRegion

use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.

the class DynamicgridSpacePartitioner method splitNode.

/**
 * Split the node at the given split point
 * @param regionToSplit
 * @param splitPosition
 * @throws BBoxDBException
 * @throws ResourceAllocationException
 */
public void splitNode(final DistributionRegion regionToSplit, final double splitPosition) throws BBoxDBException, ResourceAllocationException {
    try {
        logger.debug("Write split at pos {} into zookeeper", splitPosition);
        final DistributionRegion parent = regionToSplit.getParent();
        final String sourcePath = distributionRegionZookeeperAdapter.getZookeeperPathForDistributionRegion(regionToSplit);
        final String parentPath = distributionRegionZookeeperAdapter.getZookeeperPathForDistributionRegion(parent);
        // Calculate the covering bounding boxes
        final BoundingBox parentBox = regionToSplit.getConveringBox();
        final BoundingBox leftBoundingBox = parentBox.splitAndGetLeft(splitPosition, 0, true);
        final BoundingBox rightBoundingBox = parentBox.splitAndGetRight(splitPosition, 0, false);
        final String fullname = distributionGroupName;
        // Only one system executes the split, therefore we can determine the child ids
        final int oldNumberOfhildren = parent.getDirectChildren().size();
        final long childNumber = parent.getHighestChildNumber();
        final String child1Path = distributionRegionZookeeperAdapter.createNewChild(parentPath, (int) childNumber + 1, leftBoundingBox, fullname);
        final String child2Path = distributionRegionZookeeperAdapter.createNewChild(parentPath, (int) childNumber + 2, rightBoundingBox, fullname);
        // Update state
        distributionRegionZookeeperAdapter.setStateForDistributionGroup(sourcePath, DistributionRegionState.SPLITTING);
        final Predicate<DistributionRegion> predicate = (r) -> r.getDirectChildren().size() == oldNumberOfhildren + 2;
        DistributionRegionSyncerHelper.waitForPredicate(predicate, regionToSplit, distributionRegionSyncer);
        // The first child is stored on the same systems as the parent
        SpacePartitionerHelper.copySystemsToRegion(regionToSplit.getSystems(), child1Path, zookeeperClient);
        final List<BBoxDBInstance> blacklistSystems = regionToSplit.getSystems();
        SpacePartitionerHelper.allocateSystemsToRegion(child2Path, fullname, blacklistSystems, zookeeperClient);
    } catch (ZookeeperException | ZookeeperNotFoundException e) {
        throw new BBoxDBException(e);
    }
}
Also used : SamplingBasedSplitStrategy(org.bboxdb.distribution.partitioner.regionsplit.SamplingBasedSplitStrategy) DistributionRegionSyncerHelper(org.bboxdb.distribution.region.DistributionRegionSyncerHelper) Arrays(java.util.Arrays) Predicate(java.util.function.Predicate) Collection(java.util.Collection) SplitpointStrategy(org.bboxdb.distribution.partitioner.regionsplit.SplitpointStrategy) BoundingBox(org.bboxdb.commons.math.BoundingBox) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) ArrayList(java.util.ArrayList) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) List(java.util.List) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) InputParseException(org.bboxdb.commons.InputParseException) ResourceAllocationException(org.bboxdb.distribution.placement.ResourceAllocationException) BBoxDBException(org.bboxdb.misc.BBoxDBException) DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) MathUtil(org.bboxdb.commons.MathUtil) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BBoxDBException(org.bboxdb.misc.BBoxDBException) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) BoundingBox(org.bboxdb.commons.math.BoundingBox) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance)

Example 90 with DistributionRegion

use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.

the class TupleRedistributor method getStatistics.

/**
 * Get the statistics for the redistribution
 * @return
 */
public String getStatistics() {
    final StringBuilder sb = new StringBuilder();
    sb.append("Input tuples: " + redistributedTuples);
    float totalRedistributedTuples = 0;
    for (final DistributionRegion region : regionMap.keySet()) {
        if (regionMap.get(region).isEmpty()) {
            sb.append(", no systems for regionid " + region.getRegionId());
        } else {
            final long forwarededTuples = regionMap.get(region).get(0).getSinkedTuples();
            final float percent = ((float) forwarededTuples / (float) redistributedTuples * 100);
            sb.append(", forwared " + forwarededTuples + " to regionid " + region.getRegionId());
            sb.append(String.format(" (%.2f %%)", percent));
            totalRedistributedTuples = totalRedistributedTuples + forwarededTuples;
        }
    }
    final float percent = ((float) totalRedistributedTuples / (float) redistributedTuples * 100);
    sb.append(" Total redistributed tuples: " + totalRedistributedTuples);
    sb.append(String.format(" (%.2f %%)", percent));
    return sb.toString();
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion)

Aggregations

DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)91 Test (org.junit.Test)45 BBoxDBException (org.bboxdb.misc.BBoxDBException)34 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)33 BoundingBox (org.bboxdb.commons.math.BoundingBox)27 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)23 ArrayList (java.util.ArrayList)17 List (java.util.List)17 SpacePartitioner (org.bboxdb.distribution.partitioner.SpacePartitioner)16 DistributionRegionAdapter (org.bboxdb.distribution.zookeeper.DistributionRegionAdapter)15 DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)15 KDtreeSpacePartitioner (org.bboxdb.distribution.partitioner.KDtreeSpacePartitioner)14 DistributionGroupAdapter (org.bboxdb.distribution.zookeeper.DistributionGroupAdapter)11 ZookeeperClientFactory (org.bboxdb.distribution.zookeeper.ZookeeperClientFactory)11 DistributionRegionState (org.bboxdb.distribution.partitioner.DistributionRegionState)10 DistributionRegionIdMapper (org.bboxdb.distribution.region.DistributionRegionIdMapper)10 DistributionRegionSyncer (org.bboxdb.distribution.region.DistributionRegionSyncer)10 RoutingHeader (org.bboxdb.network.routing.RoutingHeader)10 RoutingHop (org.bboxdb.network.routing.RoutingHop)10 DistributionGroupConfigurationBuilder (org.bboxdb.storage.entity.DistributionGroupConfigurationBuilder)10