Search in sources :

Example 51 with TupleStoreName

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

the class TestTupleStoreAdapter method testTupleStoreConfig2.

/**
 * Test configuration 2
 * @throws ZookeeperException
 */
@Test(timeout = 60000)
public void testTupleStoreConfig2() throws ZookeeperException {
    final TupleStoreConfiguration tupleStoreConfiguration = TupleStoreConfigurationBuilder.create().allowDuplicates(true).withTTL(10000, TimeUnit.MILLISECONDS).withVersions(100).build();
    final TupleStoreName tupleStoreName = new TupleStoreName("dg_table1");
    tupleStoreAdapter.deleteTable(tupleStoreName);
    Assert.assertFalse(tupleStoreAdapter.isTableKnown(tupleStoreName));
    tupleStoreAdapter.writeTuplestoreConfiguration(tupleStoreName, tupleStoreConfiguration);
    final TupleStoreConfiguration readConfig = tupleStoreAdapter.readTuplestoreConfiguration(tupleStoreName);
    Assert.assertEquals(tupleStoreConfiguration, readConfig);
    Assert.assertTrue(tupleStoreAdapter.isTableKnown(tupleStoreName));
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) Test(org.junit.Test)

Example 52 with TupleStoreName

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

the class TestTablenameParser method testTablenameParserInvalid.

/**
 * Test the parsing of invalid tablenames
 */
@Test(timeout = 60000)
public void testTablenameParserInvalid() {
    final List<String> invalidNames = new ArrayList<>();
    invalidNames.add("");
    invalidNames.add(null);
    invalidNames.add("abc");
    invalidNames.add("abcd_abcd_abce");
    invalidNames.add("__");
    invalidNames.add("3__");
    invalidNames.add("3_abc_");
    invalidNames.add("3_abc_def_gef");
    invalidNames.add("__def");
    invalidNames.add("abc__def");
    invalidNames.add("-0_df_def");
    invalidNames.add("1-0_df_def");
    invalidNames.add("-1_df_def");
    invalidNames.add("0_df_def");
    invalidNames.add("0_df_def_");
    invalidNames.add("0_df_def_a");
    invalidNames.add("0_df_def__");
    invalidNames.add("_____");
    invalidNames.add("1_2_");
    for (final String invalidTablename : invalidNames) {
        final TupleStoreName tablename = new TupleStoreName(invalidTablename);
        Assert.assertFalse(tablename.isValid());
        Assert.assertEquals(TupleStoreName.INVALID_GROUP, tablename.getDistributionGroup());
        Assert.assertEquals(TupleStoreName.INVALID_TABLENAME, tablename.getTablename());
    }
}
Also used : ArrayList(java.util.ArrayList) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) Test(org.junit.Test)

Example 53 with TupleStoreName

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

the class TestTablenameParser method testTablenameParserValid.

/**
 * Test the parsing of valid tablenames
 */
@Test(timeout = 60000)
public void testTablenameParserValid() {
    final List<String> validNames = new ArrayList<String>();
    validNames.add("abc_def");
    validNames.add("34_34");
    validNames.add("def_34");
    validNames.add("def_table21");
    validNames.add("12def_table21");
    validNames.add("12def_table21_1");
    validNames.add("12def_table21_4711");
    for (final String validTablename : validNames) {
        final TupleStoreName tablename = new TupleStoreName(validTablename);
        Assert.assertTrue(tablename.isValid());
        Assert.assertNotNull(tablename.getDistributionGroup());
        Assert.assertNotNull(tablename.getTablename());
    }
}
Also used : ArrayList(java.util.ArrayList) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) Test(org.junit.Test)

Example 54 with TupleStoreName

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

the class SSTableExaminer method main.

/**
 * Main * Main * Main
 *
 * Examine a given SSTable and the coresponding index. The tuple with the key=examineKey
 * will be search with fulltable scans and index scans. The result of this operations
 * is printed onto the console.
 *
 * @param args
 */
public static void main(final String[] args) {
    if (args.length != 4) {
        logger.error("Usage: SSTableExaminer <Base directory> <Tablename> <Tablenumber> <Key>");
        System.exit(-1);
    }
    final String baseDirectory = args[0];
    final TupleStoreName relationname = new TupleStoreName(args[1]);
    if (!relationname.isValid()) {
        logger.error("Relationname {} is invalid, exiting", args[0]);
        System.exit(-1);
    }
    try {
        final int tableNumber = Integer.parseInt(args[2]);
        final String examineKey = args[3];
        final SSTableExaminer dumper = new SSTableExaminer(baseDirectory, relationname, tableNumber, examineKey);
        dumper.run();
    } catch (NumberFormatException e) {
        logger.error("Unable to parse {} as tablenumber", args[2]);
        System.exit(-1);
    }
}
Also used : TupleStoreName(org.bboxdb.storage.entity.TupleStoreName)

Example 55 with TupleStoreName

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

the class TupleStoreManagerRegistry method shutdownAndDeleteTablesForPredicate.

/**
 * Shutdown and delete data for the given predicate
 * @param deleteTablePredicate
 * @throws StorageManagerException
 */
private void shutdownAndDeleteTablesForPredicate(final Predicate<TupleStoreName> deleteTablePredicate, final boolean synchronous) throws StorageManagerException {
    // Create a copy of the key set to allow deletions (performed by shutdown) during iteration
    final Set<TupleStoreName> copyOfInstances = new HashSet<>(managerInstances.keySet());
    for (final TupleStoreName tupleStoreName : copyOfInstances) {
        if (deleteTablePredicate.test(tupleStoreName)) {
            shutdownSStable(tupleStoreName);
        }
    }
    // Storage on disk
    final List<TupleStoreName> allTables = getAllTables();
    for (final TupleStoreName tupleStoreName : allTables) {
        if (deleteTablePredicate.test(tupleStoreName)) {
            deleteTable(tupleStoreName, synchronous);
        }
    }
}
Also used : TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) HashSet(java.util.HashSet)

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