use of org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry in project bboxdb by jnidzwetzki.
the class SSTableTupleStore method open.
@Override
public void open() throws Exception {
logger.info("Open for sstable {} called", SSTABLE_NAME.getFullname());
if (serviceState.isInRunningState()) {
logger.error("Service is already in running state, ignoring call");
return;
}
serviceState.dipatchToStarting();
BBoxDBConfigurationManager.getConfiguration().setStorageDirectories(Arrays.asList(dir.getAbsolutePath()));
final File dataDir = new File(dir.getAbsoluteFile() + "/data");
dataDir.mkdirs();
storageRegistry = new TupleStoreManagerRegistry();
storageRegistry.init();
storageManager = storageRegistry.getTupleStoreManager(SSTABLE_NAME);
serviceState.dispatchToRunning();
}
use of org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry 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.tuplestore.manager.TupleStoreManagerRegistry in project bboxdb by jnidzwetzki.
the class TestQueryProcessing method beforeClass.
@BeforeClass
public static void beforeClass() throws InterruptedException, BBoxDBException {
storageRegistry = new TupleStoreManagerRegistry();
storageRegistry.init();
}
use of org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry in project bboxdb by jnidzwetzki.
the class InsertTupleHandler method processPackageLocally.
/**
* @param packageSequence
* @param clientConnectionHandler
* @param insertTupleRequest
* @param routingHeader
* @throws BBoxDBException
* @throws RejectedException
* @throws PackageEncodeException
*/
private void processPackageLocally(final short packageSequence, final ClientConnectionHandler clientConnectionHandler, final InsertTupleRequest insertTupleRequest) throws BBoxDBException, RejectedException, PackageEncodeException {
final Tuple tuple = insertTupleRequest.getTuple();
final TupleStoreName requestTable = insertTupleRequest.getTable();
final TupleStoreManagerRegistry storageRegistry = clientConnectionHandler.getStorageRegistry();
final RoutingHeader routingHeader = insertTupleRequest.getRoutingHeader();
final RoutingHop localHop = routingHeader.getRoutingHop();
PackageRouter.checkLocalSystemNameMatchesAndThrowException(localHop);
final List<Long> distributionRegions = localHop.getDistributionRegions();
processInsertPackage(tuple, requestTable, storageRegistry, distributionRegions);
forwardRoutedPackage(packageSequence, clientConnectionHandler, insertTupleRequest);
}
use of org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry in project bboxdb by jnidzwetzki.
the class KeepAliveHandler method handleGossip.
/**
* Handle keep alive gossip
* @param keepAliveRequst
* @param clientConnectionHandler
* @return
*/
private boolean handleGossip(final KeepAliveRequest keepAliveRequst, final ClientConnectionHandler clientConnectionHandler) {
final String table = keepAliveRequst.getTablename();
final TupleStoreName tupleStoreName = new TupleStoreName(table);
final List<Tuple> tuples = keepAliveRequst.getTuples();
final TupleStoreManagerRegistry storageRegistry = clientConnectionHandler.getStorageRegistry();
try {
for (final Tuple tuple : tuples) {
final boolean result = checkLocalTuples(storageRegistry, tupleStoreName, tuple);
if (!result) {
return false;
}
}
} catch (BBoxDBException e) {
logger.error("Got exception while handling gossip", e);
}
return true;
}
Aggregations