use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class InsertTupleHandler method createMissingTables.
/**
* Create all missing tables
*/
protected void createMissingTables(final TupleStoreName requestTable, final TupleStoreManagerRegistry storageRegistry, final Collection<TupleStoreName> localTables) throws StorageManagerException {
try {
final TupleStoreAdapter tupleStoreAdapter = ZookeeperClientFactory.getZookeeperClient().getTupleStoreAdapter();
if (!tupleStoreAdapter.isTableKnown(requestTable)) {
throw new StorageManagerException("Table: " + requestTable.getFullname() + " is unkown");
}
final TupleStoreConfiguration config = tupleStoreAdapter.readTuplestoreConfiguration(requestTable);
for (final TupleStoreName tupleStoreName : localTables) {
final boolean alreadyKnown = storageRegistry.isStorageManagerKnown(tupleStoreName);
if (!alreadyKnown) {
storageRegistry.createTableIfNotExist(tupleStoreName, config);
}
}
} catch (ZookeeperException e) {
throw new StorageManagerException(e);
}
}
use of org.bboxdb.storage.StorageManagerException 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.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class SSTableFacade method loadSpatialIndex.
/**
* Load the spatial index from file
* @throws StorageManagerException
*/
protected void loadSpatialIndex(final File spatialIndexFile) throws StorageManagerException {
if (!spatialIndexFile.exists()) {
throw new StorageManagerException("The spatial index does not exists: " + spatialIndexFile);
}
try (final RandomAccessFile randomAccessFile = new RandomAccessFile(spatialIndexFile, "r")) {
spatialIndex = SpatialIndexReaderFactory.getInstance();
spatialIndex.readFromFile(randomAccessFile);
} catch (Exception e) {
throw new StorageManagerException(e);
}
}
use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class Memtable method put.
@Override
public void put(final Tuple value) throws StorageManagerException {
assert (usage.get() > 0);
if (freePos >= maxEntries) {
throw new StorageManagerException("Unable to store a new tuple, all memtable slots are full");
}
data[freePos] = value;
bloomFilter.put(value.getKey());
final SpatialIndexEntry indexEntry = new SpatialIndexEntry(value.getBoundingBox(), freePos);
spatialIndex.insert(indexEntry);
freePos++;
sizeInMemory = sizeInMemory + value.getSize();
if (oldestTupleTimestamp == -1) {
oldestTupleTimestamp = value.getVersionTimestamp();
} else {
oldestTupleTimestamp = Math.min(oldestTupleTimestamp, value.getVersionTimestamp());
}
if (newestTupleTimestamp == -1) {
newestTupleTimestamp = value.getVersionTimestamp();
} else {
newestTupleTimestamp = Math.max(newestTupleTimestamp, value.getVersionTimestamp());
}
}
use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class DistributedRecoveryService method handleOutdatedRegions.
/**
* Handle the outdated distribution regions
* @param distributionGroupName
* @param outdatedRegions
*/
protected void handleOutdatedRegions(final String distributionGroupName, final List<OutdatedDistributionRegion> outdatedRegions) {
for (final OutdatedDistributionRegion outdatedDistributionRegion : outdatedRegions) {
final BBoxDBConnection connection = MembershipConnectionService.getInstance().getConnectionForInstance(outdatedDistributionRegion.getNewestInstance());
final long regionId = outdatedDistributionRegion.getDistributedRegion().getRegionId();
final List<TupleStoreName> allTables = TupleStoreUtil.getAllTablesForDistributionGroupAndRegionId(storageRegistry, distributionGroupName, regionId);
for (final TupleStoreName ssTableName : allTables) {
try {
runRecoveryForTable(ssTableName, outdatedDistributionRegion, connection.getBboxDBClient());
} catch (RejectedException | StorageManagerException | ExecutionException e) {
logger.error("Got an exception while performing recovery for table: " + ssTableName.getFullname());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
logger.error("Got an exception while performing recovery for table: " + ssTableName.getFullname());
}
}
}
}
Aggregations