Search in sources :

Example 16 with WriteConfiguration

use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.

the class JanusGraphOperationCountingTest method getConfiguration.

@Override
public WriteConfiguration getConfiguration() {
    WriteConfiguration config = getBaseConfiguration();
    ModifiableConfiguration modifiableConfiguration = new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS, config, BasicConfiguration.Restriction.NONE);
    modifiableConfiguration.set(BASIC_METRICS, true);
    modifiableConfiguration.set(METRICS_MERGE_STORES, false);
    modifiableConfiguration.set(PROPERTY_PREFETCHING, false);
    modifiableConfiguration.set(DB_CACHE, false);
    return config;
}
Also used : ModifiableConfiguration(org.janusgraph.diskstorage.configuration.ModifiableConfiguration) WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration)

Example 17 with WriteConfiguration

use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.

the class CQLScanJobIT method testPartitionedVertexFilteredScan.

@Test
public void testPartitionedVertexFilteredScan() throws Exception {
    tearDown();
    clearGraph(getConfiguration());
    WriteConfiguration partConf = getConfiguration();
    open(partConf);
    mgmt.makeVertexLabel("part").partition().make();
    finishSchema();
    JanusGraphVertex supernode = graph.addVertex("part");
    for (int i = 0; i < 128; i++) {
        JanusGraphVertex v = graph.addVertex("part");
        v.addEdge("default", supernode);
        if (0 < i && 0 == i % 4)
            graph.tx().commit();
    }
    graph.tx().commit();
    org.apache.hadoop.conf.Configuration c = new org.apache.hadoop.conf.Configuration();
    c.set(ConfigElement.getPath(JanusGraphHadoopConfiguration.GRAPH_CONFIG_KEYS, true) + "." + "storage.cql.keyspace", getClass().getSimpleName().toLowerCase());
    c.set(ConfigElement.getPath(JanusGraphHadoopConfiguration.GRAPH_CONFIG_KEYS, true) + "." + "storage.backend", "cql");
    c.set(ConfigElement.getPath(JanusGraphHadoopConfiguration.GRAPH_CONFIG_KEYS, true) + "." + "storage.port", String.valueOf(cql.getMappedCQLPort()));
    c.set(ConfigElement.getPath(JanusGraphHadoopConfiguration.FILTER_PARTITIONED_VERTICES, true), "true");
    c.set("cassandra.input.partitioner.class", "org.apache.cassandra.dht.Murmur3Partitioner");
    Job job = getVertexJobWithDefaultMapper(c);
    // Should succeed
    assertTrue(job.waitForCompletion(true));
}
Also used : WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) JanusGraphHadoopConfiguration(org.janusgraph.hadoop.config.JanusGraphHadoopConfiguration) Configuration(org.janusgraph.diskstorage.configuration.Configuration) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) JanusGraphVertex(org.janusgraph.core.JanusGraphVertex) WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) SimpleScanJob(org.janusgraph.diskstorage.SimpleScanJob) Job(org.apache.hadoop.mapreduce.Job) ScanJob(org.janusgraph.diskstorage.keycolumnvalue.scan.ScanJob) Test(org.junit.jupiter.api.Test) JanusGraphBaseTest(org.janusgraph.graphdb.JanusGraphBaseTest)

Example 18 with WriteConfiguration

use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.

the class HBaseStoreManagerConfigTest method testShortCfNames.

@Test
public void testShortCfNames() throws Exception {
    org.apache.logging.log4j.core.Logger log = (org.apache.logging.log4j.core.Logger) LogManager.getLogger(HBaseStoreManager.class);
    StringWriter writer = new StringWriter();
    Appender appender = WriterAppender.createAppender(PatternLayout.newBuilder().withPattern("%p: %m%n").build(), LevelMatchFilter.newBuilder().setLevel(Level.WARN).build(), writer, "test", false, false);
    appender.start();
    log.addAppender(appender);
    // Open the HBaseStoreManager and store with default SHORT_CF_NAMES true.
    WriteConfiguration config = hBaseContainer.getWriteConfiguration();
    HBaseStoreManager manager = new HBaseStoreManager(new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, config, BasicConfiguration.Restriction.NONE));
    KeyColumnValueStore store = manager.openDatabase(GraphDatabaseConfiguration.SYSTEM_PROPERTIES_STORE_NAME);
    store.close();
    manager.close();
    // Open the HBaseStoreManager and store with SHORT_CF_NAMES false.
    config.set(ConfigElement.getPath(HBaseStoreManager.SHORT_CF_NAMES), false);
    manager = new HBaseStoreManager(new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, config, BasicConfiguration.Restriction.NONE));
    writer.getBuffer().setLength(0);
    store = manager.openDatabase(GraphDatabaseConfiguration.SYSTEM_PROPERTIES_STORE_NAME);
    // Verify we get WARN.
    assertTrue(writer.toString().startsWith("WARN: Configuration"), writer.toString());
    log.removeAppender(appender);
    store.close();
    manager.close();
}
Also used : WriterAppender(org.apache.logging.log4j.core.appender.WriterAppender) Appender(org.apache.logging.log4j.core.Appender) KeyColumnValueStore(org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStore) StringWriter(java.io.StringWriter) WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) BasicConfiguration(org.janusgraph.diskstorage.configuration.BasicConfiguration) Test(org.junit.jupiter.api.Test)

Example 19 with WriteConfiguration

use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.

