Search in sources :

Example 6 with StorageManagerException

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

the class SSTableServiceRunnable method processTupleStores.

/**
 * Process the tuple stores
 *
 * @param storageRegistry
 * @param tupleStores
 * @throws InterruptedException
 */
private void processTupleStores(final TupleStoreManagerRegistry storageRegistry, final List<TupleStoreName> tupleStores) throws InterruptedException {
    for (final TupleStoreName tupleStoreName : tupleStores) {
        try {
            logger.debug("Running compact for: {}", tupleStoreName);
            final TupleStoreManager tupleStoreManager = storageRegistry.getTupleStoreManager(tupleStoreName);
            if (tupleStoreManager.getSstableManagerState() == TupleStoreManagerState.READ_ONLY) {
                logger.debug("Skipping compact for read only sstable manager: {}", tupleStoreName);
                continue;
            }
            if (!CompactorHelper.isRegionActive(tupleStoreName)) {
                logger.info("Skipping compact run, because region is not active {}", tupleStoreName);
                continue;
            }
            final List<SSTableFacade> facades = getAllTupleStores(tupleStoreManager);
            final MergeTask mergeTask = mergeStrategy.getMergeTask(facades);
            executeCompactTask(mergeTask, tupleStoreManager);
            testForRegionOverflow(tupleStoreManager);
        } catch (StorageManagerException | BBoxDBException e) {
            logger.error("Error while merging tables", e);
        }
    }
}
Also used : SSTableFacade(org.bboxdb.storage.sstable.reader.SSTableFacade) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) StorageManagerException(org.bboxdb.storage.StorageManagerException) BBoxDBException(org.bboxdb.misc.BBoxDBException) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Example 7 with StorageManagerException

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

the class SSTableServiceRunnable method registerNewFacadeAndDeleteOldInstances.

/**
 * Register a new sstable facade and delete the old ones
 * @param oldFacades
 * @param directory
 * @param name
 * @param tablenumber
 * @throws StorageManagerException
 */
private void registerNewFacadeAndDeleteOldInstances(final TupleStoreManager sstableManager, final List<SSTableFacade> oldFacades, final List<SSTableWriter> newTableWriter) throws StorageManagerException {
    final List<SSTableFacade> newFacades = new ArrayList<>();
    // Open new facades
    openFacades(newTableWriter, newFacades);
    // Manager has switched to read only
    if (sstableManager.getSstableManagerState() == TupleStoreManagerState.READ_ONLY) {
        logger.info("Manager is in read only mode, cancel compact run");
        handleCompactException(newFacades);
        return;
    }
    try {
        for (final SSTableFacade facade : newFacades) {
            facade.init();
        }
        // Switch facades in registry
        sstableManager.replaceCompactedSStables(newFacades, oldFacades);
        // Schedule facades for deletion
        oldFacades.forEach(f -> f.deleteOnClose());
    } catch (BBoxDBException | RejectedException e) {
        handleCompactException(newFacades);
        throw new StorageManagerException(e);
    } catch (InterruptedException e) {
        handleCompactException(newFacades);
        Thread.currentThread().interrupt();
        throw new StorageManagerException(e);
    }
}
Also used : RejectedException(org.bboxdb.commons.RejectedException) ArrayList(java.util.ArrayList) SSTableFacade(org.bboxdb.storage.sstable.reader.SSTableFacade) StorageManagerException(org.bboxdb.storage.StorageManagerException) BBoxDBException(org.bboxdb.misc.BBoxDBException)

Example 8 with StorageManagerException

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

the class RTreeMemoryReader method readFromFile.

@Override
public void readFromFile(final RandomAccessFile randomAccessFile) throws StorageManagerException, InterruptedException {
    assert (rootNode == null);
    try {
        // Validate the magic bytes
        validateStream(randomAccessFile);
        maxNodeSize = DataEncoderHelper.readIntFromDataInput(randomAccessFile);
        readDirectoryNode(randomAccessFile, null);
        while (!childToReadQueue.isEmpty()) {
            final Entry<RTreeDirectoryNode, Integer> element = childToReadQueue.remove();
            readDirectoryNode(randomAccessFile, element.getKey());
        }
    } catch (IOException e) {
        throw new StorageManagerException(e);
    }
}
Also used : IOException(java.io.IOException) StorageManagerException(org.bboxdb.storage.StorageManagerException)

Example 9 with StorageManagerException

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

the class RTreeSerializer method writeToStream.

/**
 * Serialize the tree to the file
 * @param randomAccessFile
 * @throws StorageManagerException
 */
public void writeToStream(final RandomAccessFile randomAccessFile) throws StorageManagerException {
    nodesQueue.clear();
    try {
        // Write the magic bytes
        randomAccessFile.write(SSTableConst.MAGIC_BYTES_SPATIAL_RTREE_INDEX);
        // Write the tree configuration
        final ByteBuffer nodeSizeBytes = DataEncoderHelper.intToByteBuffer(maxNodeSize);
        randomAccessFile.write(nodeSizeBytes.array());
        nodesQueue.push(rootNode);
        while (!nodesQueue.isEmpty()) {
            final RTreeDirectoryNode node = nodesQueue.pop();
            handleNewNode(randomAccessFile, node);
        }
        updateIndexNodePointer(randomAccessFile);
    } catch (IOException e) {
        throw new StorageManagerException(e);
    }
}
Also used : IOException(java.io.IOException) StorageManagerException(org.bboxdb.storage.StorageManagerException) ByteBuffer(java.nio.ByteBuffer)

Example 10 with StorageManagerException

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

the class RTreeMMFReader method readFromFile.

@Override
public void readFromFile(final RandomAccessFile randomAccessFile) throws StorageManagerException, InterruptedException {
    try {
        validateStream(randomAccessFile);
        maxNodeSize = DataEncoderHelper.readIntFromDataInput(randomAccessFile);
        firstNodePos = (int) randomAccessFile.getFilePointer();
        fileChannel = randomAccessFile.getChannel();
        final long size = fileChannel.size();
        memory = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, size);
        memory.order(Const.APPLICATION_BYTE_ORDER);
    } catch (IOException e) {
        throw new StorageManagerException(e);
    }
}
Also used : IOException(java.io.IOException) 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