Search in sources :

Example 41 with StorageManagerException

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

the class InsertTupleHandler method createMissingTables.

/**
 * Create all missing tables
 */
protected void createMissingTables(final TupleStoreName requestTable, final TupleStoreManagerRegistry storageRegistry, final Collection<TupleStoreName> localTables) throws StorageManagerException {
    try {
        final TupleStoreAdapter tupleStoreAdapter = ZookeeperClientFactory.getZookeeperClient().getTupleStoreAdapter();
        if (!tupleStoreAdapter.isTableKnown(requestTable)) {
            throw new StorageManagerException("Table: " + requestTable.getFullname() + " is unkown");
        }
        final TupleStoreConfiguration config = tupleStoreAdapter.readTuplestoreConfiguration(requestTable);
        for (final TupleStoreName tupleStoreName : localTables) {
            final boolean alreadyKnown = storageRegistry.isStorageManagerKnown(tupleStoreName);
            if (!alreadyKnown) {
                storageRegistry.createTableIfNotExist(tupleStoreName, config);
            }
        }
    } catch (ZookeeperException e) {
        throw new StorageManagerException(e);
    }
}
Also used : ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleStoreAdapter(org.bboxdb.distribution.zookeeper.TupleStoreAdapter) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) StorageManagerException(org.bboxdb.storage.StorageManagerException)

Example 42 with StorageManagerException

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

the class CompactorHelper method isRegionActive.

/**
 * Is the region for the table active?
 *
 * @param tupleStoreName
 * @return
 * @throws StorageManagerException
 * @throws InterruptedException
 */
public static boolean isRegionActive(final TupleStoreName tupleStoreName) throws StorageManagerException, InterruptedException {
    try {
        if (!tupleStoreName.isDistributedTable()) {
            logger.error("Tuple store {} is not a distributed table, untable to split", tupleStoreName);
            return false;
        }
        final long regionId = tupleStoreName.getRegionId().getAsLong();
        final String distributionGroup = tupleStoreName.getDistributionGroup();
        final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(distributionGroup);
        final DistributionRegion distributionRegion = spacePartitioner.getRootNode();
        final DistributionRegion regionToSplit = DistributionRegionHelper.getDistributionRegionForNamePrefix(distributionRegion, regionId);
        // Region does not exist
        if (regionToSplit == null) {
            logger.error("Unable to get distribution region {} {}", distributionRegion, regionId);
            return false;
        }
        if (regionToSplit.isRootElement()) {
            return true;
        }
        return regionToSplit.getState() == DistributionRegionState.ACTIVE;
    } catch (BBoxDBException e) {
        throw new StorageManagerException(e);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw e;
    }
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) StorageManagerException(org.bboxdb.storage.StorageManagerException) BBoxDBException(org.bboxdb.misc.BBoxDBException) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner)

Example 43 with StorageManagerException

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

the class SSTableFacade method loadSpatialIndex.

/**
 * Load the spatial index from file
 * @throws StorageManagerException
 */
protected void loadSpatialIndex(final File spatialIndexFile) throws StorageManagerException {
    if (!spatialIndexFile.exists()) {
        throw new StorageManagerException("The spatial index does not exists: " + spatialIndexFile);
    }
    try (final RandomAccessFile randomAccessFile = new RandomAccessFile(spatialIndexFile, "r")) {
        spatialIndex = SpatialIndexReaderFactory.getInstance();
        spatialIndex.readFromFile(randomAccessFile);
    } catch (Exception e) {
        throw new StorageManagerException(e);
    }
}
Also used : RandomAccessFile(java.io.RandomAccessFile) StorageManagerException(org.bboxdb.storage.StorageManagerException) IOException(java.io.IOException) BBoxDBException(org.bboxdb.misc.BBoxDBException) StorageManagerException(org.bboxdb.storage.StorageManagerException)

Example 44 with StorageManagerException

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

the class Memtable method put.

@Override
public void put(final Tuple value) throws StorageManagerException {
    assert (usage.get() > 0);
    if (freePos >= maxEntries) {
        throw new StorageManagerException("Unable to store a new tuple, all memtable slots are full");
    }
    data[freePos] = value;
    bloomFilter.put(value.getKey());
    final SpatialIndexEntry indexEntry = new SpatialIndexEntry(value.getBoundingBox(), freePos);
    spatialIndex.insert(indexEntry);
    freePos++;
    sizeInMemory = sizeInMemory + value.getSize();
    if (oldestTupleTimestamp == -1) {
        oldestTupleTimestamp = value.getVersionTimestamp();
    } else {
        oldestTupleTimestamp = Math.min(oldestTupleTimestamp, value.getVersionTimestamp());
    }
    if (newestTupleTimestamp == -1) {
        newestTupleTimestamp = value.getVersionTimestamp();
    } else {
        newestTupleTimestamp = Math.max(newestTupleTimestamp, value.getVersionTimestamp());
    }
}
Also used : StorageManagerException(org.bboxdb.storage.StorageManagerException) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry)

Example 45 with StorageManagerException

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

the class DistributedRecoveryService method handleOutdatedRegions.

/**
 * Handle the outdated distribution regions
 * @param distributionGroupName
 * @param outdatedRegions
 */
protected void handleOutdatedRegions(final String distributionGroupName, final List<OutdatedDistributionRegion> outdatedRegions) {
    for (final OutdatedDistributionRegion outdatedDistributionRegion : outdatedRegions) {
        final BBoxDBConnection connection = MembershipConnectionService.getInstance().getConnectionForInstance(outdatedDistributionRegion.getNewestInstance());
        final long regionId = outdatedDistributionRegion.getDistributedRegion().getRegionId();
        final List<TupleStoreName> allTables = TupleStoreUtil.getAllTablesForDistributionGroupAndRegionId(storageRegistry, distributionGroupName, regionId);
        for (final TupleStoreName ssTableName : allTables) {
            try {
                runRecoveryForTable(ssTableName, outdatedDistributionRegion, connection.getBboxDBClient());
            } catch (RejectedException | StorageManagerException | ExecutionException e) {
                logger.error("Got an exception while performing recovery for table: " + ssTableName.getFullname());
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
                logger.error("Got an exception while performing recovery for table: " + ssTableName.getFullname());
            }
        }
    }
}
Also used : RejectedException(org.bboxdb.commons.RejectedException) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) BBoxDBConnection(org.bboxdb.network.client.BBoxDBConnection) StorageManagerException(org.bboxdb.storage.StorageManagerException) ExecutionException(java.util.concurrent.ExecutionException)

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