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