use of org.bboxdb.misc.BBoxDBException in project bboxdb by jnidzwetzki.
the class SSTableServiceRunnable method processTupleStores.
/**
* Process the tuple stores
*
* @param storageRegistry
* @param tupleStores
* @throws InterruptedException
*/
private void processTupleStores(final TupleStoreManagerRegistry storageRegistry, final List<TupleStoreName> tupleStores) throws InterruptedException {
for (final TupleStoreName tupleStoreName : tupleStores) {
try {
logger.debug("Running compact for: {}", tupleStoreName);
final TupleStoreManager tupleStoreManager = storageRegistry.getTupleStoreManager(tupleStoreName);
if (tupleStoreManager.getSstableManagerState() == TupleStoreManagerState.READ_ONLY) {
logger.debug("Skipping compact for read only sstable manager: {}", tupleStoreName);
continue;
}
if (!CompactorHelper.isRegionActive(tupleStoreName)) {
logger.info("Skipping compact run, because region is not active {}", tupleStoreName);
continue;
}
final List<SSTableFacade> facades = getAllTupleStores(tupleStoreManager);
final MergeTask mergeTask = mergeStrategy.getMergeTask(facades);
executeCompactTask(mergeTask, tupleStoreManager);
testForRegionOverflow(tupleStoreManager);
} catch (StorageManagerException | BBoxDBException e) {
logger.error("Error while merging tables", e);
}
}
}
use of org.bboxdb.misc.BBoxDBException in project bboxdb by jnidzwetzki.
the class SSTableServiceRunnable method testForRegionOverflow.
/**
* Does the region needs to be split?
* @param sstableManager
* @throws BBoxDBException
* @throws InterruptedException
*/
private void testForRegionOverflow(final TupleStoreManager sstableManager) throws BBoxDBException, InterruptedException {
// Don't try to split non-distributed tables
if (!sstableManager.getTupleStoreName().isDistributedTable()) {
return;
}
try {
final TupleStoreName ssTableName = sstableManager.getTupleStoreName();
final long regionId = ssTableName.getRegionId().getAsLong();
final SpacePartitioner spacePartitioner = getSpacePartitioner(ssTableName);
final DistributionRegion distributionRegion = spacePartitioner.getRootNode();
final DistributionRegion regionToSplit = DistributionRegionHelper.getDistributionRegionForNamePrefix(distributionRegion, regionId);
// Region does not exist
if (regionToSplit == null) {
return;
}
if (!RegionSplitHelper.isSplittingSupported(regionToSplit)) {
return;
}
if (!RegionSplitHelper.isRegionOverflow(regionToSplit)) {
return;
}
executeSplit(sstableManager, spacePartitioner, regionToSplit);
} catch (Exception e) {
throw new BBoxDBException(e);
}
}
use of org.bboxdb.misc.BBoxDBException in project bboxdb by jnidzwetzki.
the class SSTableServiceRunnable method registerNewFacadeAndDeleteOldInstances.
/**
* Register a new sstable facade and delete the old ones
* @param oldFacades
* @param directory
* @param name
* @param tablenumber
* @throws StorageManagerException
*/
private void registerNewFacadeAndDeleteOldInstances(final TupleStoreManager sstableManager, final List<SSTableFacade> oldFacades, final List<SSTableWriter> newTableWriter) throws StorageManagerException {
final List<SSTableFacade> newFacades = new ArrayList<>();
// Open new facades
openFacades(newTableWriter, newFacades);
// Manager has switched to read only
if (sstableManager.getSstableManagerState() == TupleStoreManagerState.READ_ONLY) {
logger.info("Manager is in read only mode, cancel compact run");
handleCompactException(newFacades);
return;
}
try {
for (final SSTableFacade facade : newFacades) {
facade.init();
}
// Switch facades in registry
sstableManager.replaceCompactedSStables(newFacades, oldFacades);
// Schedule facades for deletion
oldFacades.forEach(f -> f.deleteOnClose());
} catch (BBoxDBException | RejectedException e) {
handleCompactException(newFacades);
throw new StorageManagerException(e);
} catch (InterruptedException e) {
handleCompactException(newFacades);
Thread.currentThread().interrupt();
throw new StorageManagerException(e);
}
}
use of org.bboxdb.misc.BBoxDBException in project bboxdb by jnidzwetzki.
the class SSTableServiceRunnable method testForMergeInGroup.
/**
* Test for merge in distribution region
*
* @param localinstance
* @param groupName
* @throws BBoxDBException
*/
private void testForMergeInGroup(final String groupName) throws BBoxDBException {
final BBoxDBInstance localinstance = ZookeeperClientFactory.getLocalInstanceName();
final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(groupName);
final DistributionRegion rootNode = spacePartitioner.getRootNode();
if (rootNode == null) {
return;
}
final List<DistributionRegion> mergeCandidates = rootNode.getThisAndChildRegions().stream().filter(r -> r.getSystems().contains(localinstance)).collect(Collectors.toList());
for (final DistributionRegion region : mergeCandidates) {
testForUnderflow(spacePartitioner, region);
}
}
use of org.bboxdb.misc.BBoxDBException in project bboxdb by jnidzwetzki.
the class SSTableFacade method init.
@Override
public void init() throws InterruptedException, BBoxDBException {
try {
if (ssTableReader == null || ssTableKeyIndexReader == null) {
logger.warn("init called but sstable reader or index reader is null");
return;
}
ssTableReader.init();
ssTableKeyIndexReader.init();
ssTableKeyIndexReader.activateKeyCache(keyCacheElements);
// Spatial index
final File spatialIndexFile = getSpatialIndexFile(directory, tablename, tablenumber);
loadSpatialIndex(spatialIndexFile);
// Bloom filter
final File bloomFilterFile = getBloomFilterFile(directory, tablename, tablenumber);
loadBloomFilter(bloomFilterFile);
} catch (StorageManagerException e) {
throw new BBoxDBException(e);
}
}
Aggregations