use of org.janusgraph.graphdb.management.ConfigurationManagementGraph in project janusgraph by JanusGraph.
the class ConfiguredGraphFactoryTest method shouldGetConfigurationManagementGraphInstance.
@Test
public void shouldGetConfigurationManagementGraphInstance() throws ConfigurationManagementGraphNotEnabledException {
final ConfigurationManagementGraph thisInstance = ConfigurationManagementGraph.getInstance();
assertNotNull(thisInstance);
}
use of org.janusgraph.graphdb.management.ConfigurationManagementGraph in project janusgraph by JanusGraph.
the class ConfiguredGraphFactory method createTemplateConfiguration.
/**
* Create a template configuration according to the supplied {@link Configuration}; if
* you already created a template configuration or the supplied {@link Configuration}
* contains the property "graph.graphname", we throw a {@link RuntimeException}; you can then use
* this template configuration to create a graph using the
* ConfiguredGraphFactory create signature and supplying a new graphName.
*/
public static void createTemplateConfiguration(final Configuration config) {
final ConfigurationManagementGraph configManagementGraph = getConfigGraphManagementInstance();
configManagementGraph.createTemplateConfiguration(config);
}
use of org.janusgraph.graphdb.management.ConfigurationManagementGraph 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;
}
use of org.janusgraph.graphdb.management.ConfigurationManagementGraph in project janusgraph by JanusGraph.
the class ConfiguredGraphFactory method updateConfiguration.
/**
* Update configuration corresponding to supplied graphName; we update supplied existing
* properties and add new ones to the {@link Configuration}; The supplied {@link Configuration} must include a
* property "graph.graphname" and it must match supplied graphName;
* NOTE: The updated configuration is only guaranteed to take effect if the {@link Graph} corresponding to
* graphName has been closed and reopened on every JanusGraph Node.
*/
public static void updateConfiguration(final String graphName, final Configuration config) {
final ConfigurationManagementGraph configManagementGraph = getConfigGraphManagementInstance();
removeGraphFromCache(graphName);
configManagementGraph.updateConfiguration(graphName, config);
}
use of org.janusgraph.graphdb.management.ConfigurationManagementGraph in project janusgraph by JanusGraph.
the class ConfiguredGraphFactory method getGraphNames.
/**
* Get a Set of the graphNames that exist in your configuration management graph
*/
public static Set<String> getGraphNames() {
final ConfigurationManagementGraph configManagementGraph = getConfigGraphManagementInstance();
final List<Map<String, Object>> configurations = configManagementGraph.getConfigurations();
return configurations.stream().map(elem -> (String) elem.getOrDefault(ConfigurationManagementGraph.PROPERTY_GRAPH_NAME, null)).filter(Objects::nonNull).collect(Collectors.toSet());
}
Aggregations