Search in sources :

Example 1 with WriteConfiguration

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

the class CassandraGraphTest method testGraphConfigUsedByTx.

@Test
public void testGraphConfigUsedByTx() {
    close();
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "TWO");
    wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "THREE");
    graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
    StandardJanusGraphTx tx = (StandardJanusGraphTx) graph.newTransaction();
    assertEquals("TWO", tx.getTxHandle().getBaseTransactionConfig().getCustomOptions().get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
    assertEquals("THREE", 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)

Example 2 with WriteConfiguration

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

the class CassandraGraphTest method testTitanGraphBackwardCompatibility.

@Test
public void testTitanGraphBackwardCompatibility() {
    close();
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(CASSANDRA_KEYSPACE), "titan");
    wc.set(ConfigElement.getPath(GraphDatabaseConfiguration.TITAN_COMPATIBLE_VERSIONS), "x.x.x");
    assertNull(wc.get(ConfigElement.getPath(GraphDatabaseConfiguration.INITIAL_JANUSGRAPH_VERSION), GraphDatabaseConfiguration.INITIAL_JANUSGRAPH_VERSION.getDatatype()));
    assertFalse(JanusGraphConstants.TITAN_COMPATIBLE_VERSIONS.contains(wc.get(ConfigElement.getPath(GraphDatabaseConfiguration.TITAN_COMPATIBLE_VERSIONS), GraphDatabaseConfiguration.TITAN_COMPATIBLE_VERSIONS.getDatatype())));
    wc.set(ConfigElement.getPath(GraphDatabaseConfiguration.TITAN_COMPATIBLE_VERSIONS), "1.0.0");
    assertTrue(JanusGraphConstants.TITAN_COMPATIBLE_VERSIONS.contains(wc.get(ConfigElement.getPath(GraphDatabaseConfiguration.TITAN_COMPATIBLE_VERSIONS), GraphDatabaseConfiguration.TITAN_COMPATIBLE_VERSIONS.getDatatype())));
    wc.set(ConfigElement.getPath(GraphDatabaseConfiguration.IDS_STORE_NAME), JanusGraphConstants.TITAN_ID_STORE_NAME);
    assertTrue(JanusGraphConstants.TITAN_ID_STORE_NAME.equals(wc.get(ConfigElement.getPath(GraphDatabaseConfiguration.IDS_STORE_NAME), GraphDatabaseConfiguration.IDS_STORE_NAME.getDatatype())));
    graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
}
Also used : WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) Test(org.junit.Test)

Example 3 with WriteConfiguration

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

the class CQLGraphTest method testTitanGraphBackwardCompatibility.

@Test
public void testTitanGraphBackwardCompatibility() {
    close();
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(KEYSPACE), "titan");
    wc.set(ConfigElement.getPath(GraphDatabaseConfiguration.TITAN_COMPATIBLE_VERSIONS), "x.x.x");
    assertNull(wc.get(ConfigElement.getPath(GraphDatabaseConfiguration.INITIAL_JANUSGRAPH_VERSION), GraphDatabaseConfiguration.INITIAL_JANUSGRAPH_VERSION.getDatatype()));
    assertFalse(JanusGraphConstants.TITAN_COMPATIBLE_VERSIONS.contains(wc.get(ConfigElement.getPath(GraphDatabaseConfiguration.TITAN_COMPATIBLE_VERSIONS), GraphDatabaseConfiguration.TITAN_COMPATIBLE_VERSIONS.getDatatype())));
    wc.set(ConfigElement.getPath(GraphDatabaseConfiguration.TITAN_COMPATIBLE_VERSIONS), "1.0.0");
    assertTrue(JanusGraphConstants.TITAN_COMPATIBLE_VERSIONS.contains(wc.get(ConfigElement.getPath(GraphDatabaseConfiguration.TITAN_COMPATIBLE_VERSIONS), GraphDatabaseConfiguration.TITAN_COMPATIBLE_VERSIONS.getDatatype())));
    graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
}
Also used : WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) Test(org.junit.Test) CassandraGraphTest(org.janusgraph.graphdb.CassandraGraphTest)

Example 4 with WriteConfiguration

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

the class JanusGraphFactory method open.

/**
 * Opens a {@link JanusGraph} database configured according to the provided configuration.
 * This method shouldn't be called by end users; it is used by internal server processes to
 * open graphs defined at server start that do not include the graphname property.
 *
 * @param configuration Configuration for the graph database
 * @param backupName Backup name for graph
 * @return JanusGraph graph database
 */
