use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class RegionMerger method redistributeDataMerge.
/**
* Redistribute the data in region merge
* @param source
* @param destination
* @throws Exception
*/
private void redistributeDataMerge(final List<DistributionRegion> source, final DistributionRegion destination) throws Exception {
logger.info("Redistributing all data for region (merge): " + destination.getIdentifier());
final String distributionGroupName = destination.getDistributionGroupName();
final List<TupleStoreName> localTables = TupleStoreUtil.getAllTablesForDistributionGroupAndRegionId(registry, distributionGroupName, destination.getRegionId());
// Add the local mapping, new data is written to the region
final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(distributionGroupName);
final DistributionRegionIdMapper mapper = spacePartitioner.getDistributionRegionIdMapper();
// We have set the region to active, wait until we see this status change
// from Zookeeper and the space partitioner add this region as active
mapper.waitUntilMappingAppears(destination.getRegionId());
// Redistribute data
for (final TupleStoreName tupleStoreName : localTables) {
logger.info("Merging data of tuple store {}", tupleStoreName);
startFlushToDisk(tupleStoreName);
final TupleRedistributor tupleRedistributor = new TupleRedistributor(registry, tupleStoreName);
tupleRedistributor.registerRegion(destination);
for (final DistributionRegion childRegion : source) {
mergeDataFromChildRegion(destination, tupleStoreName, tupleRedistributor, childRegion);
}
logger.info("Final statistics for merge ({}): {}", tupleStoreName, tupleRedistributor.getStatistics());
}
}
use of org.bboxdb.distribution.region.DistributionRegion 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.distribution.region.DistributionRegion 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.distribution.region.DistributionRegion 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);
}
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class AbstractTreeSpacePartitoner 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);
}
}
Aggregations