use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class RTreeTestHelper method queryIndex.
/**
* Test the query
*
* @param entries
* @param index
* @throws StorageManagerException
*/
public static void queryIndex(final List<SpatialIndexEntry> entries, final SpatialIndexReader index) throws StorageManagerException {
for (final SpatialIndexEntry entry : entries) {
final List<? extends SpatialIndexEntry> resultList = index.getEntriesForRegion(entry.getBoundingBox());
Assert.assertTrue(resultList.size() >= 1);
final List<Integer> keyResult = resultList.stream().map(e -> e.getValue()).filter(k -> k.equals(entry.getValue())).collect(Collectors.toList());
Assert.assertTrue("Searching for: " + entry, keyResult.size() == 1);
}
}
use of org.bboxdb.storage.StorageManagerException 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.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class QueryHelper method getTupleStoreManager.
/**
* Get or create the tuple store manager
* @param storageRegistry
* @param tupleStoreName
* @return
* @throws ZookeeperException
* @throws StorageManagerException
*/
public static TupleStoreManager getTupleStoreManager(TupleStoreManagerRegistry storageRegistry, final TupleStoreName tupleStoreName) throws ZookeeperException, StorageManagerException {
if (storageRegistry.isStorageManagerKnown(tupleStoreName)) {
return storageRegistry.getTupleStoreManager(tupleStoreName);
}
final TupleStoreAdapter tupleStoreAdapter = ZookeeperClientFactory.getZookeeperClient().getTupleStoreAdapter();
if (!tupleStoreAdapter.isTableKnown(tupleStoreName)) {
throw new StorageManagerException("Table: " + tupleStoreName.getFullname() + " is unkown");
}
final TupleStoreConfiguration config = tupleStoreAdapter.readTuplestoreConfiguration(tupleStoreName);
return storageRegistry.createTableIfNotExist(tupleStoreName, config);
}
use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class ConnectionMainteinanceRunnable method sendKeepAlivePackage.
/**
* Build a keep alive package (with or without gossip)
* @return
* @return
*/
private EmptyResultFuture sendKeepAlivePackage() {
final TupleStoreManagerRegistry tupleStoreManagerRegistry = bboxDBClient.getTupleStoreManagerRegistry();
if (tupleStoreManagerRegistry == null) {
return bboxDBClient.sendKeepAlivePackage();
}
final List<TupleStoreName> tables = tupleStoreManagerRegistry.getAllTables();
if (tables.isEmpty()) {
return bboxDBClient.sendKeepAlivePackage();
}
lastGossipTableName = ListHelper.getElementRandom(tables);
List<ReadOnlyTupleStore> storages = new ArrayList<>();
try {
final TupleStoreManager tupleStoreManager = tupleStoreManagerRegistry.getTupleStoreManager(lastGossipTableName);
try {
storages = tupleStoreManager.aquireStorage();
if (storages.isEmpty()) {
return bboxDBClient.sendKeepAlivePackage();
}
final ReadOnlyTupleStore tupleStore = ListHelper.getElementRandom(storages);
if (tupleStore.getNumberOfTuples() > 0) {
return sendKeepAliveWithGossip(tupleStoreManager, tupleStore);
}
} catch (Exception e) {
throw e;
} finally {
tupleStoreManager.releaseStorage(storages);
}
} catch (StorageManagerException e) {
logger.error("Got exception while reading tuples", e);
}
return bboxDBClient.sendKeepAlivePackage();
}
use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class SSTableExaminer method run.
@Override
public void run() {
try {
final SSTableFacade sstableFacade = new SSTableFacade(baseDirectory, relationname, tableNumber, 0);
sstableFacade.init();
if (!sstableFacade.acquire()) {
throw new StorageManagerException("Unable to acquire sstable reader");
}
final SSTableReader ssTableReader = sstableFacade.getSsTableReader();
final SSTableKeyIndexReader ssTableIndexReader = sstableFacade.getSsTableKeyIndexReader();
fullTableScan(ssTableReader);
if (!WILDCARD_KEY.equals(examineKey)) {
internalScan(ssTableReader);
seachViaIndex(ssTableReader, ssTableIndexReader);
}
sstableFacade.release();
sstableFacade.shutdown();
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations