Search in sources :

Example 11 with TupleStoreManager

use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager 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 12 with TupleStoreManager

use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.

the class RegionMerger method startFlushToDisk.

/**
 * Start the to disk flushing
 * @param ssTableName
 * @throws StorageManagerException
 */
private void startFlushToDisk(final TupleStoreName ssTableName) throws StorageManagerException {
    final TupleStoreManager ssTableManager = registry.getTupleStoreManager(ssTableName);
    ssTableManager.init();
    ssTableManager.setToReadWrite();
}
Also used : TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Example 13 with TupleStoreManager

use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.

the class RegionSplitter method distributeData.

/**
 * Redistribute the given sstable
 * @param ssTableName
 * @param source
 * @param destination
 * @throws StorageManagerException
 */
private void distributeData(final TupleStoreName ssTableName, final DistributionRegion source, final List<DistributionRegion> destination) throws BBoxDBException, StorageManagerException {
    logger.info("Redistributing table {}", ssTableName.getFullname());
    final TupleStoreManager ssTableManager = registry.getTupleStoreManager(ssTableName);
    // Spread data
    final TupleRedistributor tupleRedistributor = getTupleRedistributor(source, destination, ssTableName);
    spreadTupleStores(ssTableManager, tupleRedistributor);
    logger.info("Redistributing table {} is DONE", ssTableName.getFullname());
}
Also used : TupleRedistributor(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.TupleRedistributor) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Example 14 with TupleStoreManager

use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.

the class TupleRedistributor method registerRegion.

/**
 * Register a new region for distribution
 * @param distributionRegion
 * @throws StorageManagerException
 * @throws ZookeeperException
 */
public void registerRegion(final DistributionRegion distributionRegion) throws StorageManagerException {
    final ArrayList<AbstractTupleSink> sinks = new ArrayList<>();
    final Collection<BBoxDBInstance> instances = distributionRegion.getSystems();
    final MembershipConnectionService membershipConnectionService = MembershipConnectionService.getInstance();
    final BBoxDBInstance localInstance = ZookeeperClientFactory.getLocalInstanceName();
    for (final BBoxDBInstance instance : instances) {
        if (instance.socketAddressEquals(localInstance)) {
            final TupleStoreName localTableName = tupleStoreName.cloneWithDifferntRegionId(distributionRegion.getRegionId());
            final TupleStoreAdapter tupleStoreAdapter = ZookeeperClientFactory.getZookeeperClient().getTupleStoreAdapter();
            final TupleStoreConfiguration config = readTuplestoreConfig(localTableName, tupleStoreAdapter);
            final TupleStoreManager storageManager = tupleStoreManagerRegistry.createTableIfNotExist(localTableName, config);
            final LocalTupleSink tupleSink = new LocalTupleSink(tupleStoreName, storageManager);
            sinks.add(tupleSink);
            logger.info("Redistributing data to local table {}", localTableName.getFullname());
        } else {
            final BBoxDBConnection connection = membershipConnectionService.getConnectionForInstance(instance);
            final NetworkTupleSink tupleSink = new NetworkTupleSink(tupleStoreName, connection);
            sinks.add(tupleSink);
            logger.info("Redistributing data to remote system {}", instance.getInetSocketAddress());
        }
    }
    registerRegion(distributionRegion, sinks);
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) ArrayList(java.util.ArrayList) MembershipConnectionService(org.bboxdb.distribution.membership.MembershipConnectionService) TupleStoreAdapter(org.bboxdb.distribution.zookeeper.TupleStoreAdapter) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) BBoxDBConnection(org.bboxdb.network.client.BBoxDBConnection) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Example 15 with TupleStoreManager

use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.

the class SSTableServiceRunnable method processTupleStores.

/**
 * Process the tuple stores
 *
 * @param storageRegistry
 * @param tupleStores
 * @throws InterruptedException
 */
private void processTupleStores(final TupleStoreManagerRegistry storageRegistry, final List<TupleStoreName> tupleStores) throws InterruptedException {
    for (final TupleStoreName tupleStoreName : tupleStores) {
        try {
            logger.debug("Running compact for: {}", tupleStoreName);
            final TupleStoreManager tupleStoreManager = storageRegistry.getTupleStoreManager(tupleStoreName);
            if (tupleStoreManager.getSstableManagerState() == TupleStoreManagerState.READ_ONLY) {
                logger.debug("Skipping compact for read only sstable manager: {}", tupleStoreName);
                continue;
            }
            if (!CompactorHelper.isRegionActive(tupleStoreName)) {
                logger.info("Skipping compact run, because region is not active {}", tupleStoreName);
                continue;
            }
            final List<SSTableFacade> facades = getAllTupleStores(tupleStoreManager);
            final MergeTask mergeTask = mergeStrategy.getMergeTask(facades);
            executeCompactTask(mergeTask, tupleStoreManager);
            testForRegionOverflow(tupleStoreManager);
        } catch (StorageManagerException | BBoxDBException e) {
            logger.error("Error while merging tables", e);
        }
    }
}
Also used : SSTableFacade(org.bboxdb.storage.sstable.reader.SSTableFacade) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) StorageManagerException(org.bboxdb.storage.StorageManagerException) BBoxDBException(org.bboxdb.misc.BBoxDBException) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Aggregations

TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)32 Tuple (org.bboxdb.storage.entity.Tuple)17 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)17 Test (org.junit.Test)12 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)11 BoundingBox (org.bboxdb.commons.math.BoundingBox)10 BBoxDBException (org.bboxdb.misc.BBoxDBException)10 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)10 TupleStoreManagerRegistry (org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry)9 StorageManagerException (org.bboxdb.storage.StorageManagerException)8 IndexedSpatialJoinOperator (org.bboxdb.storage.queryprocessor.operator.IndexedSpatialJoinOperator)8 SpatialIndexReadOperator (org.bboxdb.storage.queryprocessor.operator.SpatialIndexReadOperator)8 ArrayList (java.util.ArrayList)7 List (java.util.List)6 RejectedException (org.bboxdb.commons.RejectedException)6 Lists (com.google.common.collect.Lists)5 Iterator (java.util.Iterator)5 Collectors (java.util.stream.Collectors)5 AfterClass (org.junit.AfterClass)5 IOException (java.io.IOException)4