Search in sources :

Example 21 with StorageManagerException

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

the class KeyClientQuery method computeTuples.

/**
 * Fetch the tuples for the given key and remove the duplicates
 */
protected void computeTuples() {
    try {
        final String fullname = requestTable.getDistributionGroup();
        final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(fullname);
        final DistributionRegionIdMapper regionIdMapper = spacePartitioner.getDistributionRegionIdMapper();
        final List<TupleStoreName> localTables = regionIdMapper.getAllLocalTables(requestTable);
        for (final TupleStoreName tupleStoreName : localTables) {
            final TupleStoreManager storageManager = clientConnectionHandler.getStorageRegistry().getTupleStoreManager(tupleStoreName);
            final List<Tuple> tuplesInTable = storageManager.get(key);
            tuplesForKey.addAll(tuplesInTable);
        }
        removeDuplicates(localTables);
    } catch (BBoxDBException | StorageManagerException e) {
        logger.error("Got an exception while fetching tuples for key " + key, e);
        tuplesForKey.clear();
    }
}
Also used : TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) StorageManagerException(org.bboxdb.storage.StorageManagerException) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) BBoxDBException(org.bboxdb.misc.BBoxDBException) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Example 22 with StorageManagerException

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

the class StreamClientQuery method setupNewIterator.

/**
 * Setup a new iterator with the next local table
 */
protected boolean setupNewIterator() {
    if (activeOperatorIterator != null && !activeOperatorIterator.hasNext()) {
        logger.warn("setupNewIterator() called, but old iterator is not exhaustet. Ignoring call");
        return false;
    }
    if (getNumberOfTablesToProcess() == 0) {
        logger.warn("setupNewIterator() called, but localTables are empty");
        return false;
    }
    try {
        final List<TupleStoreManager> storageManagers = new ArrayList<>();
        final TupleStoreManagerRegistry storageRegistry = clientConnectionHandler.getStorageRegistry();
        for (final TupleStoreName tupleStoreName : requestTables) {
            final TupleStoreName sstableName = localTables.get(tupleStoreName).remove(0);
            final TupleStoreManager storageManager = QueryHelper.getTupleStoreManager(storageRegistry, sstableName);
            storageManagers.add(storageManager);
        }
        activeOperator = operatorTreeBuilder.buildOperatorTree(storageManagers);
        activeOperatorIterator = activeOperator.iterator();
        return true;
    } catch (StorageManagerException | ZookeeperException e) {
        logger.warn("Got exception while fetching tuples", e);
    }
    return false;
}
Also used : ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) ArrayList(java.util.ArrayList) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) StorageManagerException(org.bboxdb.storage.StorageManagerException) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Example 23 with StorageManagerException

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

the class TestTupleSink method testTupleSink.

/**
 * Test the tuple sinks
 * @throws StorageManagerException
 * @throws BBoxDBException
 * @throws ZookeeperException
 * @throws InterruptedException
 */
