Search in sources :

Example 36 with TupleStoreConfiguration

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

the class TestStorageManager method testVersionDuplicates.

/**
 * Test the storage manager with duplicates
 * @throws StorageManagerException
 * @throws RejectedException
 */
@Test(timeout = 60000)
public void testVersionDuplicates() throws StorageManagerException, RejectedException {
    // Delete the old table
    storageRegistry.deleteTable(TEST_RELATION, true);
    // Create a new table
    final TupleStoreConfiguration tupleStoreConfiguration = TupleStoreConfigurationBuilder.create().allowDuplicates(true).withVersions(3).build();
    storageRegistry.createTable(TEST_RELATION, tupleStoreConfiguration);
    // Assure table is created successfully
    storageManager = storageRegistry.getTupleStoreManager(TEST_RELATION);
    Assert.assertTrue(storageManager.getServiceState().isInRunningState());
    final Tuple tuple1 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc1".getBytes());
    storageManager.put(tuple1);
    final Tuple tuple2 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc2".getBytes());
    storageManager.put(tuple2);
    final Tuple tuple3 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc3".getBytes());
    storageManager.put(tuple3);
    final Tuple tuple4 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc4".getBytes());
    storageManager.put(tuple4);
    final Tuple tuple5 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc5".getBytes());
    storageManager.put(tuple5);
    final List<Tuple> readTuples = storageManager.get("abc");
    Assert.assertEquals(3, readTuples.size());
    Assert.assertTrue(readTuples.contains(tuple3));
    Assert.assertTrue(readTuples.contains(tuple4));
    Assert.assertTrue(readTuples.contains(tuple5));
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 37 with TupleStoreConfiguration

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

the class TestStorageRegistry method testDeleteTable.

/**
 * Test delete table
 * @throws StorageManagerException
 * @throws InterruptedException
 * @throws RejectedException
 */
@Test(timeout = 60000)
public void testDeleteTable() throws StorageManagerException, InterruptedException, RejectedException {
    storageRegistry.deleteTable(RELATION_NAME, true);
    Assert.assertFalse(storageRegistry.isStorageManagerActive(RELATION_NAME));
    storageRegistry.createTable(RELATION_NAME, new TupleStoreConfiguration());
    final TupleStoreManager storageManager = storageRegistry.getTupleStoreManager(RELATION_NAME);
    for (int i = 0; i < 50000; i++) {
        final Tuple createdTuple = new Tuple(Integer.toString(i), BoundingBox.FULL_SPACE, Integer.toString(i).getBytes());
        storageManager.put(createdTuple);
    }
    // Wait for requests to settle
    storageManager.flush();
    storageRegistry.deleteTable(RELATION_NAME, true);
    Assert.assertTrue(storageManager.isShutdownComplete());
    // Check the removal of the directory
    final BBoxDBConfiguration configuration = BBoxDBConfigurationManager.getConfiguration();
    final String storageDirectory = configuration.getStorageDirectories().get(0);
    final String pathname = SSTableHelper.getSSTableDir(storageDirectory, RELATION_NAME);
    final File directory = new File(pathname);
    System.out.println("Check for " + directory);
    Assert.assertFalse(directory.exists());
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) BBoxDBConfiguration(org.bboxdb.misc.BBoxDBConfiguration) File(java.io.File) Tuple(org.bboxdb.storage.entity.Tuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) Test(org.junit.Test)

Example 38 with TupleStoreConfiguration

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

the class TestTableCompactor method testCompactTestFileCreation.

@Test(timeout = 60000)
public void testCompactTestFileCreation() throws StorageManagerException {
    final List<Tuple> tupleList1 = new ArrayList<Tuple>();
    tupleList1.add(new Tuple("1", BoundingBox.FULL_SPACE, "abc".getBytes()));
    final SSTableKeyIndexReader reader1 = addTuplesToFileAndGetReader(tupleList1, 1);
    final List<Tuple> tupleList2 = new ArrayList<Tuple>();
    tupleList2.add(new Tuple("2", BoundingBox.FULL_SPACE, "def".getBytes()));
    final SSTableKeyIndexReader reader2 = addTuplesToFileAndGetReader(tupleList2, 2);
    storageRegistry.deleteTable(TEST_RELATION, true);
    storageRegistry.createTable(TEST_RELATION, new TupleStoreConfiguration());
    final TupleStoreManager storageManager = storageRegistry.getTupleStoreManager(TEST_RELATION);
    final SSTableCompactor compactor = new SSTableCompactor(storageManager, Arrays.asList(reader1, reader2));
    compactor.executeCompactation();
    final List<SSTableWriter> resultWriter = compactor.getResultList();
    Assert.assertEquals(1, resultWriter.size());
    Assert.assertEquals(2, compactor.getReadTuples());
    Assert.assertEquals(2, compactor.getWrittenTuples());
    for (final SSTableWriter writer : resultWriter) {
        Assert.assertTrue(writer.getSstableFile().exists());
        Assert.assertTrue(writer.getSstableIndexFile().exists());
        writer.close();
    }
}
Also used : SSTableKeyIndexReader(org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) SSTableWriter(org.bboxdb.storage.sstable.SSTableWriter) ArrayList(java.util.ArrayList) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) SSTableCompactor(org.bboxdb.storage.sstable.compact.SSTableCompactor) Test(org.junit.Test)

