Search in sources :

Example 1 with Configuration

use of com.thinkaurelius.titan.diskstorage.configuration.Configuration in project titan by thinkaurelius.

the class BerkeleyJEStoreManager method beginTransaction.

@Override
public BerkeleyJETx beginTransaction(final BaseTransactionConfig txCfg) throws BackendException {
    try {
        Transaction tx = null;
        Configuration effectiveCfg = new MergedConfiguration(txCfg.getCustomOptions(), getStorageConfig());
        if (transactional) {
            TransactionConfig txnConfig = new TransactionConfig();
            ConfigOption.getEnumValue(effectiveCfg.get(ISOLATION_LEVEL), IsolationLevel.class).configure(txnConfig);
            tx = environment.beginTransaction(null, txnConfig);
        }
        BerkeleyJETx btx = new BerkeleyJETx(tx, ConfigOption.getEnumValue(effectiveCfg.get(LOCK_MODE), LockMode.class), txCfg);
        if (log.isTraceEnabled()) {
            log.trace("Berkeley tx created", new TransactionBegin(btx.toString()));
        }
        return btx;
    } catch (DatabaseException e) {
        throw new PermanentBackendException("Could not start BerkeleyJE transaction", e);
    }
}
Also used : MergedConfiguration(com.thinkaurelius.titan.diskstorage.configuration.MergedConfiguration) StoreTransaction(com.thinkaurelius.titan.diskstorage.keycolumnvalue.StoreTransaction) Configuration(com.thinkaurelius.titan.diskstorage.configuration.Configuration) MergedConfiguration(com.thinkaurelius.titan.diskstorage.configuration.MergedConfiguration) GraphDatabaseConfiguration(com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration) PermanentBackendException(com.thinkaurelius.titan.diskstorage.PermanentBackendException)

Example 2 with Configuration

use of com.thinkaurelius.titan.diskstorage.configuration.Configuration in project titan by thinkaurelius.

the class AbstractCassandraStoreManager method getFeatures.

@Override
public StoreFeatures getFeatures() {
    if (features == null) {
        Configuration global = GraphDatabaseConfiguration.buildGraphConfiguration().set(CASSANDRA_READ_CONSISTENCY, "QUORUM").set(CASSANDRA_WRITE_CONSISTENCY, "QUORUM").set(METRICS_PREFIX, GraphDatabaseConfiguration.METRICS_SYSTEM_PREFIX_DEFAULT);
        Configuration local = GraphDatabaseConfiguration.buildGraphConfiguration().set(CASSANDRA_READ_CONSISTENCY, "LOCAL_QUORUM").set(CASSANDRA_WRITE_CONSISTENCY, "LOCAL_QUORUM").set(METRICS_PREFIX, GraphDatabaseConfiguration.METRICS_SYSTEM_PREFIX_DEFAULT);
        StandardStoreFeatures.Builder fb = new StandardStoreFeatures.Builder();
        fb.batchMutation(true).distributed(true);
        fb.timestamps(true).cellTTL(true);
        fb.keyConsistent(global, local);
        boolean keyOrdered;
        switch(getPartitioner()) {
            case RANDOM:
                keyOrdered = false;
                fb.keyOrdered(keyOrdered).orderedScan(false).unorderedScan(true);
                break;
            case BYTEORDER:
                keyOrdered = true;
                fb.keyOrdered(keyOrdered).orderedScan(true).unorderedScan(false);
                break;
            default:
                throw new IllegalArgumentException("Unrecognized partitioner: " + getPartitioner());
        }
        switch(getDeployment()) {
            case REMOTE:
                fb.multiQuery(true);
                break;
            case LOCAL:
                fb.multiQuery(true).localKeyPartition(keyOrdered);
                break;
            case EMBEDDED:
                fb.multiQuery(false).localKeyPartition(keyOrdered);
                break;
            default:
                throw new IllegalArgumentException("Unrecognized deployment mode: " + getDeployment());
        }
        features = fb.build();
    }
    return features;
}
Also used : StandardStoreFeatures(com.thinkaurelius.titan.diskstorage.keycolumnvalue.StandardStoreFeatures) Configuration(com.thinkaurelius.titan.diskstorage.configuration.Configuration) GraphDatabaseConfiguration(com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration)

Example 3 with Configuration

use of com.thinkaurelius.titan.diskstorage.configuration.Configuration in project titan by thinkaurelius.

the class RidGenerationTest method testThreadBasedRidGeneration.

@Test
public void testThreadBasedRidGeneration() throws InterruptedException {
    Configuration c = Configuration.EMPTY;
    int n = 8;
    // n <= 1 is useless
    Preconditions.checkArgument(1 < n);
    Collection<byte[]> rids = Collections.synchronizedSet(new HashSet<byte[]>());
    RidThread[] threads = new RidThread[n];
    for (int i = 0; i < n; i++) {
        threads[i] = new RidThread(rids, c);
    }
    for (int i = 0; i < n; i++) {
        threads[i].start();
    }
    for (int i = 0; i < n; i++) {
        threads[i].join();
    }
//TODO: rewrite test case in terms of GraphDatabaseConfiguration
//assertEquals(n, rids.size());
}
Also used : Configuration(com.thinkaurelius.titan.diskstorage.configuration.Configuration) BaseConfiguration(org.apache.commons.configuration.BaseConfiguration) Test(org.junit.Test)

