Search in sources :

Example 16 with GraphDatabaseConfigurationBuilder

use of org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder in project janusgraph by JanusGraph.

the class EnsureCacheTest method NopTest.

@Test
public void NopTest() {
    final Map<String, Object> map = new HashMap<>();
    map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
    final MapConfiguration config = ConfigurationUtil.loadMapConfiguration(map);
    final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config)));
    graph.traversal().addV().iterate();
}
Also used : GraphDatabaseConfigurationBuilder(org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder) HashMap(java.util.HashMap) MapConfiguration(org.apache.commons.configuration2.MapConfiguration) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Test(org.junit.jupiter.api.Test)

Example 17 with GraphDatabaseConfigurationBuilder

use of org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder in project janusgraph by JanusGraph.

the class ConfiguredGraphFactory method open.

/**
 * Open a {@link JanusGraph} using a previously created Configuration using the
 * {@link ConfigurationManagementGraph} API. A corresponding configuration must exist.
 *
 * <p>NOTE: If your configuration corresponding to this graph does not contain information about
 * the backend's keyspace/table/storage directory, then we set the keyspace/table to the
 * graphName or set the storage directory to the storage_root + /graphName.</p>
 *
 * @param graphName
 *
 * @return JanusGraph
 */
public static JanusGraph open(String graphName) {
    final ConfigurationManagementGraph configManagementGraph = getConfigGraphManagementInstance();
    final Map<String, Object> graphConfigMap = configManagementGraph.getConfiguration(graphName);
    Preconditions.checkNotNull(graphConfigMap, "Please create configuration for this graph using the ConfigurationManagementGraph#createConfiguration API.");
    final JanusGraphManager jgm = JanusGraphManagerUtility.getInstance();
    Preconditions.checkNotNull(jgm, JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG);
    final CommonsConfiguration config = new CommonsConfiguration(ConfigurationUtil.loadMapConfiguration(graphConfigMap));
    return (JanusGraph) jgm.openGraph(graphName, (String gName) -> new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(config)));
}
Also used : GraphDatabaseConfigurationBuilder(org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) ConfigurationManagementGraph(org.janusgraph.graphdb.management.ConfigurationManagementGraph) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph)

Example 18 with GraphDatabaseConfigurationBuilder

use of org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder in project janusgraph by JanusGraph.

the class ManagementLoggerGraphCacheEvictionTest method graphShouldBeRemovedFromCache.

@Test
public void graphShouldBeRemovedFromCache() throws InterruptedException {
    final JanusGraphManager jgm = new JanusGraphManager(new Settings());
    assertNotNull(jgm);
    assertNotNull(JanusGraphManager.getInstance());
    assertNull(jgm.getGraph("graph1"));
    final Map<String, Object> map = new HashMap<>();
    map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
    map.put(GRAPH_NAME.toStringWithoutRoot(), "graph1");
    final MapConfiguration config = ConfigurationUtil.loadMapConfiguration(map);
    final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config)));
    jgm.putGraph("graph1", graph);
    assertEquals("graph1", ((StandardJanusGraph) JanusGraphManager.getInstance().getGraph("graph1")).getGraphName());
    final ManagementSystem mgmt = (ManagementSystem) graph.openManagement();
    mgmt.evictGraphFromCache();
    mgmt.commit();
    // wait for log to be asynchronously pulled
    Thread.sleep(10000);
    assertNull(jgm.getGraph("graph1"));
}
Also used : ManagementSystem(org.janusgraph.graphdb.database.management.ManagementSystem) GraphDatabaseConfigurationBuilder(org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder) HashMap(java.util.HashMap) MapConfiguration(org.apache.commons.configuration2.MapConfiguration) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) Settings(org.apache.tinkerpop.gremlin.server.Settings) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Test(org.junit.jupiter.api.Test)

Example 19 with GraphDatabaseConfigurationBuilder

use of org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder in project janusgraph by JanusGraph.

the class ConfigurationManagementGraphTest method shouldReindexIfPropertyKeyExists.

@Test
public void shouldReindexIfPropertyKeyExists() {
    final Map<String, Object> map = new HashMap<>();
    map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
    final MapConfiguration config = ConfigurationUtil.loadMapConfiguration(map);
    final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config)));
    final String propertyKeyName = "Created_Using_Template";
    final Class dataType = Boolean.class;
    JanusGraphManagement management = graph.openManagement();
    management.makePropertyKey(propertyKeyName).dataType(dataType).make();
    management.commit();
    // Instantiate the ConfigurationManagementGraph Singleton
    // This is purposefully done after a property key is created to ensure that a REDINDEX is initiated
    new ConfigurationManagementGraph(graph);
    management = graph.openManagement();
    final JanusGraphIndex index = management.getGraphIndex("Created_Using_Template_Index");
    final PropertyKey propertyKey = management.getPropertyKey("Created_Using_Template");
    assertNotNull(index);
    assertNotNull(propertyKey);
    assertEquals(ENABLED, index.getIndexStatus(propertyKey));
    management.commit();
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) HashMap(java.util.HashMap) MapConfiguration(org.apache.commons.configuration2.MapConfiguration) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) GraphDatabaseConfigurationBuilder(org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder) JanusGraphIndex(org.janusgraph.core.schema.JanusGraphIndex) PropertyKey(org.janusgraph.core.PropertyKey) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Test(org.junit.jupiter.api.Test)

Aggregations

GraphDatabaseConfigurationBuilder (org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder)19 CommonsConfiguration (org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration)18 StandardJanusGraph (org.janusgraph.graphdb.database.StandardJanusGraph)18 MapConfiguration (org.apache.commons.configuration2.MapConfiguration)16 Test (org.junit.jupiter.api.Test)14 HashMap (java.util.HashMap)4 JanusGraphManager (org.janusgraph.graphdb.management.JanusGraphManager)4 Settings (org.apache.tinkerpop.gremlin.server.Settings)2 ModifiableConfiguration (org.janusgraph.diskstorage.configuration.ModifiableConfiguration)2 GraphDatabaseConfiguration (org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration)2 ConfigurationManagementGraph (org.janusgraph.graphdb.management.ConfigurationManagementGraph)2 Preconditions (com.google.common.base.Preconditions)1 File (java.io.File)1 Instant (java.time.Instant)1 List (java.util.List)1 Set (java.util.Set)1 Spliterators (java.util.Spliterators)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 StreamSupport (java.util.stream.StreamSupport)1