Example 39 with TupleStoreConfiguration

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

the class CLI method actionCreateTable.

/**
 * Create a new table
 * @param line
 */
protected void actionCreateTable(final CommandLine line) {
    if (!line.hasOption(CLIParameter.TABLE)) {
        System.err.println("Create table should be performed, but no table was specified");
        printHelpAndExit();
    }
    final TupleStoreConfigurationBuilder ssTableConfigurationBuilder = TupleStoreConfigurationBuilder.create();
    // Duplicates
    if (line.hasOption(CLIParameter.DUPLICATES)) {
        final String allowDuplicates = line.getOptionValue(CLIParameter.DUPLICATES);
        final boolean duplicatesAllowed = MathUtil.tryParseBooleanOrExit(allowDuplicates, () -> "Unable to parse the bolean value for duplicates: " + allowDuplicates);
        ssTableConfigurationBuilder.allowDuplicates(duplicatesAllowed);
    }
    // TTL
    if (line.hasOption(CLIParameter.TTL)) {
        final String ttlString = line.getOptionValue(CLIParameter.TTL);
        final int ttl = MathUtil.tryParseIntOrExit(ttlString, () -> "Unable to parse the region size: " + ttlString);
        ssTableConfigurationBuilder.withTTL(ttl, TimeUnit.MILLISECONDS);
    }
    // Versions
    if (line.hasOption(CLIParameter.VERSIONS)) {
        final String versionString = line.getOptionValue(CLIParameter.VERSIONS);
        final int versions = MathUtil.tryParseIntOrExit(versionString, () -> "Unable to parse the region size: " + versionString);
        ssTableConfigurationBuilder.withVersions(versions);
    }
    // Spatial index reader
    if (line.hasOption(CLIParameter.SPATIAL_INDEX_READER)) {
        final String spatialIndexReader = line.getOptionValue(CLIParameter.SPATIAL_INDEX_READER);
        ssTableConfigurationBuilder.withSpatialIndexReader(spatialIndexReader);
    }
    // Spatial index writer
    if (line.hasOption(CLIParameter.SPATIAL_INDEX_WRITER)) {
        final String spatialIndexWriter = line.getOptionValue(CLIParameter.SPATIAL_INDEX_WRITER);
        ssTableConfigurationBuilder.withSpatialIndexWriter(spatialIndexWriter);
    }
    final TupleStoreConfiguration configuration = ssTableConfigurationBuilder.build();
    try {
        final String table = line.getOptionValue(CLIParameter.TABLE);
        final EmptyResultFuture resultFuture = bboxDbConnection.createTable(table, configuration);
        resultFuture.waitForAll();
        if (resultFuture.isFailed()) {
            System.err.println("Unable to create table: " + resultFuture.getAllMessages());
            System.exit(-1);
        }
    } catch (BBoxDBException e) {
        System.err.println("Got an exception while creating table: " + e);
        System.exit(-1);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        return;
    }
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleStoreConfigurationBuilder(org.bboxdb.storage.entity.TupleStoreConfigurationBuilder) BBoxDBException(org.bboxdb.misc.BBoxDBException) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 40 with TupleStoreConfiguration

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

the class TestTuplestoreConfiguration method testWriteAndReadConfiguration.

@Test(timeout = 60000)
public void testWriteAndReadConfiguration() {
    final TupleStoreConfiguration configuration1 = new TupleStoreConfiguration();
    final String yamlString = configuration1.exportToYaml();
    final TupleStoreConfiguration configuration2 = TupleStoreConfiguration.importFromYaml(yamlString);
    Assert.assertEquals(configuration1, configuration2);
    Assert.assertEquals(configuration1.hashCode(), configuration2.hashCode());
    Assert.assertTrue(configuration1.toString().length() > 10);
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) Test(org.junit.Test)

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