use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class KeyClientQuery method computeTuples.
/**
* Fetch the tuples for the given key and remove the duplicates
*/
protected void computeTuples() {
try {
final String fullname = requestTable.getDistributionGroup();
final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(fullname);
final DistributionRegionIdMapper regionIdMapper = spacePartitioner.getDistributionRegionIdMapper();
final List<TupleStoreName> localTables = regionIdMapper.getAllLocalTables(requestTable);
for (final TupleStoreName tupleStoreName : localTables) {
final TupleStoreManager storageManager = clientConnectionHandler.getStorageRegistry().getTupleStoreManager(tupleStoreName);
final List<Tuple> tuplesInTable = storageManager.get(key);
tuplesForKey.addAll(tuplesInTable);
}
removeDuplicates(localTables);
} catch (BBoxDBException | StorageManagerException e) {
logger.error("Got an exception while fetching tuples for key " + key, e);
tuplesForKey.clear();
}
}
use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class StreamClientQuery method setupNewIterator.
/**
* Setup a new iterator with the next local table
*/
protected boolean setupNewIterator() {
if (activeOperatorIterator != null && !activeOperatorIterator.hasNext()) {
logger.warn("setupNewIterator() called, but old iterator is not exhaustet. Ignoring call");
return false;
}
if (getNumberOfTablesToProcess() == 0) {
logger.warn("setupNewIterator() called, but localTables are empty");
return false;
}
try {
final List<TupleStoreManager> storageManagers = new ArrayList<>();
final TupleStoreManagerRegistry storageRegistry = clientConnectionHandler.getStorageRegistry();
for (final TupleStoreName tupleStoreName : requestTables) {
final TupleStoreName sstableName = localTables.get(tupleStoreName).remove(0);
final TupleStoreManager storageManager = QueryHelper.getTupleStoreManager(storageRegistry, sstableName);
storageManagers.add(storageManager);
}
activeOperator = operatorTreeBuilder.buildOperatorTree(storageManagers);
activeOperatorIterator = activeOperator.iterator();
return true;
} catch (StorageManagerException | ZookeeperException e) {
logger.warn("Got exception while fetching tuples", e);
}
return false;
}
use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class TestTupleSink method testTupleSink.
/**
* Test the tuple sinks
* @throws StorageManagerException
* @throws BBoxDBException
* @throws ZookeeperException
* @throws InterruptedException
*/
@Test(timeout = 60000)
public void testTupleSink() throws StorageManagerException, BBoxDBException, ZookeeperException, InterruptedException {
final DistributionRegion distributionRegion = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(TEST_GROUP).getRootNode();
tupleStoreAdapter.deleteTable(TABLENAME);
tupleStoreAdapter.writeTuplestoreConfiguration(TABLENAME, new TupleStoreConfiguration());
final List<BBoxDBInstance> systems = Arrays.asList(new BBoxDBInstance("10.0.0.1:10000"), new BBoxDBInstance("10.0.0.2:10000"), ZookeeperClientFactory.getLocalInstanceName());
distributionRegion.setSystems(systems);
final TupleRedistributor tupleRedistributor = createTupleRedistributor();
tupleRedistributor.registerRegion(distributionRegion);
final Map<DistributionRegion, List<AbstractTupleSink>> map = tupleRedistributor.getRegionMap();
Assert.assertEquals(1, map.size());
final long networkSinks = map.values().stream().flatMap(e -> e.stream()).filter(s -> s instanceof NetworkTupleSink).count();
Assert.assertEquals(2, networkSinks);
final long localSinks = map.values().stream().flatMap(e -> e.stream()).filter(s -> s instanceof LocalTupleSink).count();
Assert.assertEquals(1, localSinks);
}
use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class TupleStoreManager method scanForExistingTables.
/**
* Scan the database directory for all existing SSTables and
* create reader objects
* @throws StorageManagerException
* @throws InterruptedException
*/
protected void scanForExistingTables() throws StorageManagerException, InterruptedException {
logger.info("Scan for existing SSTables: " + tupleStoreName.getFullname());
final String storageDir = storage.getBasedir().getAbsolutePath();
final String ssTableDir = SSTableHelper.getSSTableDir(storageDir, tupleStoreName);
final File directoryHandle = new File(ssTableDir);
checkSSTableDir(directoryHandle);
final File[] entries = directoryHandle.listFiles();
for (final File file : entries) {
final String filename = file.getName();
if (SSTableHelper.isFileNameSSTable(filename)) {
logger.info("Found sstable: {}", filename);
try {
final int sequenceNumber = SSTableHelper.extractSequenceFromFilename(tupleStoreName, filename);
final SSTableFacade facade = new SSTableFacade(storageDir, tupleStoreName, sequenceNumber, configuration.getSstableKeyCacheEntries());
facade.init();
tupleStoreInstances.addNewDetectedSSTable(facade);
} catch (BBoxDBException e) {
throw new StorageManagerException(e);
}
}
}
}
use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class TupleStoreManager method flush.
/**
* Flush all in memory data, if the memtable flush thread is running
* @return
*/
public boolean flush() {
final Memtable activeMemtable = tupleStoreInstances.getMemtable();
if (activeMemtable == null) {
return true;
}
// Flush in memory data
initNewMemtable();
try {
tupleStoreInstances.waitForMemtableFlush(activeMemtable);
} catch (InterruptedException e) {
logger.info("Got interrupted exception while waiting for memtable flush");
Thread.currentThread().interrupt();
return false;
} catch (StorageManagerException e) {
logger.info("Got exception while waiting for memtable flush", e);
return false;
}
return true;
}
Aggregations