use of org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder in project janusgraph by JanusGraph.
the class EnsureCacheTest method NopTest.
@Test
public void NopTest() {
final Map<String, Object> map = new HashMap<>();
map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
final MapConfiguration config = ConfigurationUtil.loadMapConfiguration(map);
final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config)));
graph.traversal().addV().iterate();
}
use of org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder 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.checkNotNull(graphConfigMap, "Please create configuration for this graph using the ConfigurationManagementGraph#createConfiguration API.");
final JanusGraphManager jgm = JanusGraphManagerUtility.getInstance();
Preconditions.checkNotNull(jgm, JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG);
final CommonsConfiguration config = new CommonsConfiguration(ConfigurationUtil.loadMapConfiguration(graphConfigMap));
return (JanusGraph) jgm.openGraph(graphName, (String gName) -> new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(config)));
}
use of org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder in project janusgraph by JanusGraph.
the class ManagementLoggerGraphCacheEvictionTest method graphShouldBeRemovedFromCache.
@Test
public void graphShouldBeRemovedFromCache() throws InterruptedException {
final JanusGraphManager jgm = new JanusGraphManager(new Settings());
assertNotNull(jgm);
assertNotNull(JanusGraphManager.getInstance());
assertNull(jgm.getGraph("graph1"));
final Map<String, Object> map = new HashMap<>();
map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
map.put(GRAPH_NAME.toStringWithoutRoot(), "graph1");
final MapConfiguration config = ConfigurationUtil.loadMapConfiguration(map);
final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config)));
jgm.putGraph("graph1", graph);
assertEquals("graph1", ((StandardJanusGraph) JanusGraphManager.getInstance().getGraph("graph1")).getGraphName());
final ManagementSystem mgmt = (ManagementSystem) graph.openManagement();
mgmt.evictGraphFromCache();
mgmt.commit();
// wait for log to be asynchronously pulled
Thread.sleep(10000);
assertNull(jgm.getGraph("graph1"));
}
use of org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder in project janusgraph by JanusGraph.
the class ConfigurationManagementGraphTest method shouldReindexIfPropertyKeyExists.
@Test
public void shouldReindexIfPropertyKeyExists() {
final Map<String, Object> map = new HashMap<>();
map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
final MapConfiguration config = ConfigurationUtil.loadMapConfiguration(map);
final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config)));
final String propertyKeyName = "Created_Using_Template";
final Class dataType = Boolean.class;
JanusGraphManagement management = graph.openManagement();
management.makePropertyKey(propertyKeyName).dataType(dataType).make();
management.commit();
// Instantiate the ConfigurationManagementGraph Singleton
// This is purposefully done after a property key is created to ensure that a REDINDEX is initiated
new ConfigurationManagementGraph(graph);
management = graph.openManagement();
final JanusGraphIndex index = management.getGraphIndex("Created_Using_Template_Index");
final PropertyKey propertyKey = management.getPropertyKey("Created_Using_Template");
assertNotNull(index);
assertNotNull(propertyKey);
assertEquals(ENABLED, index.getIndexStatus(propertyKey));
management.commit();
}
Aggregations