@Test(timeout = 60000)
public void testTupleSink() throws StorageManagerException, BBoxDBException, ZookeeperException, InterruptedException {
    final DistributionRegion distributionRegion = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(TEST_GROUP).getRootNode();
    tupleStoreAdapter.deleteTable(TABLENAME);
    tupleStoreAdapter.writeTuplestoreConfiguration(TABLENAME, new TupleStoreConfiguration());
    final List<BBoxDBInstance> systems = Arrays.asList(new BBoxDBInstance("10.0.0.1:10000"), new BBoxDBInstance("10.0.0.2:10000"), ZookeeperClientFactory.getLocalInstanceName());
    distributionRegion.setSystems(systems);
    final TupleRedistributor tupleRedistributor = createTupleRedistributor();
    tupleRedistributor.registerRegion(distributionRegion);
    final Map<DistributionRegion, List<AbstractTupleSink>> map = tupleRedistributor.getRegionMap();
    Assert.assertEquals(1, map.size());
    final long networkSinks = map.values().stream().flatMap(e -> e.stream()).filter(s -> s instanceof NetworkTupleSink).count();
    Assert.assertEquals(2, networkSinks);
    final long localSinks = map.values().stream().flatMap(e -> e.stream()).filter(s -> s instanceof LocalTupleSink).count();
    Assert.assertEquals(1, localSinks);
}
Also used : TupleRedistributor(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.TupleRedistributor) Arrays(java.util.Arrays) BeforeClass(org.junit.BeforeClass) TupleStoreAdapter(org.bboxdb.distribution.zookeeper.TupleStoreAdapter) LocalTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.LocalTupleSink) Tuple(org.bboxdb.storage.entity.Tuple) BoundingBox(org.bboxdb.commons.math.BoundingBox) ArrayList(java.util.ArrayList) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) Map(java.util.Map) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) StorageManagerException(org.bboxdb.storage.StorageManagerException) DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) ZookeeperClientFactory(org.bboxdb.distribution.zookeeper.ZookeeperClientFactory) NetworkTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.NetworkTupleSink) DistributionGroupConfigurationBuilder(org.bboxdb.storage.entity.DistributionGroupConfigurationBuilder) Test(org.junit.Test) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) Mockito(org.mockito.Mockito) List(java.util.List) AbstractTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.AbstractTupleSink) BBoxDBException(org.bboxdb.misc.BBoxDBException) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) DistributionGroupAdapter(org.bboxdb.distribution.zookeeper.DistributionGroupAdapter) SpacePartitionerCache(org.bboxdb.distribution.partitioner.SpacePartitionerCache) TupleRedistributor(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.TupleRedistributor) Assert(org.junit.Assert) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) LocalTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.LocalTupleSink) NetworkTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.NetworkTupleSink) ArrayList(java.util.ArrayList) List(java.util.List) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Example 24 with StorageManagerException

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

the class TupleStoreManager method scanForExistingTables.

/**
 * Scan the database directory for all existing SSTables and
 * create reader objects
 * @throws StorageManagerException
 * @throws InterruptedException
 */
protected void scanForExistingTables() throws StorageManagerException, InterruptedException {
    logger.info("Scan for existing SSTables: " + tupleStoreName.getFullname());
    final String storageDir = storage.getBasedir().getAbsolutePath();
    final String ssTableDir = SSTableHelper.getSSTableDir(storageDir, tupleStoreName);
    final File directoryHandle = new File(ssTableDir);
    checkSSTableDir(directoryHandle);
    final File[] entries = directoryHandle.listFiles();
    for (final File file : entries) {
        final String filename = file.getName();
        if (SSTableHelper.isFileNameSSTable(filename)) {
            logger.info("Found sstable: {}", filename);
            try {
                final int sequenceNumber = SSTableHelper.extractSequenceFromFilename(tupleStoreName, filename);
                final SSTableFacade facade = new SSTableFacade(storageDir, tupleStoreName, sequenceNumber, configuration.getSstableKeyCacheEntries());
                facade.init();
                tupleStoreInstances.addNewDetectedSSTable(facade);
            } catch (BBoxDBException e) {
                throw new StorageManagerException(e);
            }
        }
    }
}
Also used : SSTableFacade(org.bboxdb.storage.sstable.reader.SSTableFacade) StorageManagerException(org.bboxdb.storage.StorageManagerException) File(java.io.File) BBoxDBException(org.bboxdb.misc.BBoxDBException)

Example 25 with StorageManagerException

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

the class TupleStoreManager method flush.

/**
 * Flush all in memory data, if the memtable flush thread is running
 * @return
 */
public boolean flush() {
    final Memtable activeMemtable = tupleStoreInstances.getMemtable();
    if (activeMemtable == null) {
        return true;
    }
    // Flush in memory data
    initNewMemtable();
    try {
        tupleStoreInstances.waitForMemtableFlush(activeMemtable);
    } catch (InterruptedException e) {
        logger.info("Got interrupted exception while waiting for memtable flush");
        Thread.currentThread().interrupt();
        return false;
    } catch (StorageManagerException e) {
        logger.info("Got exception while waiting for memtable flush", e);
        return false;
    }
    return true;
}
Also used : Memtable(org.bboxdb.storage.memtable.Memtable) StorageManagerException(org.bboxdb.storage.StorageManagerException)

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