use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class CompactorHelper method isRegionActive.
/**
* Is the region for the table active?
*
* @param tupleStoreName
* @return
* @throws StorageManagerException
* @throws InterruptedException
*/
public static boolean isRegionActive(final TupleStoreName tupleStoreName) throws StorageManagerException, InterruptedException {
try {
if (!tupleStoreName.isDistributedTable()) {
logger.error("Tuple store {} is not a distributed table, untable to split", tupleStoreName);
return false;
}
final long regionId = tupleStoreName.getRegionId().getAsLong();
final String distributionGroup = tupleStoreName.getDistributionGroup();
final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(distributionGroup);
final DistributionRegion distributionRegion = spacePartitioner.getRootNode();
final DistributionRegion regionToSplit = DistributionRegionHelper.getDistributionRegionForNamePrefix(distributionRegion, regionId);
// Region does not exist
if (regionToSplit == null) {
logger.error("Unable to get distribution region {} {}", distributionRegion, regionId);
return false;
}
if (regionToSplit.isRootElement()) {
return true;
}
return regionToSplit.getState() == DistributionRegionState.ACTIVE;
} catch (BBoxDBException e) {
throw new StorageManagerException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw e;
}
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class SSTableServiceRunnable method testForUnderflow.
/**
* Test for region underflow
*
* @param spacePartitioner
* @param regionToMerge
* @throws BBoxDBException
*/
private void testForUnderflow(final SpacePartitioner spacePartitioner, final DistributionRegion oneSourceNode) throws BBoxDBException {
final List<List<DistributionRegion>> candidates = spacePartitioner.getMergeCandidates(oneSourceNode);
for (final List<DistributionRegion> sources : candidates) {
if (RegionMergeHelper.isRegionUnderflow(sources)) {
final TupleStoreManagerRegistry tupleStoreManagerRegistry = storage.getTupleStoreManagerRegistry();
final RegionMerger regionMerger = new RegionMerger(tupleStoreManagerRegistry);
regionMerger.mergeRegion(sources, spacePartitioner, tupleStoreManagerRegistry);
return;
}
}
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class DistributedRecoveryService method runRecoveryForDistributionGroup.
/**
* Run recovery for distribution group
* @param distributionGroupName
* @throws ZookeeperException
*/
protected void runRecoveryForDistributionGroup(final String distributionGroupName) {
try {
final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
final BBoxDBInstance localInstance = ZookeeperClientFactory.getLocalInstanceName();
for (final DiskStorage storage : storageRegistry.getAllStorages()) {
checkGroupVersion(storage, distributionGroupName, zookeeperClient);
}
final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(distributionGroupName);
final DistributionRegion distributionGroup = spacePartitioner.getRootNode();
final List<OutdatedDistributionRegion> outdatedRegions = DistributionRegionHelper.getOutdatedRegions(distributionGroup, localInstance);
handleOutdatedRegions(distributionGroupName, outdatedRegions);
} catch (Throwable e) {
logger.error("Got exception while running recovery for distribution group: " + distributionGroupName, e);
}
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class RegionSplitter method splitRegion.
/**
* Perform a distribution region split
*
* @param region
* @param distributionGroupZookeeperAdapter
* @param spacePartitioner
* @param diskStorage
*/
public void splitRegion(final DistributionRegion region, final SpacePartitioner spacePartitioner, final TupleStoreManagerRegistry tupleStoreManagerRegistry) {
assert (region != null);
final DistributionRegionAdapter distributionRegionZookeeperAdapter = ZookeeperClientFactory.getZookeeperClient().getDistributionRegionAdapter();
logger.info("Performing split for: {}", region.getIdentifier());
final boolean setResult = tryToSetToFullSplitting(region, distributionRegionZookeeperAdapter);
if (!setResult) {
return;
}
boolean splitFailed = false;
final List<DistributionRegion> destination = new ArrayList<>();
try {
final Collection<BoundingBox> samples = SamplingHelper.getSamplesForRegion(region, tupleStoreManagerRegistry);
final List<DistributionRegion> splitRegions = spacePartitioner.splitRegion(region, samples);
destination.addAll(splitRegions);
redistributeDataSplit(region, destination);
distributionRegionZookeeperAdapter.deleteRegionStatistics(region);
// Setting the region to split will cause a local data delete (see TupleStoreZookeeperObserver)
spacePartitioner.splitComplete(region, destination);
} catch (Throwable e) {
logger.warn("Got exception during split, retry in a few minutes: " + region.getIdentifier(), e);
splitFailed = true;
}
handleSplitFailed(region, spacePartitioner, splitFailed, destination);
logger.info("Performing split for: {} is done", region.getIdentifier());
}
use of org.bboxdb.distribution.region.DistributionRegion in project bboxdb by jnidzwetzki.
the class DistributionRegionAdapter method getZookeeperPathForDistributionRegion.
/**
* Get the zookeeper path for a distribution region
* @param distributionRegion
* @return
*/
public String getZookeeperPathForDistributionRegion(final DistributionRegion distributionRegion) {
final StringBuilder sb = new StringBuilder();
DistributionRegion tmpRegion = distributionRegion;
if (tmpRegion != null) {
while (!tmpRegion.isRootElement()) {
sb.insert(0, "/" + ZookeeperNodeNames.NAME_CHILDREN + tmpRegion.getChildNumberOfParent());
tmpRegion = tmpRegion.getParent();
}
}
final String name = distributionRegion.getDistributionGroupName();
final DistributionGroupAdapter distributionGroupAdapter = zookeeperClient.getDistributionGroupAdapter();
sb.insert(0, distributionGroupAdapter.getDistributionGroupRootElementPath(name));
return sb.toString();
}
Aggregations