Search in sources :

Example 1 with ZookeeperNotFoundException

use of org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException 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 2 with ZookeeperNotFoundException

use of org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException in project bboxdb by jnidzwetzki.

the class DistributedRecoveryService method init.

@Override
public void init() {
    try {
        final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
        final ZookeeperBBoxDBInstanceAdapter zookeeperBBoxDBInstanceAdapter = new ZookeeperBBoxDBInstanceAdapter(zookeeperClient);
        final BBoxDBInstance distributedInstance = ZookeeperClientFactory.getLocalInstanceName();
        zookeeperBBoxDBInstanceAdapter.updateStateData(distributedInstance, BBoxDBInstanceState.OUTDATED);
        logger.info("Running recovery for local stored data");
        runRecovery();
        logger.info("Running recovery for local stored data DONE");
        zookeeperBBoxDBInstanceAdapter.updateStateData(distributedInstance, BBoxDBInstanceState.READY);
    } catch (ZookeeperException | ZookeeperNotFoundException e) {
        logger.error("Got an exception during recovery: ", e);
    }
}
Also used : ZookeeperClient(org.bboxdb.distribution.zookeeper.ZookeeperClient) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) ZookeeperBBoxDBInstanceAdapter(org.bboxdb.distribution.membership.ZookeeperBBoxDBInstanceAdapter) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance)

Example 3 with ZookeeperNotFoundException

use of org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException in project bboxdb by jnidzwetzki.

the class DistributionRegionSyncer method updateNode.

/**
 * Update the given node
 * @param nodePath
 * @param region
 * @throws InterruptedException
 */
private void updateNode(final String nodePath, final DistributionRegion region) throws InterruptedException {
    logger.debug("updateNode called with node {}", nodePath);
    final Watcher callbackWatcher = this;
    final Retryer<Boolean> retryer = new Retryer<>(10, 100, () -> {
        try {
            final Collection<BBoxDBInstance> systemsForDistributionRegion = distributionRegionAdapter.getSystemsForDistributionRegion(region);
            region.setSystems(systemsForDistributionRegion);
            final int regionId = distributionGroupAdapter.getRegionIdForPath(nodePath);
            if (region.getRegionId() != regionId) {
                throw new RuntimeException("Replacing region id " + region.getRegionId() + " with " + regionId + " on " + nodePath);
            }
            final DistributionRegionState regionState = distributionRegionAdapter.getStateForDistributionRegion(nodePath, callbackWatcher);
            region.setState(regionState);
            updateChildrenForRegion(nodePath, region);
        } catch (ZookeeperNotFoundException e) {
            // Node is deleted, let the deletion callback remove the node
            logger.debug("Skippping node update for path {}, node is deleted", nodePath);
        }
        return true;
    });
    retryer.execute();
    if (!retryer.isSuccessfully()) {
        logger.error("Got error while rereading tree", retryer.getLastException());
    }
}
Also used : Retryer(org.bboxdb.commons.Retryer) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) Watcher(org.apache.zookeeper.Watcher) DistributionRegionState(org.bboxdb.distribution.partitioner.DistributionRegionState) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance)

Example 4 with ZookeeperNotFoundException

use of org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException in project bboxdb by jnidzwetzki.

the class KDtreeSpacePartitioner method splitRegion.

/**
 * Split the node at the given position
 * @param regionToSplit
 * @param splitPosition
 * @throws ZookeeperException
 * @throws ResourceAllocationException
 * @throws ZookeeperNotFoundException
 */
@Override
public List<DistributionRegion> splitRegion(final DistributionRegion regionToSplit, final Collection<BoundingBox> samples) throws BBoxDBException {
    try {
        final SplitpointStrategy splitpointStrategy = new SamplingBasedSplitStrategy(samples);
        final int splitDimension = getSplitDimension(regionToSplit);
        final BoundingBox regionBox = regionToSplit.getConveringBox();
        final double splitPosition = splitpointStrategy.getSplitPoint(splitDimension, regionBox);
        splitNode(regionToSplit, splitPosition);
        return regionToSplit.getDirectChildren();
    } catch (Exception e) {
        throw new BBoxDBException(e);
    }
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) SamplingBasedSplitStrategy(org.bboxdb.distribution.partitioner.regionsplit.SamplingBasedSplitStrategy) BBoxDBException(org.bboxdb.misc.BBoxDBException) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) ResourceAllocationException(org.bboxdb.distribution.placement.ResourceAllocationException) BBoxDBException(org.bboxdb.misc.BBoxDBException) SplitpointStrategy(org.bboxdb.distribution.partitioner.regionsplit.SplitpointStrategy)

Example 5 with ZookeeperNotFoundException

use of org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException in project bboxdb by jnidzwetzki.

the class SpacePartitionerFactory method getSpacePartitionerForDistributionGroup.

/**
 * Return the space partitioner for the distribution group
 * @param mapper
 * @param callback
 * @throws ZookeeperNotFoundException
 */
public static SpacePartitioner getSpacePartitionerForDistributionGroup(final SpacePartitionerContext spacePartitionerContext) throws ZookeeperException {
    try {
        final String distributionGroup = spacePartitionerContext.getDistributionGroupName();
        final DistributionGroupConfiguration config = DistributionGroupConfigurationCache.getInstance().getDistributionGroupConfiguration(distributionGroup);
        final String spacePartitionerString = config.getSpacePartitioner();
        // Instance the classname
        final Class<?> classObject = Class.forName(spacePartitionerString);
        if (classObject == null) {
            throw new ClassNotFoundException("Unable to locate class: " + spacePartitionerString);
        }
        final Object factoryObject = classObject.newInstance();
        if (!(factoryObject instanceof SpacePartitioner)) {
            throw new ClassNotFoundException(spacePartitionerString + " is not a instance of SpacePartitioner");
        }
        final SpacePartitioner spacePartitioner = (SpacePartitioner) factoryObject;
        spacePartitioner.init(spacePartitionerContext);
        return spacePartitioner;
    } catch (Exception e) {
        logger.warn("Unable to instance space partitioner for group: " + spacePartitionerContext.getDistributionGroupName(), e);
        throw new RuntimeException(e);
    }
}
Also used : DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)

Aggregations

ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)16 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)13 BBoxDBException (org.bboxdb.misc.BBoxDBException)8 BoundingBox (org.bboxdb.commons.math.BoundingBox)6 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)5 DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)5 ResourceAllocationException (org.bboxdb.distribution.placement.ResourceAllocationException)4 OptionalDouble (java.util.OptionalDouble)2 SamplingBasedSplitStrategy (org.bboxdb.distribution.partitioner.regionsplit.SamplingBasedSplitStrategy)2 SplitpointStrategy (org.bboxdb.distribution.partitioner.regionsplit.SplitpointStrategy)2 Cursor (java.awt.Cursor)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)1 Predicate (java.util.function.Predicate)1 Watcher (org.apache.zookeeper.Watcher)1