Search in sources :

Example 6 with JanusGraphManager

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

the class ConfiguredGraphFactory method close.

/**
 * Removes the graph corresponding to the supplied graphName
 * from the {@link JanusGraphManager} {@link Map<String, Graph>} graph reference tracker and
 * returns the corresponding Graph, or null if it doesn't exist.
 *
 * @param graphName Graph
 * @return JanusGraph
 */
public static JanusGraph close(String graphName) throws Exception {
    final JanusGraphManager jgm = JanusGraphManagerUtility.getInstance();
    Preconditions.checkState(jgm != null, JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG);
    final Graph graph = jgm.removeGraph(graphName);
    if (null != graph)
        graph.close();
    return (JanusGraph) graph;
}
Also used : StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Graph(org.apache.tinkerpop.gremlin.structure.Graph) ConfigurationManagementGraph(org.janusgraph.graphdb.management.ConfigurationManagementGraph) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager)

Example 7 with JanusGraphManager

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

the class JanusGraphNioChannelizer method init.

@Override
public void init(final ServerGremlinExecutor serverGremlinExecutor) {
    this.serverGremlinExecutor = serverGremlinExecutor;
    super.init(serverGremlinExecutor);
    final GraphManager graphManager = serverGremlinExecutor.getGraphManager();
    Preconditions.checkArgument(graphManager instanceof JanusGraphManager, "Must use JanusGraphManager with a JanusGraphChannelizer.");
    ((JanusGraphManager) graphManager).configureGremlinExecutor(serverGremlinExecutor.getGremlinExecutor());
}
Also used : GraphManager(org.apache.tinkerpop.gremlin.server.GraphManager) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager)

Example 8 with JanusGraphManager

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

the class JanusGraphWsAndHttpChannelizer method init.

@Override
public void init(final ServerGremlinExecutor serverGremlinExecutor) {
    this.serverGremlinExecutor = serverGremlinExecutor;
    super.init(serverGremlinExecutor);
    final GraphManager graphManager = serverGremlinExecutor.getGraphManager();
    Preconditions.checkArgument(graphManager instanceof JanusGraphManager, "Must use JanusGraphManager with a JanusGraphChannelizer.");
    ((JanusGraphManager) graphManager).configureGremlinExecutor(serverGremlinExecutor.getGremlinExecutor());
}
Also used : GraphManager(org.apache.tinkerpop.gremlin.server.GraphManager) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager)

Example 9 with JanusGraphManager

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

the class JanusGraphHttpChannelizer method init.

@Override
public void init(final ServerGremlinExecutor serverGremlinExecutor) {
    this.serverGremlinExecutor = serverGremlinExecutor;
    super.init(serverGremlinExecutor);
    final GraphManager graphManager = serverGremlinExecutor.getGraphManager();
    Preconditions.checkArgument(graphManager instanceof JanusGraphManager, "Must use JanusGraphManager with a JanusGraphChannelizer.");
    ((JanusGraphManager) graphManager).configureGremlinExecutor(serverGremlinExecutor.getGremlinExecutor());
}
Also used : GraphManager(org.apache.tinkerpop.gremlin.server.GraphManager) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager)

Example 10 with JanusGraphManager

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

the class JanusGraphFactory method drop.

/**
 * Drop graph database, deleting all data in storage and indexing backends. Graph can be open or closed (will be
 * closed as part of the drop operation). The graph is also removed from the {@link JanusGraphManager}
 * graph reference tracker, if there.
 *
 * <p><b>WARNING: This is an irreversible operation that will delete all graph and index data.</b></p>
 * @param graph JanusGraph graph database. Can be open or closed.
 * @throws BackendException If an error occurs during deletion
 */
public static void drop(JanusGraph graph) throws BackendException {
    Preconditions.checkNotNull(graph);
    Preconditions.checkArgument(graph instanceof StandardJanusGraph, "Invalid graph instance detected: %s", graph.getClass());
    final StandardJanusGraph g = (StandardJanusGraph) graph;
    final JanusGraphManager jgm = JanusGraphManagerUtility.getInstance();
    if (jgm != null) {
        jgm.removeGraph(g.getGraphName());
    }
    if (graph.isOpen()) {
        graph.close();
    }
    final GraphDatabaseConfiguration config = g.getConfiguration();
    final Backend backend = config.getBackend();
    try {
        backend.clearStorage();
    } finally {
        IOUtils.closeQuietly(backend);
    }
}
Also used : Backend(org.janusgraph.diskstorage.Backend) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph)

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