Search in sources :

Example 21 with TupleStoreName

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;
}
Also used : TupleStoreName(org.bboxdb.storage.entity.TupleStoreName)

Example 22 with TupleStoreName

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);
    }
}
Also used : TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Example 23 with TupleStoreName

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());
    }
}
Also used : TupleRedistributor(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.TupleRedistributor) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner)

Example 24 with TupleStoreName

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);
}
Also used : TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) BBoxDBException(org.bboxdb.misc.BBoxDBException) StorageManagerException(org.bboxdb.storage.StorageManagerException) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner)

Example 25 with TupleStoreName

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);
    });
}
Also used : NetworkOperationFuture(org.bboxdb.network.client.future.NetworkOperationFuture) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) InsertTupleRequest(org.bboxdb.network.packages.request.InsertTupleRequest)

Aggregations

TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)77 Test (org.junit.Test)25 Tuple (org.bboxdb.storage.entity.Tuple)18 StorageManagerException (org.bboxdb.storage.StorageManagerException)15 ArrayList (java.util.ArrayList)14 PackageEncodeException (org.bboxdb.network.packages.PackageEncodeException)14 SpacePartitioner (org.bboxdb.distribution.partitioner.SpacePartitioner)13 ByteBuffer (java.nio.ByteBuffer)12 BoundingBox (org.bboxdb.commons.math.BoundingBox)12 DistributionRegionIdMapper (org.bboxdb.distribution.region.DistributionRegionIdMapper)12 BBoxDBException (org.bboxdb.misc.BBoxDBException)12 InsertTupleRequest (org.bboxdb.network.packages.request.InsertTupleRequest)12 RoutingHeader (org.bboxdb.network.routing.RoutingHeader)12 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)12 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)11 List (java.util.List)10 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)10 TupleStoreManagerRegistry (org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry)10 ErrorResponse (org.bboxdb.network.packages.response.ErrorResponse)9 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)9