use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.
the class KeepAliveHandler method checkLocalTuples.
/**
* @param tupleStoreManagerRegistry
* @param tupleStoreName
* @param tuple
* @throws BBoxDBException
* @throws StorageManagerException
*/
private boolean checkLocalTuples(final TupleStoreManagerRegistry tupleStoreManagerRegistry, final TupleStoreName tupleStoreName, final Tuple tuple) throws BBoxDBException {
final String fullname = tupleStoreName.getDistributionGroup();
final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(fullname);
final DistributionRegionIdMapper regionIdMapper = spacePartitioner.getDistributionRegionIdMapper();
final Collection<TupleStoreName> localTables = regionIdMapper.getLocalTablesForRegion(tuple.getBoundingBox(), tupleStoreName);
for (final TupleStoreName localTupleStoreName : localTables) {
try {
final TupleStoreManager storageManager = tupleStoreManagerRegistry.getTupleStoreManager(localTupleStoreName);
final String key = tuple.getKey();
final List<Tuple> localTuples = storageManager.get(key);
if (localTables.isEmpty()) {
logger.error("Got empty tuple list during gossip");
return false;
}
final List<Long> localVersions = getSortedVersionList(localTuples);
final long gossipTupleVersion = tuple.getVersionTimestamp();
return checkLocalTupleVersions(localVersions, gossipTupleVersion, key);
} catch (StorageManagerException e) {
logger.error("Got exception while reading tuples", e);
}
}
return true;
}
use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.
the class MemtableWriterRunnable method runThread.
/**
* Start the flush thread
*/
@Override
protected void runThread() {
while (!Thread.currentThread().isInterrupted()) {
try {
final MemtableAndTupleStoreManagerPair memtableAndSSTableManager = storage.takeNextUnflushedMemtable();
final Memtable memtable = memtableAndSSTableManager.getMemtable();
final TupleStoreManager sstableManager = memtableAndSSTableManager.getTupleStoreManager();
flushMemtableToDisk(memtable, sstableManager);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
}
}
}
use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.
the class SSTableCheckpointRunnable method createCheckpointIfNeeded.
/**
* Create a checkpoint if needed
* @param storageRegistry
* @param ssTableName
*/
protected void createCheckpointIfNeeded(final TupleStoreManagerRegistry storageRegistry, final TupleStoreName ssTableName) {
try {
final TupleStoreManager ssTableManager = storageRegistry.getTupleStoreManager(ssTableName);
createCheckpoint(ssTableManager);
} catch (InterruptedException e) {
logger.debug("Got interrupted exception, stopping checkpoint thread");
Thread.currentThread().interrupt();
} catch (StorageManagerException e) {
logger.error("Got exception while creating checkpoint", e);
}
}
use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.
the class KeyClientQuery method removeDuplicates.
/**
* Remove the duplicates for the given key
* @param localTables
* @throws StorageManagerException
*/
protected void removeDuplicates(final List<TupleStoreName> localTables) throws StorageManagerException {
// No local table is known, so no configuration is known
if (localTables.isEmpty()) {
return;
}
final TupleStoreManager storageManager = clientConnectionHandler.getStorageRegistry().getTupleStoreManager(localTables.get(0));
final DuplicateResolver<Tuple> duplicateResolver = TupleDuplicateResolverFactory.build(storageManager.getTupleStoreConfiguration());
duplicateResolver.removeDuplicates(tuplesForKey);
}
use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager 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();
}
Aggregations