Search in sources :

Example 46 with StorageManagerException

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

the class RegionMerger method mergeDataByLocalRead.

/**
 * Merge data by local data read
 *
 * @param region
 * @param tupleStoreName
 * @param tupleRedistributor
 * @param childRegion
 * @throws StorageManagerException
 * @throws TupleStoreManagerRegistry
 */
private void mergeDataByLocalRead(final DistributionRegion region, final TupleStoreName tupleStoreName, final TupleRedistributor tupleRedistributor, final DistributionRegion childRegion) throws StorageManagerException {
    final long regionId = region.getRegionId();
    final TupleStoreName childRegionName = tupleStoreName.cloneWithDifferntRegionId(regionId);
    final TupleStoreManager tupleStoreManager = registry.getTupleStoreManager(childRegionName);
    final List<ReadOnlyTupleStore> storages = new ArrayList<>();
    try {
        storages.addAll(tupleStoreManager.aquireStorage());
        for (final ReadOnlyTupleStore storage : storages) {
            for (final Tuple tuple : storage) {
                tupleRedistributor.redistributeTuple(tuple);
            }
        }
    } catch (Exception e) {
        throw e;
    } finally {
        tupleStoreManager.releaseStorage(storages);
    }
}
Also used : ArrayList(java.util.ArrayList) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) ReadOnlyTupleStore(org.bboxdb.storage.tuplestore.ReadOnlyTupleStore) Tuple(org.bboxdb.storage.entity.Tuple) StorageManagerException(org.bboxdb.storage.StorageManagerException) BBoxDBException(org.bboxdb.misc.BBoxDBException) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Example 47 with StorageManagerException

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

the class RegionMerger method mergeDataByNetworkRead.

/**
 * Merge the region by a network read
 *
 * @param region
 * @param tupleStoreName
 * @param tupleRedistributor
 * @param childRegion
 * @throws InterruptedException
 * @throws StorageManagerException
 * @throws Exception
 */
private void mergeDataByNetworkRead(final DistributionRegion region, final TupleStoreName tupleStoreName, final TupleRedistributor tupleRedistributor, final DistributionRegion childRegion) throws InterruptedException, StorageManagerException {
    final List<BBoxDBInstance> systems = childRegion.getSystems();
    assert (!systems.isEmpty()) : "Systems can not be empty";
    final BBoxDBInstance firstSystem = systems.get(0);
    final BBoxDBConnection connection = MembershipConnectionService.getInstance().getConnectionForInstance(firstSystem);
    assert (connection != null) : "Connection can not be null: " + firstSystem.getStringValue();
    final BoundingBox bbox = childRegion.getConveringBox();
    final String fullname = tupleStoreName.getFullname();
    final BBoxDBClient bboxDBClient = connection.getBboxDBClient();
    final TupleListFuture result = bboxDBClient.queryBoundingBox(fullname, bbox);
    result.waitForAll();
    if (result.isFailed()) {
        throw new StorageManagerException("Exception while fetching tuples: " + result.getAllMessages());
    }
    for (final Tuple tuple : result) {
        tupleRedistributor.redistributeTuple(tuple);
    }
}
Also used : BBoxDBClient(org.bboxdb.network.client.BBoxDBClient) BoundingBox(org.bboxdb.commons.math.BoundingBox) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) BBoxDBConnection(org.bboxdb.network.client.BBoxDBConnection) StorageManagerException(org.bboxdb.storage.StorageManagerException) Tuple(org.bboxdb.storage.entity.Tuple)

Example 48 with StorageManagerException

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

the class TupleRedistributor method redistributeTuple.

/**
 * Redistribute a new tuple
 * @param tuple
 * @throws Exception
 */
public void redistributeTuple(final Tuple tuple) throws StorageManagerException {
    boolean tupleRedistributed = false;
    redistributedTuples++;
    for (final DistributionRegion region : regionMap.keySet()) {
        if (belongsTupleToRegion(tuple, region)) {
            for (final AbstractTupleSink tupleSink : regionMap.get(region)) {
                tupleSink.sinkTuple(tuple);
                tupleRedistributed = true;
            }
        }
    }
    if (tupleRedistributed == false) {
        throw new StorageManagerException("Tuple " + tuple + " was not redistributed");
    }
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) 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