use of org.janusgraph.graphdb.management.JanusGraphManager in project janusgraph by JanusGraph.
the class JanusGraphWebSocketChannelizer 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 close.
/**
* Removes {@link Graph} from {@link JanusGraphManager} graph reference tracker, if exists
* there.
*
* @param graph Graph
*/
public static void close(Graph graph) throws Exception {
final JanusGraphManager jgm = JanusGraphManagerUtility.getInstance();
if (jgm != null) {
jgm.removeGraph(((StandardJanusGraph) graph).getGraphName());
}
graph.close();
}
use of org.janusgraph.graphdb.management.JanusGraphManager in project janusgraph by JanusGraph.
the class JanusGraphFactory method open.
/**
* Opens a {@link JanusGraph} database configured according to the provided configuration.
* This method shouldn't be called by end users; it is used by internal server processes to
* open graphs defined at server start that do not include the graphname property.
*
* @param configuration Configuration for the graph database
* @param backupName Backup name for graph
* @return JanusGraph graph database
*/
public static JanusGraph open(ReadConfiguration configuration, String backupName) {
final ModifiableConfiguration config = new ModifiableConfiguration(ROOT_NS, (WriteConfiguration) configuration, BasicConfiguration.Restriction.NONE);
final String graphName = config.has(GRAPH_NAME) ? config.get(GRAPH_NAME) : backupName;
final JanusGraphManager jgm = JanusGraphManagerUtility.getInstance();
if (null != graphName) {
Preconditions.checkNotNull(jgm, JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG);
return (JanusGraph) jgm.openGraph(graphName, gName -> new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(configuration)));
} else {
if (jgm != null) {
log.warn("You should supply \"graph.graphname\" in your .properties file configuration if you are opening " + "a graph that has not already been opened at server start, i.e. it was " + "defined in your YAML file. This will ensure the graph is tracked by the JanusGraphManager, " + "which will enable autocommit and rollback functionality upon all gremlin script executions. " + "Note that JanusGraphFactory#open(String === shortcut notation) does not support consuming the property " + "\"graph.graphname\" so these graphs should be accessed dynamically by supplying a .properties file here " + "or by using the ConfiguredGraphFactory.");
}
return new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(configuration));
}
}
use of org.janusgraph.graphdb.management.JanusGraphManager in project janusgraph by JanusGraph.
the class JanusGraphFactory method getGraphNames.
/**
* Return a Set of graph names stored in the {@link JanusGraphManager}
*
* @return Set<String>
*/
public static Set<String> getGraphNames() {
final JanusGraphManager jgm = JanusGraphManagerUtility.getInstance();
Preconditions.checkNotNull(jgm, JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG);
return jgm.getGraphNames();
}
use of org.janusgraph.graphdb.management.JanusGraphManager in project janusgraph by JanusGraph.
the class ConfiguredGraphFactory method create.
/**
* Creates a {@link JanusGraph} configuration stored in the {@link ConfigurationManagementGraph}
* graph and a {@link JanusGraph} graph reference according to the single
* Template Configuration previously created by the {@link ConfigurationManagementGraph} API;
* A configuration for this graph must not already exist, and a Template Configuration must
* exist. If the Template Configuration does not include its
* backend's respective keyspace/table/storage_directory parameter, we set the keyspace/table
* to the supplied graphName or we append the graphName to the supplied
* storage_root parameter.
*
* @param graphName
*
* @return JanusGraph
*/
public static synchronized JanusGraph create(final String graphName) {
final ConfigurationManagementGraph configManagementGraph = getConfigGraphManagementInstance();
final Map<String, Object> graphConfigMap = configManagementGraph.getConfiguration(graphName);
Preconditions.checkState(null == graphConfigMap, String.format("Configuration for graph %s already exists.", graphName));
final Map<String, Object> templateConfigMap = configManagementGraph.getTemplateConfiguration();
Preconditions.checkNotNull(templateConfigMap, "Please create a template Configuration using the ConfigurationManagementGraph#createTemplateConfiguration API.");
templateConfigMap.put(ConfigurationManagementGraph.PROPERTY_GRAPH_NAME, graphName);
templateConfigMap.put(ConfigurationManagementGraph.PROPERTY_CREATED_USING_TEMPLATE, true);
final JanusGraphManager jgm = JanusGraphManagerUtility.getInstance();
Preconditions.checkNotNull(jgm, JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG);
final CommonsConfiguration config = new CommonsConfiguration(ConfigurationUtil.loadMapConfiguration(templateConfigMap));
final JanusGraph g = (JanusGraph) jgm.openGraph(graphName, (String gName) -> new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(config)));
configManagementGraph.createConfiguration(new MapConfiguration(templateConfigMap));
return g;
}
Aggregations