Search in sources :

Example 41 with TupleStoreConfiguration

use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.

the class InsertTupleHandler method createMissingTables.

/**
 * Create all missing tables
 */
protected void createMissingTables(final TupleStoreName requestTable, final TupleStoreManagerRegistry storageRegistry, final Collection<TupleStoreName> localTables) throws StorageManagerException {
    try {
        final TupleStoreAdapter tupleStoreAdapter = ZookeeperClientFactory.getZookeeperClient().getTupleStoreAdapter();
        if (!tupleStoreAdapter.isTableKnown(requestTable)) {
            throw new StorageManagerException("Table: " + requestTable.getFullname() + " is unkown");
        }
        final TupleStoreConfiguration config = tupleStoreAdapter.readTuplestoreConfiguration(requestTable);
        for (final TupleStoreName tupleStoreName : localTables) {
            final boolean alreadyKnown = storageRegistry.isStorageManagerKnown(tupleStoreName);
            if (!alreadyKnown) {
                storageRegistry.createTableIfNotExist(tupleStoreName, config);
            }
        }
    } catch (ZookeeperException e) {
        throw new StorageManagerException(e);
    }
}
Also used : ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleStoreAdapter(org.bboxdb.distribution.zookeeper.TupleStoreAdapter) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) StorageManagerException(org.bboxdb.storage.StorageManagerException)

Example 42 with TupleStoreConfiguration

use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.

the class DataRedistributionLoader method initBBoxDB.

/**
 * Re-Create the distribution group and the table
 */
private void initBBoxDB() {
    try {
        // Delete old distribution group
        System.out.println("Delete old distribution group");
        final EmptyResultFuture dgroupDeleteResult = bboxDBCluster.deleteDistributionGroup(DGROUP);
        dgroupDeleteResult.waitForAll();
        if (dgroupDeleteResult.isFailed()) {
            System.err.println(dgroupDeleteResult.getAllMessages());
            System.exit(-1);
        }
        // Create new distribution group
        System.out.println("Create new distribution group");
        final DistributionGroupConfiguration dgroupConfig = DistributionGroupConfigurationBuilder.create(2).withReplicationFactor((short) 1).withMaximumRegionSize(16).withMinimumRegionSize(4).build();
        final EmptyResultFuture dgroupCreateResult = bboxDBCluster.createDistributionGroup(DGROUP, dgroupConfig);
        dgroupCreateResult.waitForAll();
        if (dgroupCreateResult.isFailed()) {
            System.err.println(dgroupCreateResult.getAllMessages());
            System.exit(-1);
        }
        // Create new table
        System.out.println("Create new table");
        final TupleStoreConfiguration storeConfiguration = TupleStoreConfigurationBuilder.create().allowDuplicates(false).build();
        final EmptyResultFuture tableCreateResult = bboxDBCluster.createTable(TABLE, storeConfiguration);
        tableCreateResult.waitForAll();
        if (tableCreateResult.isFailed()) {
            System.err.println(tableCreateResult.getAllMessages());
            System.exit(-1);
        }
    } catch (Exception e) {
        System.err.println("Got an exception while prepating BBoxDB");
        e.printStackTrace();
        System.exit(-1);
    }
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) IOException(java.io.IOException) BBoxDBException(org.bboxdb.misc.BBoxDBException) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 43 with TupleStoreConfiguration

use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.

the class TupleStoreAdapter method readTuplestoreConfiguration.

/**
 * Read the tuple store name
 * @param tupleStoreName
 * @throws ZookeeperException
 */