Example 4 with Configuration

use of com.thinkaurelius.titan.diskstorage.configuration.Configuration in project titan by thinkaurelius.

the class HBaseStoreManager method getFeatures.

@Override
public StoreFeatures getFeatures() {
    Configuration c = GraphDatabaseConfiguration.buildGraphConfiguration();
    StandardStoreFeatures.Builder fb = new StandardStoreFeatures.Builder().orderedScan(true).unorderedScan(true).batchMutation(true).multiQuery(true).distributed(true).keyOrdered(true).storeTTL(true).timestamps(true).preferredTimestamps(PREFERRED_TIMESTAMPS).keyConsistent(c);
    try {
        fb.localKeyPartition(getDeployment() == Deployment.LOCAL);
    } catch (Exception e) {
        logger.warn("Unexpected exception during getDeployment()", e);
    }
    return fb.build();
}
Also used : StandardStoreFeatures(com.thinkaurelius.titan.diskstorage.keycolumnvalue.StandardStoreFeatures) Configuration(com.thinkaurelius.titan.diskstorage.configuration.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) GraphDatabaseConfiguration(com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration) TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException) TemporaryBackendException(com.thinkaurelius.titan.diskstorage.TemporaryBackendException) PermanentBackendException(com.thinkaurelius.titan.diskstorage.PermanentBackendException) BackendException(com.thinkaurelius.titan.diskstorage.BackendException) MasterNotRunningException(org.apache.hadoop.hbase.MasterNotRunningException) TableNotEnabledException(org.apache.hadoop.hbase.TableNotEnabledException) TitanException(com.thinkaurelius.titan.core.TitanException) ZooKeeperConnectionException(org.apache.hadoop.hbase.ZooKeeperConnectionException) IOException(java.io.IOException)

Example 5 with Configuration

use of com.thinkaurelius.titan.diskstorage.configuration.Configuration in project titan by thinkaurelius.

the class ElasticSearchConfigTest method testLocalNodeUsingYaml.

@Test
public void testLocalNodeUsingYaml() throws BackendException, InterruptedException {
    String baseDir = Joiner.on(File.separator).join("target", "es", "jvmlocal_yml");
    assertFalse(new File(baseDir + File.separator + "data").exists());
    ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration();
    config.set(INTERFACE, ElasticSearchSetup.NODE.toString(), INDEX_NAME);
    config.set(INDEX_CONF_FILE, Joiner.on(File.separator).join("target", "test-classes", "es_jvmlocal.yml"), INDEX_NAME);
    Configuration indexConfig = config.restrictTo(INDEX_NAME);
    IndexProvider idx = new ElasticSearchIndex(indexConfig);
    simpleWriteAndQuery(idx);
    idx.close();
    assertTrue(new File(baseDir + File.separator + "data").exists());
}
Also used : Configuration(com.thinkaurelius.titan.diskstorage.configuration.Configuration) CommonsConfiguration(com.thinkaurelius.titan.diskstorage.configuration.backend.CommonsConfiguration) BasicConfiguration(com.thinkaurelius.titan.diskstorage.configuration.BasicConfiguration) GraphDatabaseConfiguration(com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration) BaseConfiguration(org.apache.commons.configuration.BaseConfiguration) ModifiableConfiguration(com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration) ModifiableConfiguration(com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration) ElasticSearchIndex(com.thinkaurelius.titan.diskstorage.es.ElasticSearchIndex) File(java.io.File) Test(org.junit.Test)

Aggregations

Configuration (com.thinkaurelius.titan.diskstorage.configuration.Configuration)18 GraphDatabaseConfiguration (com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration)15 ModifiableConfiguration (com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration)10 Test (org.junit.Test)10 ElasticSearchIndex (com.thinkaurelius.titan.diskstorage.es.ElasticSearchIndex)9 BaseConfiguration (org.apache.commons.configuration.BaseConfiguration)8 BasicConfiguration (com.thinkaurelius.titan.diskstorage.configuration.BasicConfiguration)7 CommonsConfiguration (com.thinkaurelius.titan.diskstorage.configuration.backend.CommonsConfiguration)7 PermanentBackendException (com.thinkaurelius.titan.diskstorage.PermanentBackendException)4 StandardStoreFeatures (com.thinkaurelius.titan.diskstorage.keycolumnvalue.StandardStoreFeatures)4 TitanException (com.thinkaurelius.titan.core.TitanException)3 BackendException (com.thinkaurelius.titan.diskstorage.BackendException)3 TemporaryBackendException (com.thinkaurelius.titan.diskstorage.TemporaryBackendException)3 File (java.io.File)3 IOException (java.io.IOException)3 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)3 MasterNotRunningException (org.apache.hadoop.hbase.MasterNotRunningException)3 TableNotEnabledException (org.apache.hadoop.hbase.TableNotEnabledException)3 TableNotFoundException (org.apache.hadoop.hbase.TableNotFoundException)3 ZooKeeperConnectionException (org.apache.hadoop.hbase.ZooKeeperConnectionException)3