Search in sources :

Example 21 with ManagementSystem

use of org.janusgraph.graphdb.database.management.ManagementSystem 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"));
}
Also used : ManagementSystem(org.janusgraph.graphdb.database.management.ManagementSystem) GraphDatabaseConfigurationBuilder(org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder) HashMap(java.util.HashMap) MapConfiguration(org.apache.commons.configuration2.MapConfiguration) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) Settings(org.apache.tinkerpop.gremlin.server.Settings) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Test(org.junit.jupiter.api.Test)

Aggregations

ManagementSystem (org.janusgraph.graphdb.database.management.ManagementSystem)21 JanusGraph (org.janusgraph.core.JanusGraph)17 HashMap (java.util.HashMap)16 CredentialGraph (org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraph)14 Transaction (org.apache.tinkerpop.gremlin.structure.Transaction)14 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)12 Test (org.junit.Test)10 PropertyKey (org.janusgraph.core.PropertyKey)6 SimpleAuthenticator (org.apache.tinkerpop.gremlin.server.auth.SimpleAuthenticator)5 JanusGraphIndex (org.janusgraph.core.schema.JanusGraphIndex)5 Test (org.junit.jupiter.api.Test)4 JanusGraphManagement (org.janusgraph.core.schema.JanusGraphManagement)3 PropertyKeyMaker (org.janusgraph.core.schema.PropertyKeyMaker)3 StandardJanusGraph (org.janusgraph.graphdb.database.StandardJanusGraph)3 MapConfiguration (org.apache.commons.configuration2.MapConfiguration)2 AuthenticationException (org.apache.tinkerpop.gremlin.server.auth.AuthenticationException)2 CommonsConfiguration (org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration)2 GraphDatabaseConfigurationBuilder (org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder)2 JanusGraphManager (org.janusgraph.graphdb.management.JanusGraphManager)2 Settings (org.apache.tinkerpop.gremlin.server.Settings)1