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);
}
}
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);
}
}
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());
}
}
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);
}
}
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);
}
}
Aggregations