public TupleStoreConfiguration readTuplestoreConfiguration(final TupleStoreName tupleStoreName) throws ZookeeperException {
    final TupleStoreConfiguration tupleStoreConfiguration = new TupleStoreConfiguration();
    try {
        final String spatialIndexReader = zookeeperClient.readPathAndReturnString(getIndexReaderPath(tupleStoreName));
        tupleStoreConfiguration.setSpatialIndexReader(spatialIndexReader);
        final String spatialIndexWriter = zookeeperClient.readPathAndReturnString(getIndexWriterPath(tupleStoreName));
        tupleStoreConfiguration.setSpatialIndexWriter(spatialIndexWriter);
        final String duplicatesAllowed = zookeeperClient.readPathAndReturnString(getDuplicatesAllowedPath(tupleStoreName));
        final boolean duplicatesAllowedBoolean = Boolean.parseBoolean(duplicatesAllowed);
        tupleStoreConfiguration.setAllowDuplicates(duplicatesAllowedBoolean);
        final String duplicatesTTL = zookeeperClient.readPathAndReturnString(getDuplicatesTTLPath(tupleStoreName));
        final Integer ttlInterger = Integer.parseInt(duplicatesTTL);
        tupleStoreConfiguration.setTtl(ttlInterger);
        final String duplicateVersions = zookeeperClient.readPathAndReturnString(getDuplicateVersionsPath(tupleStoreName));
        final Integer duplicateVersionsInteger = Integer.parseInt(duplicateVersions);
        tupleStoreConfiguration.setVersions(duplicateVersionsInteger);
    } catch (ZookeeperNotFoundException | NumberFormatException e) {
        throw new ZookeeperException(e);
    }
    return tupleStoreConfiguration;
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration)

Example 44 with TupleStoreConfiguration

use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.

the class TupleStoreConfigurationCache method getDuplicateResolverForTupleStore.

public synchronized DuplicateResolver<Tuple> getDuplicateResolverForTupleStore(final String tupleStorename) {
    if (!cache.containsKey(tupleStorename)) {
        try {
            final TupleStoreAdapter tupleStoreAdapter = ZookeeperClientFactory.getZookeeperClient().getTupleStoreAdapter();
            final TupleStoreName tupleStoreNameObject = new TupleStoreName(tupleStorename);
            if (!tupleStoreAdapter.isTableKnown(tupleStoreNameObject)) {
                logger.error("Table {} is not known, using do nothing duplicate resolver", tupleStorename);
                return new DoNothingDuplicateResolver();
            }
            final TupleStoreConfiguration tupleStoreConfiguration = tupleStoreAdapter.readTuplestoreConfiguration(tupleStoreNameObject);
            final DuplicateResolver<Tuple> resolver = TupleDuplicateResolverFactory.build(tupleStoreConfiguration);
            cache.put(tupleStorename, resolver);
        } catch (ZookeeperException e) {
            logger.error("Exception while reading zookeeper data", e);
            return new DoNothingDuplicateResolver();
        }
    }
    final DuplicateResolver<Tuple> duplicateResolver = cache.get(tupleStorename);
    return duplicateResolver;
}
Also used : ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleStoreAdapter(org.bboxdb.distribution.zookeeper.TupleStoreAdapter) DoNothingDuplicateResolver(org.bboxdb.storage.sstable.duplicateresolver.DoNothingDuplicateResolver) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) Tuple(org.bboxdb.storage.entity.Tuple)

Aggregations

TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)44 Test (org.junit.Test)23 Tuple (org.bboxdb.storage.entity.Tuple)21 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)15 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)13 BoundingBox (org.bboxdb.commons.math.BoundingBox)12 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)10 TupleStoreAdapter (org.bboxdb.distribution.zookeeper.TupleStoreAdapter)7 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)7 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)7 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)7 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)7 BBoxDBConnection (org.bboxdb.network.client.BBoxDBConnection)5 ArrayList (java.util.ArrayList)4 BBoxDBException (org.bboxdb.misc.BBoxDBException)4 BBoxDBClient (org.bboxdb.network.client.BBoxDBClient)4 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)3 DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)3 SSTableWriter (org.bboxdb.storage.sstable.SSTableWriter)3 SSTableCompactor (org.bboxdb.storage.sstable.compact.SSTableCompactor)3