Search in sources :

Example 11 with JanusGraphManager

use of org.janusgraph.graphdb.management.JanusGraphManager 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.checkState(null != graphConfigMap, "Please create configuration for this graph using the ConfigurationManagementGraph#createConfiguration API.");
    final JanusGraphManager jgm = JanusGraphManagerUtility.getInstance();
    Preconditions.checkState(jgm != null, JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG);
    final CommonsConfiguration config = new CommonsConfiguration(new MapConfiguration(graphConfigMap));
    return (JanusGraph) jgm.openGraph(graphName, (String gName) -> new StandardJanusGraph(new GraphDatabaseConfiguration(config)));
}
Also used : MapConfiguration(org.apache.commons.configuration.MapConfiguration) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) ConfigurationManagementGraph(org.janusgraph.graphdb.management.ConfigurationManagementGraph) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph)

Example 12 with JanusGraphManager

use of org.janusgraph.graphdb.management.JanusGraphManager in project janusgraph by JanusGraph.

the class ConfiguredGraphFactory method removeGraphFromCache.

private static void removeGraphFromCache(final JanusGraph graph) {
    final JanusGraphManager jgm = JanusGraphManagerUtility.getInstance();
    Preconditions.checkState(jgm != null, JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG);
    jgm.removeGraph(((StandardJanusGraph) graph).getGraphName());
    final ManagementSystem mgmt = (ManagementSystem) graph.openManagement();
    mgmt.evictGraphFromCache();
    mgmt.commit();
}
Also used : ManagementSystem(org.janusgraph.graphdb.database.management.ManagementSystem) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager)

Aggregations

JanusGraphManager (org.janusgraph.graphdb.management.JanusGraphManager)12 StandardJanusGraph (org.janusgraph.graphdb.database.StandardJanusGraph)5 GraphManager (org.apache.tinkerpop.gremlin.server.GraphManager)4 GraphDatabaseConfiguration (org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration)4 CommonsConfiguration (org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration)3 ConfigurationManagementGraph (org.janusgraph.graphdb.management.ConfigurationManagementGraph)3 MapConfiguration (org.apache.commons.configuration.MapConfiguration)2 Graph (org.apache.tinkerpop.gremlin.structure.Graph)2 Backend (org.janusgraph.diskstorage.Backend)2 Preconditions (com.google.common.base.Preconditions)1 Iterators (com.google.common.collect.Iterators)1 File (java.io.File)1 Instant (java.time.Instant)1 java.util (java.util)1 Pattern (java.util.regex.Pattern)1 BaseConfiguration (org.apache.commons.configuration.BaseConfiguration)1 Configuration (org.apache.commons.configuration.Configuration)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)1 StringUtils (org.apache.commons.lang.StringUtils)1