Search in sources :

Example 16 with BBoxDBException

use of org.bboxdb.misc.BBoxDBException in project bboxdb by jnidzwetzki.

the class RegionSplitter method spreadTupleStores.

/**
 * Spread a given tuple store onto new systems
 * @param region
 * @param sstableManager
 * @param ssTableManager
 * @param tupleRedistributor
 * @param onlyInMemoryData
 * @throws StorageManagerException
 */
private void spreadTupleStores(final TupleStoreManager ssTableManager, final TupleRedistributor tupleRedistributor) throws BBoxDBException {
    final List<ReadOnlyTupleStore> storages = new ArrayList<>();
    try {
        final List<ReadOnlyTupleStore> aquiredStorages = ssTableManager.aquireStorage();
        storages.addAll(aquiredStorages);
        final int totalSotrages = aquiredStorages.size();
        for (int i = 0; i < totalSotrages; i++) {
            final ReadOnlyTupleStore storage = aquiredStorages.get(i);
            logger.info("Spread tuple storage {} number {} of {}", storage.getInternalName(), i, totalSotrages - 1);
            spreadStorage(tupleRedistributor, storage);
        }
        logger.info("Final statistics for spread ({}): {}", ssTableManager.getTupleStoreName().getFullname(), tupleRedistributor.getStatistics());
    } catch (Exception e) {
        throw new BBoxDBException(e);
    } finally {
        ssTableManager.releaseStorage(storages);
    }
}
Also used : ArrayList(java.util.ArrayList) ReadOnlyTupleStore(org.bboxdb.storage.tuplestore.ReadOnlyTupleStore) BBoxDBException(org.bboxdb.misc.BBoxDBException) BBoxDBException(org.bboxdb.misc.BBoxDBException) StorageManagerException(org.bboxdb.storage.StorageManagerException)

Example 17 with BBoxDBException

use of org.bboxdb.misc.BBoxDBException in project bboxdb by jnidzwetzki.

the class AbstractGridSpacePartitioner method createRootNode.

@Override
public void createRootNode(final DistributionGroupConfiguration configuration) throws BBoxDBException {
    // [[0.0,5.0]:[0.0,5.0]];0.5;0.5
    final String spConfig = spacePartitionerContext.getSpacePartitionerConfig();
    if (spConfig.isEmpty()) {
        throw new BBoxDBException("Got empty space partitioner config");
    }
    final String[] splitConfig = spConfig.split(";");
    checkConfigParameter(configuration, splitConfig);
    try {
        final String distributionGroup = spacePartitionerContext.getDistributionGroupName();
        final String rootPath = distributionGroupZookeeperAdapter.getDistributionGroupRootElementPath(distributionGroup);
        zookeeperClient.createDirectoryStructureRecursive(rootPath);
        final int nameprefix = distributionGroupZookeeperAdapter.getNextTableIdForDistributionGroup(distributionGroup);
        zookeeperClient.createPersistentNode(rootPath + "/" + ZookeeperNodeNames.NAME_NAMEPREFIX, Integer.toString(nameprefix).getBytes());
        zookeeperClient.createPersistentNode(rootPath + "/" + ZookeeperNodeNames.NAME_SYSTEMS, "".getBytes());
        final BoundingBox rootBox = new BoundingBox(splitConfig[0]);
        distributionRegionZookeeperAdapter.setBoundingBoxForPath(rootPath, rootBox);
        // Create grid
        createCells(splitConfig, configuration, rootPath, rootBox);
        zookeeperClient.createPersistentNode(rootPath + "/" + ZookeeperNodeNames.NAME_REGION_STATE, DistributionRegionState.SPLIT.getStringValue().getBytes());
        NodeMutationHelper.markNodeMutationAsComplete(zookeeperClient, rootPath);
    } catch (Exception e) {
        throw new BBoxDBException(e);
    }
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) BBoxDBException(org.bboxdb.misc.BBoxDBException) BBoxDBException(org.bboxdb.misc.BBoxDBException)

Example 18 with BBoxDBException

use of org.bboxdb.misc.BBoxDBException in project bboxdb by jnidzwetzki.

the class AbstractSpacePartitioner method splitFailed.

@Override
public void splitFailed(final DistributionRegion sourceRegion, final List<DistributionRegion> destination) throws BBoxDBException {
    try {
        distributionRegionZookeeperAdapter.setStateForDistributionRegion(sourceRegion, DistributionRegionState.ACTIVE);
        for (final DistributionRegion childRegion : destination) {
            logger.info("Deleting child after failed split: {}", childRegion.getIdentifier());
            distributionRegionZookeeperAdapter.deleteChild(childRegion);
        }
    } catch (ZookeeperException e) {
        throw new BBoxDBException(e);
    }
}
Also used : ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BBoxDBException(org.bboxdb.misc.BBoxDBException)

Example 19 with BBoxDBException

use of org.bboxdb.misc.BBoxDBException in project bboxdb by jnidzwetzki.

the class AbstractSpacePartitioner method prepareMerge.

@Override
public void prepareMerge(final List<DistributionRegion> source, final DistributionRegion destination) throws BBoxDBException {
    try {
        logger.debug("Merging region: {}", destination.getIdentifier());
        distributionRegionZookeeperAdapter.setStateForDistributionRegion(destination, DistributionRegionState.REDISTRIBUTION_ACTIVE);
        for (final DistributionRegion childRegion : source) {
            final String zookeeperPathChild = distributionRegionZookeeperAdapter.getZookeeperPathForDistributionRegion(childRegion);
            distributionRegionZookeeperAdapter.setStateForDistributionGroup(zookeeperPathChild, DistributionRegionState.MERGING);
        }
    } catch (ZookeeperException e) {
        throw new BBoxDBException(e);
    }
}
Also used : ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BBoxDBException(org.bboxdb.misc.BBoxDBException)

Example 20 with BBoxDBException

use of org.bboxdb.misc.BBoxDBException in project bboxdb by jnidzwetzki.

the class AbstractTreeSpacePartitoner method mergeComplete.

@Override
public void mergeComplete(final List<DistributionRegion> source, final DistributionRegion destination) throws BBoxDBException {
    try {
        for (final DistributionRegion childRegion : source) {
            logger.info("Merge done deleting: {}", childRegion.getIdentifier());
            distributionRegionZookeeperAdapter.deleteChild(childRegion);
        }
        distributionRegionZookeeperAdapter.setStateForDistributionRegion(destination, DistributionRegionState.ACTIVE);
    } catch (ZookeeperException e) {
        throw new BBoxDBException(e);
    }
}
Also used : ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BBoxDBException(org.bboxdb.misc.BBoxDBException)

Aggregations

BBoxDBException (org.bboxdb.misc.BBoxDBException)64 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)24 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)22 BoundingBox (org.bboxdb.commons.math.BoundingBox)17 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)14 SpacePartitioner (org.bboxdb.distribution.partitioner.SpacePartitioner)13 ArrayList (java.util.ArrayList)12 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)12 StorageManagerException (org.bboxdb.storage.StorageManagerException)12 List (java.util.List)11 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)11 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)10 Tuple (org.bboxdb.storage.entity.Tuple)9 ResourceAllocationException (org.bboxdb.distribution.placement.ResourceAllocationException)7 RoutingHop (org.bboxdb.network.routing.RoutingHop)7 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)6 RoutingHeader (org.bboxdb.network.routing.RoutingHeader)6 RejectedException (org.bboxdb.commons.RejectedException)5 DistributionRegionIdMapper (org.bboxdb.distribution.region.DistributionRegionIdMapper)5 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)5