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);
}
}
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);
}
}
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");
}
}
Aggregations