public static JanusGraph open(ReadConfiguration configuration, String backupName) {
    final ModifiableConfiguration config = new ModifiableConfiguration(ROOT_NS, (WriteConfiguration) configuration, BasicConfiguration.Restriction.NONE);
    final String graphName = config.has(GRAPH_NAME) ? config.get(GRAPH_NAME) : backupName;
    final JanusGraphManager jgm = JanusGraphManagerUtility.getInstance();
    if (null != graphName) {
        Preconditions.checkNotNull(jgm, JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG);
        return (JanusGraph) jgm.openGraph(graphName, gName -> new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(configuration)));
    } else {
        if (jgm != null) {
            log.warn("You should supply \"graph.graphname\" in your .properties file configuration if you are opening " + "a graph that has not already been opened at server start, i.e. it was " + "defined in your YAML file. This will ensure the graph is tracked by the JanusGraphManager, " + "which will enable autocommit and rollback functionality upon all gremlin script executions. " + "Note that JanusGraphFactory#open(String === shortcut notation) does not support consuming the property " + "\"graph.graphname\" so these graphs should be accessed dynamically by supplying a .properties file here " + "or by using the ConfiguredGraphFactory.");
        }
        return new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(configuration));
    }
}
Also used : GRAPH_NAME(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.GRAPH_NAME) StandardStoreManager(org.janusgraph.diskstorage.StandardStoreManager) Spliterators(java.util.Spliterators) Graph(org.apache.tinkerpop.gremlin.structure.Graph) STORAGE_BACKEND(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.STORAGE_BACKEND) LoggerFactory(org.slf4j.LoggerFactory) ConfigOption(org.janusgraph.diskstorage.configuration.ConfigOption) StringUtils(org.apache.commons.lang3.StringUtils) Backend(org.janusgraph.diskstorage.Backend) ROOT_NS(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.ROOT_NS) StandardTransactionLogProcessor(org.janusgraph.graphdb.log.StandardTransactionLogProcessor) WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) GraphDatabaseConfigurationBuilder(org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder) STORAGE_HOSTS(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.STORAGE_HOSTS) StreamSupport(java.util.stream.StreamSupport) JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG(org.janusgraph.graphdb.management.JanusGraphManager.JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG) TransactionRecovery(org.janusgraph.core.log.TransactionRecovery) BackendException(org.janusgraph.diskstorage.BackendException) ConfigurationUtil(org.janusgraph.util.system.ConfigurationUtil) Logger(org.slf4j.Logger) LoggerUtil.sanitizeAndLaunder(org.janusgraph.util.system.LoggerUtil.sanitizeAndLaunder) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) STORAGE_DIRECTORY(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.STORAGE_DIRECTORY) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) IOUtils(org.janusgraph.util.system.IOUtils) Set(java.util.Set) Instant(java.time.Instant) STORAGE_NS(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.STORAGE_NS) Collectors(java.util.stream.Collectors) Configuration(org.apache.commons.configuration2.Configuration) File(java.io.File) ConfigurationException(org.apache.commons.configuration2.ex.ConfigurationException) List(java.util.List) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration) LogProcessorFramework(org.janusgraph.core.log.LogProcessorFramework) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager) INDEX_DIRECTORY(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.INDEX_DIRECTORY) BaseConfiguration(org.apache.commons.configuration2.BaseConfiguration) INDEX_CONF_FILE(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.INDEX_CONF_FILE) BasicConfiguration(org.janusgraph.diskstorage.configuration.BasicConfiguration) STORAGE_CONF_FILE(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.STORAGE_CONF_FILE) Preconditions(com.google.common.base.Preconditions) Pattern(java.util.regex.Pattern) StandardLogProcessorFramework(org.janusgraph.graphdb.log.StandardLogProcessorFramework) INDEX_NS(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.INDEX_NS) ModifiableConfiguration(org.janusgraph.diskstorage.configuration.ModifiableConfiguration) ReadConfiguration(org.janusgraph.diskstorage.configuration.ReadConfiguration) GraphDatabaseConfigurationBuilder(org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager) ModifiableConfiguration(org.janusgraph.diskstorage.configuration.ModifiableConfiguration) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph)

Example 5 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)

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