Search in sources :

Example 16 with TupleStoreManagerRegistry

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();
}
Also used : TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) File(java.io.File)

Example 17 with TupleStoreManagerRegistry

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();
}
Also used : TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) ArrayList(java.util.ArrayList) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) StorageManagerException(org.bboxdb.storage.StorageManagerException) ReadOnlyTupleStore(org.bboxdb.storage.tuplestore.ReadOnlyTupleStore) BBoxDBException(org.bboxdb.misc.BBoxDBException) StorageManagerException(org.bboxdb.storage.StorageManagerException) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Example 18 with TupleStoreManagerRegistry

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();
}
Also used : TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) BeforeClass(org.junit.BeforeClass)

Example 19 with TupleStoreManagerRegistry

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);
}
Also used : TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) RoutingHeader(org.bboxdb.network.routing.RoutingHeader) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) RoutingHop(org.bboxdb.network.routing.RoutingHop) Tuple(org.bboxdb.storage.entity.Tuple)

Example 20 with TupleStoreManagerRegistry

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;
}
Also used : TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) BBoxDBException(org.bboxdb.misc.BBoxDBException) Tuple(org.bboxdb.storage.entity.Tuple)

Aggregations

TupleStoreManagerRegistry (org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry)21 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)10 BeforeClass (org.junit.BeforeClass)5 StorageManagerException (org.bboxdb.storage.StorageManagerException)4 ArrayList (java.util.ArrayList)3 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)3 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)3 SpacePartitioner (org.bboxdb.distribution.partitioner.SpacePartitioner)2 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)2 TupleStoreAdapter (org.bboxdb.distribution.zookeeper.TupleStoreAdapter)2 BBoxDBException (org.bboxdb.misc.BBoxDBException)2 Tuple (org.bboxdb.storage.entity.Tuple)2 File (java.io.File)1 List (java.util.List)1 DistributedRecoveryService (org.bboxdb.distribution.DistributedRecoveryService)1 TupleStoreFlushZookeeperAdapter (org.bboxdb.distribution.TupleStoreFlushZookeeperAdapter)1 MembershipConnectionService (org.bboxdb.distribution.membership.MembershipConnectionService)1 KDtreeSpacePartitioner (org.bboxdb.distribution.partitioner.KDtreeSpacePartitioner)1 RegionMerger (org.bboxdb.distribution.partitioner.regionsplit.RegionMerger)1 RegionSplitter (org.bboxdb.distribution.partitioner.regionsplit.RegionSplitter)1