use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class TupleStoreUtil method getTuplesInDistributionGroupAndRegionId.
/**
* Get the amount of tuples in the distribution group and region id
* @param distributionGroupName
* @param regionId
* @return
* @throws StorageManagerException
*/
public static long getTuplesInDistributionGroupAndRegionId(final TupleStoreManagerRegistry registry, final String distributionGroupName, final long regionId) throws StorageManagerException {
final List<TupleStoreName> tables = getAllTablesForDistributionGroupAndRegionId(registry, distributionGroupName, regionId);
long tuples = 0;
for (TupleStoreName ssTableName : tables) {
tuples = tuples + registry.getTupleStoreManager(ssTableName).getNumberOfTuples();
}
return tuples;
}
use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class LocalSelftest method main.
public static void main(final String[] args) throws InterruptedException, ExecutionException, BBoxDBException, StorageManagerException, RejectedException {
if (args.length != 1) {
logger.error("Usage: LocalSelftest <Iterations>");
System.exit(-1);
}
try {
final int iterations = Integer.parseInt(args[0]);
logger.info("Running selftest......");
final TupleStoreManagerRegistry storageRegistry = new TupleStoreManagerRegistry();
storageRegistry.init();
final TupleStoreName sstable = new TupleStoreName(TABLENAME);
final TupleStoreManager storageManager = storageRegistry.getTupleStoreManager(sstable);
for (int iteration = 0; iteration < iterations; iteration++) {
logger.info("Running iteration {}", iteration);
storageRegistry.deleteTable(sstable, true);
testInsertDelete(storageManager);
}
storageRegistry.shutdown();
logger.info("Selftest done");
} catch (NumberFormatException e) {
logger.error("Unable to parse {} as a number, exiting", args[0]);
System.exit(-1);
}
}
use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class RegionMerger method redistributeDataMerge.
/**
* Redistribute the data in region merge
* @param source
* @param destination
* @throws Exception
*/
private void redistributeDataMerge(final List<DistributionRegion> source, final DistributionRegion destination) throws Exception {
logger.info("Redistributing all data for region (merge): " + destination.getIdentifier());
final String distributionGroupName = destination.getDistributionGroupName();
final List<TupleStoreName> localTables = TupleStoreUtil.getAllTablesForDistributionGroupAndRegionId(registry, distributionGroupName, destination.getRegionId());
// Add the local mapping, new data is written to the region
final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(distributionGroupName);
final DistributionRegionIdMapper mapper = spacePartitioner.getDistributionRegionIdMapper();
// We have set the region to active, wait until we see this status change
// from Zookeeper and the space partitioner add this region as active
mapper.waitUntilMappingAppears(destination.getRegionId());
// Redistribute data
for (final TupleStoreName tupleStoreName : localTables) {
logger.info("Merging data of tuple store {}", tupleStoreName);
startFlushToDisk(tupleStoreName);
final TupleRedistributor tupleRedistributor = new TupleRedistributor(registry, tupleStoreName);
tupleRedistributor.registerRegion(destination);
for (final DistributionRegion childRegion : source) {
mergeDataFromChildRegion(destination, tupleStoreName, tupleRedistributor, childRegion);
}
logger.info("Final statistics for merge ({}): {}", tupleStoreName, tupleRedistributor.getStatistics());
}
}
use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class RegionSplitter method redistributeDataSplit.
/**
* Redistribute data after region split
* @param region
*/
private void redistributeDataSplit(final DistributionRegion source, final List<DistributionRegion> destination) {
final long regionId = source.getRegionId();
try {
logger.info("Redistributing all data for region: {}", regionId);
final String distributionGroupName = source.getDistributionGroupName();
final List<TupleStoreName> localTables = TupleStoreUtil.getAllTablesForDistributionGroupAndRegionId(registry, distributionGroupName, regionId);
// Remove the local mapping, no new data is written to the region
final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(distributionGroupName);
final DistributionRegionIdMapper mapper = spacePartitioner.getDistributionRegionIdMapper();
// We have set the region to splitting, wait until we see this status change
// from Zookeeper and the space partitioner removed this region as active
mapper.waitUntilMappingDisappears(regionId);
// Redistribute data
for (final TupleStoreName ssTableName : localTables) {
// Reject new writes and flush to disk
stopFlushToDisk(ssTableName);
distributeData(ssTableName, source, destination);
}
} catch (InterruptedException e) {
logger.warn("Thread was interrupted");
Thread.currentThread().interrupt();
return;
} catch (Exception e) {
logger.error("Got exception when redistribute local data", e);
return;
}
logger.info("Redistributing data for region: {} DONE", regionId);
}
use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class BBoxDBClient method getInsertTupleFuture.
/**
* @param table
* @param tuple
* @param routingHeader
* @return
*/
public NetworkOperationFuture getInsertTupleFuture(final String table, final Tuple tuple, final RoutingHeader routingHeader) {
return new NetworkOperationFuture(connection, () -> {
final TupleStoreName ssTableName = new TupleStoreName(table);
final short sequenceNumber = connection.getNextSequenceNumber();
return new InsertTupleRequest(sequenceNumber, routingHeader, ssTableName, tuple);
});
}
Aggregations