the class JanusGraphTest method testManagedOptionMasking.

@Test
public void testManagedOptionMasking() throws BackendException {
    // Can't use clopen(...) for this test, because it's aware local vs global option types and
    // uses ManagementSystem where necessary.  We want to simulate an erroneous attempt to
    // override global options by tweaking the local config file (ignoring ManagementSystem),
    // so we have to bypass clopen(...).
    // clopen(
    // option(ALLOW_STALE_CONFIG), false,
    // option(ATTRIBUTE_ALLOW_ALL_SERIALIZABLE), false);
    // Check this test's assumptions about option default values
    Duration customCommitTime = Duration.ofMillis(456L);
    Preconditions.checkState(ALLOW_STALE_CONFIG.getDefaultValue());
    Preconditions.checkState(ALLOW_STALE_CONFIG.getType().equals(ConfigOption.Type.MASKABLE));
    Preconditions.checkState(!customCommitTime.equals(MAX_COMMIT_TIME.getDefaultValue()));
    // Disallow managed option masking and verify exception at graph startup
    close();
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(ALLOW_STALE_CONFIG), false);
    wc.set(ConfigElement.getPath(MAX_COMMIT_TIME), customCommitTime);
    try {
        graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
        fail("Masking managed config options should be disabled in this configuration");
    } catch (JanusGraphConfigurationException e) {
        // Exception should cite the problematic setting's full name
        assertTrue(e.getMessage().contains(ConfigElement.getPath(MAX_COMMIT_TIME)));
    }
    // Allow managed option masking (default config again) and check that the local value is ignored and
    // that no exception is thrown
    close();
    wc = getConfiguration();
    wc.set(ConfigElement.getPath(ALLOW_STALE_CONFIG), true);
    wc.set(ConfigElement.getPath(MAX_COMMIT_TIME), customCommitTime);
    graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
    // Local value should be overridden by the default that already exists in the backend
    assertEquals(MAX_COMMIT_TIME.getDefaultValue(), graph.getConfiguration().getMaxCommitTime());
    // Wipe the storage backend
    graph.getBackend().clearStorage();
    try {
        graph.close();
    } catch (Throwable t) {
        log.debug("Swallowing throwable during shutdown after clearing backend storage", t);
    }
    // Bootstrap a new DB with managed option masking disabled
    wc = getConfiguration();
    wc.set(ConfigElement.getPath(ALLOW_STALE_CONFIG), false);
    graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
    close();
    // Check for expected exception
    wc = getConfiguration();
    wc.set(ConfigElement.getPath(MAX_COMMIT_TIME), customCommitTime);
    try {
        graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
        fail("Masking managed config options should be disabled in this configuration");
    } catch (JanusGraphConfigurationException e) {
        // Exception should cite the problematic setting's full name
        assertTrue(e.getMessage().contains(ConfigElement.getPath(MAX_COMMIT_TIME)));
    }
    // Now check that ALLOW_STALE_CONFIG is actually MASKABLE -- enable it in the local config
    wc = getConfiguration();
    wc.set(ConfigElement.getPath(ALLOW_STALE_CONFIG), true);
    wc.set(ConfigElement.getPath(MAX_COMMIT_TIME), customCommitTime);
    graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
    // Local value should be overridden by the default that already exists in the backend
    assertEquals(MAX_COMMIT_TIME.getDefaultValue(), graph.getConfiguration().getMaxCommitTime());
}
Also used : JanusGraphConfigurationException(org.janusgraph.core.JanusGraphConfigurationException) Duration(java.time.Duration) WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 20 with WriteConfiguration

use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.

the class CassandraGraphTest method testCustomConfigUsedByTx.

@Test
public void testCustomConfigUsedByTx() {
    close();
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ALL");
    wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "ALL");
    graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
    StandardJanusGraphTx tx = (StandardJanusGraphTx) graph.buildTransaction().customOption(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ONE").customOption(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "TWO").start();
    assertEquals("ONE", tx.getTxHandle().getBaseTransactionConfig().getCustomOptions().get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
    assertEquals("TWO", tx.getTxHandle().getBaseTransactionConfig().getCustomOptions().get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));
    tx.rollback();
}
Also used : StandardJanusGraphTx(org.janusgraph.graphdb.transaction.StandardJanusGraphTx) WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) Test(org.junit.Test)

Aggregations

WriteConfiguration (org.janusgraph.diskstorage.configuration.WriteConfiguration)40 Test (org.junit.jupiter.api.Test)26 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)21 ModifiableConfiguration (org.janusgraph.diskstorage.configuration.ModifiableConfiguration)7 StandardJanusGraphTx (org.janusgraph.graphdb.transaction.StandardJanusGraphTx)7 BasicConfiguration (org.janusgraph.diskstorage.configuration.BasicConfiguration)6 File (java.io.File)5 GraphDatabaseConfiguration (org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration)5 StandardJanusGraph (org.janusgraph.graphdb.database.StandardJanusGraph)5 Test (org.junit.Test)5 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)4 URL (java.net.URL)3 JanusGraphManagement (org.janusgraph.core.schema.JanusGraphManagement)3 Configuration (org.janusgraph.diskstorage.configuration.Configuration)3 RequestLogger (com.datastax.oss.driver.internal.core.tracker.RequestLogger)2 IOException (java.io.IOException)2 StringWriter (java.io.StringWriter)2 Duration (java.time.Duration)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2