Search in sources :

Example 1 with BasicConfiguration

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

the class HBaseStoreManagerConfigTest method testShortCfNames.

@Test
public void testShortCfNames() throws Exception {
    Logger log = Logger.getLogger(HBaseStoreManager.class);
    Level savedLevel = log.getLevel();
    log.setLevel(Level.WARN);
    StringWriter writer = new StringWriter();
    Appender appender = new WriterAppender(new PatternLayout("%p: %m%n"), writer);
    log.addAppender(appender);
    // Open the HBaseStoreManager and store with default SHORT_CF_NAMES true.
    WriteConfiguration config = HBaseStorageSetup.getHBaseGraphConfiguration();
    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(), writer.toString().startsWith("WARN: Configuration"));
    log.removeAppender(appender);
    log.setLevel(savedLevel);
    store.close();
    manager.close();
}
Also used : Appender(org.apache.log4j.Appender) WriterAppender(org.apache.log4j.WriterAppender) StringWriter(java.io.StringWriter) KeyColumnValueStore(org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStore) PatternLayout(org.apache.log4j.PatternLayout) Level(org.apache.log4j.Level) WriterAppender(org.apache.log4j.WriterAppender) WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) Logger(org.apache.log4j.Logger) BasicConfiguration(org.janusgraph.diskstorage.configuration.BasicConfiguration) Test(org.junit.Test)

Example 2 with BasicConfiguration

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

the class AbstractJanusGraphProvider method clear.

// @Override
// public <ID> ID reconstituteGraphSONIdentifier(final Class<? extends Element> clazz, final Object id) {
// if (Edge.class.isAssignableFrom(clazz)) {
// // JanusGraphSONModule toStrings the edgeId - expect a String value for the id
// if (!(id instanceof String)) throw new RuntimeException("Expected a String value for the RelationIdentifier");
// return (ID) RelationIdentifier.parse((String) id);
// } else {
// return (ID) id;
// }
// }
@Override
public void clear(Graph g, final Configuration configuration) throws Exception {
    if (null != g) {
        while (g instanceof WrappedGraph) g = ((WrappedGraph<? extends Graph>) g).getBaseGraph();
        JanusGraph graph = (JanusGraph) g;
        if (graph.isOpen()) {
            if (g.tx().isOpen())
                g.tx().rollback();
            try {
                g.close();
            } catch (IOException | IllegalStateException e) {
                logger.warn("Titan graph may not have closed cleanly", e);
            }
        }
    }
    WriteConfiguration config = new CommonsConfiguration(configuration);
    BasicConfiguration readConfig = new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, config, BasicConfiguration.Restriction.NONE);
    if (readConfig.has(GraphDatabaseConfiguration.STORAGE_BACKEND)) {
        JanusGraphBaseTest.clearGraph(config);
    }
}
Also used : Graph(org.apache.tinkerpop.gremlin.structure.Graph) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) WrappedGraph(org.apache.tinkerpop.gremlin.structure.util.wrapped.WrappedGraph) JanusGraph(org.janusgraph.core.JanusGraph) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) JanusGraph(org.janusgraph.core.JanusGraph) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) IOException(java.io.IOException) WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) BasicConfiguration(org.janusgraph.diskstorage.configuration.BasicConfiguration) WrappedGraph(org.apache.tinkerpop.gremlin.structure.util.wrapped.WrappedGraph)

Aggregations

BasicConfiguration (org.janusgraph.diskstorage.configuration.BasicConfiguration)2 WriteConfiguration (org.janusgraph.diskstorage.configuration.WriteConfiguration)2 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Appender (org.apache.log4j.Appender)1 Level (org.apache.log4j.Level)1 Logger (org.apache.log4j.Logger)1 PatternLayout (org.apache.log4j.PatternLayout)1 WriterAppender (org.apache.log4j.WriterAppender)1 Graph (org.apache.tinkerpop.gremlin.structure.Graph)1 WrappedGraph (org.apache.tinkerpop.gremlin.structure.util.wrapped.WrappedGraph)1 JanusGraph (org.janusgraph.core.JanusGraph)1 CommonsConfiguration (org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration)1 KeyColumnValueStore (org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStore)1 StandardJanusGraph (org.janusgraph.graphdb.database.StandardJanusGraph)1 Test (org.junit.Test)1