Search in sources :

Example 31 with StorageManagerException

use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.

the class RTreeTestHelper method queryIndex.

/**
 * Test the query
 *
 * @param entries
 * @param index
 * @throws StorageManagerException
 */
public static void queryIndex(final List<SpatialIndexEntry> entries, final SpatialIndexReader index) throws StorageManagerException {
    for (final SpatialIndexEntry entry : entries) {
        final List<? extends SpatialIndexEntry> resultList = index.getEntriesForRegion(entry.getBoundingBox());
        Assert.assertTrue(resultList.size() >= 1);
        final List<Integer> keyResult = resultList.stream().map(e -> e.getValue()).filter(k -> k.equals(entry.getValue())).collect(Collectors.toList());
        Assert.assertTrue("Searching for: " + entry, keyResult.size() == 1);
    }
}
Also used : List(java.util.List) SpatialIndexReader(org.bboxdb.storage.sstable.spatialindex.SpatialIndexReader) Random(java.util.Random) StorageManagerException(org.bboxdb.storage.StorageManagerException) Assert(org.junit.Assert) Collectors(java.util.stream.Collectors) BoundingBox(org.bboxdb.commons.math.BoundingBox) SpatialIndexBuilder(org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry) ArrayList(java.util.ArrayList) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry)

Example 32 with StorageManagerException

use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.

the class RegionSplitter method spreadTupleStores.

/**
 * Spread a given tuple store onto new systems
 * @param region
 * @param sstableManager
 * @param ssTableManager
 * @param tupleRedistributor
 * @param onlyInMemoryData
 * @throws StorageManagerException
 */
private void spreadTupleStores(final TupleStoreManager ssTableManager, final TupleRedistributor tupleRedistributor) throws BBoxDBException {
    final List<ReadOnlyTupleStore> storages = new ArrayList<>();
    try {
        final List<ReadOnlyTupleStore> aquiredStorages = ssTableManager.aquireStorage();
        storages.addAll(aquiredStorages);
        final int totalSotrages = aquiredStorages.size();
        for (int i = 0; i < totalSotrages; i++) {
            final ReadOnlyTupleStore storage = aquiredStorages.get(i);
            logger.info("Spread tuple storage {} number {} of {}", storage.getInternalName(), i, totalSotrages - 1);
            spreadStorage(tupleRedistributor, storage);
        }
        logger.info("Final statistics for spread ({}): {}", ssTableManager.getTupleStoreName().getFullname(), tupleRedistributor.getStatistics());
    } catch (Exception e) {
        throw new BBoxDBException(e);
    } finally {
        ssTableManager.releaseStorage(storages);
    }
}
Also used : ArrayList(java.util.ArrayList) ReadOnlyTupleStore(org.bboxdb.storage.tuplestore.ReadOnlyTupleStore) BBoxDBException(org.bboxdb.misc.BBoxDBException) BBoxDBException(org.bboxdb.misc.BBoxDBException) StorageManagerException(org.bboxdb.storage.StorageManagerException)

Example 33 with StorageManagerException

use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.

the class QueryHelper method getTupleStoreManager.

/**
 * Get or create the tuple store manager
 * @param storageRegistry
 * @param tupleStoreName
 * @return
 * @throws ZookeeperException
 * @throws StorageManagerException
 */
public static TupleStoreManager getTupleStoreManager(TupleStoreManagerRegistry storageRegistry, final TupleStoreName tupleStoreName) throws ZookeeperException, StorageManagerException {
    if (storageRegistry.isStorageManagerKnown(tupleStoreName)) {
        return storageRegistry.getTupleStoreManager(tupleStoreName);
    }
    final TupleStoreAdapter tupleStoreAdapter = ZookeeperClientFactory.getZookeeperClient().getTupleStoreAdapter();
    if (!tupleStoreAdapter.isTableKnown(tupleStoreName)) {
        throw new StorageManagerException("Table: " + tupleStoreName.getFullname() + " is unkown");
    }
    final TupleStoreConfiguration config = tupleStoreAdapter.readTuplestoreConfiguration(tupleStoreName);
    return storageRegistry.createTableIfNotExist(tupleStoreName, config);
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleStoreAdapter(org.bboxdb.distribution.zookeeper.TupleStoreAdapter) StorageManagerException(org.bboxdb.storage.StorageManagerException)

Example 34 with StorageManagerException

use of org.bboxdb.storage.StorageManagerException 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 35 with StorageManagerException

use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.

the class SSTableExaminer method run.

@Override
public void run() {
    try {
        final SSTableFacade sstableFacade = new SSTableFacade(baseDirectory, relationname, tableNumber, 0);
        sstableFacade.init();
        if (!sstableFacade.acquire()) {
            throw new StorageManagerException("Unable to acquire sstable reader");
        }
        final SSTableReader ssTableReader = sstableFacade.getSsTableReader();
        final SSTableKeyIndexReader ssTableIndexReader = sstableFacade.getSsTableKeyIndexReader();
        fullTableScan(ssTableReader);
        if (!WILDCARD_KEY.equals(examineKey)) {
            internalScan(ssTableReader);
            seachViaIndex(ssTableReader, ssTableIndexReader);
        }
        sstableFacade.release();
        sstableFacade.shutdown();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : SSTableReader(org.bboxdb.storage.sstable.reader.SSTableReader) SSTableKeyIndexReader(org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader) SSTableFacade(org.bboxdb.storage.sstable.reader.SSTableFacade) StorageManagerException(org.bboxdb.storage.StorageManagerException) IOException(java.io.IOException) StorageManagerException(org.bboxdb.storage.StorageManagerException) BufferUnderflowException(java.nio.BufferUnderflowException)

Aggregations

StorageManagerException (org.bboxdb.storage.StorageManagerException)48 BBoxDBException (org.bboxdb.misc.BBoxDBException)16 IOException (java.io.IOException)14 ArrayList (java.util.ArrayList)14 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)12 Tuple (org.bboxdb.storage.entity.Tuple)11 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)8 File (java.io.File)7 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)7 ReadOnlyTupleStore (org.bboxdb.storage.tuplestore.ReadOnlyTupleStore)6 List (java.util.List)5 RejectedException (org.bboxdb.commons.RejectedException)5 SpatialIndexEntry (org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry)5 DiskStorage (org.bboxdb.storage.tuplestore.DiskStorage)5 RandomAccessFile (java.io.RandomAccessFile)4 Collectors (java.util.stream.Collectors)4 BoundingBox (org.bboxdb.commons.math.BoundingBox)4 SpacePartitioner (org.bboxdb.distribution.partitioner.SpacePartitioner)4 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)4 SSTableFacade (org.bboxdb.storage.sstable.reader.SSTableFacade)4