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;
}
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());
}
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());
}
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());
}
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);
}
}
Aggregations