Search in sources :

Example 16 with TupleStoreManager

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;
}
Also used : TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) StorageManagerException(org.bboxdb.storage.StorageManagerException) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) Tuple(org.bboxdb.storage.entity.Tuple) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Example 17 with TupleStoreManager

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;
        }
    }
}
Also used : MemtableAndTupleStoreManagerPair(org.bboxdb.storage.entity.MemtableAndTupleStoreManagerPair) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Example 18 with TupleStoreManager

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

Example 19 with TupleStoreManager

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);
}
Also used : Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Example 20 with TupleStoreManager

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();
}
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)

Aggregations

TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)32 Tuple (org.bboxdb.storage.entity.Tuple)17 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)17 Test (org.junit.Test)12 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)11 BoundingBox (org.bboxdb.commons.math.BoundingBox)10 BBoxDBException (org.bboxdb.misc.BBoxDBException)10 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)10 TupleStoreManagerRegistry (org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry)9 StorageManagerException (org.bboxdb.storage.StorageManagerException)8 IndexedSpatialJoinOperator (org.bboxdb.storage.queryprocessor.operator.IndexedSpatialJoinOperator)8 SpatialIndexReadOperator (org.bboxdb.storage.queryprocessor.operator.SpatialIndexReadOperator)8 ArrayList (java.util.ArrayList)7 List (java.util.List)6 RejectedException (org.bboxdb.commons.RejectedException)6 Lists (com.google.common.collect.Lists)5 Iterator (java.util.Iterator)5 Collectors (java.util.stream.Collectors)5 AfterClass (org.junit.AfterClass)5 IOException (java.io.IOException)4