Search in sources :

Example 6 with GraphDatabaseConfiguration

use of org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration in project janusgraph by JanusGraph.

the class GraphDatabaseConfigurationInstanceIdTest method instanceIdShouldEqualHostname.

@Test
public void instanceIdShouldEqualHostname() throws UnknownHostException {
    final Map<String, Object> map = new HashMap<String, Object>();
    map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
    map.put(UNIQUE_INSTANCE_ID_HOSTNAME.toStringWithoutRoot(), true);
    final MapConfiguration config = new MapConfiguration(map);
    final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfiguration(new CommonsConfiguration(config)));
    assertEquals(graph.openManagement().getOpenInstances().size(), 1);
    assertEquals(graph.openManagement().getOpenInstances().toArray()[0], Inet4Address.getLocalHost().getHostName());
    graph.close();
}
Also used : HashMap(java.util.HashMap) MapConfiguration(org.apache.commons.configuration.MapConfiguration) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Test(org.junit.Test)

Example 7 with GraphDatabaseConfiguration

use of org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration in project janusgraph by JanusGraph.

the class ManagementLoggerGraphCacheEvictionTest method shouldNotBeAbleToEvictGraphWhenJanusGraphManagerIsNull.

@Test
public void shouldNotBeAbleToEvictGraphWhenJanusGraphManagerIsNull() {
    final Map<String, Object> map = new HashMap<>();
    map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
    final MapConfiguration config = new MapConfiguration(map);
    final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfiguration(new CommonsConfiguration(config)));
    final ManagementSystem mgmt = (ManagementSystem) graph.openManagement();
    mgmt.evictGraphFromCache();
    mgmt.commit();
    assertNull(JanusGraphManager.getInstance());
}
Also used : ManagementSystem(org.janusgraph.graphdb.database.management.ManagementSystem) HashMap(java.util.HashMap) MapConfiguration(org.apache.commons.configuration.MapConfiguration) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Test(org.junit.Test)

Example 8 with GraphDatabaseConfiguration

use of org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration in project janusgraph by JanusGraph.

the class GraphDatabaseConfigurationInstanceIdTest method graphShouldNotOpenWithSameInstanceId.

@Test
public void graphShouldNotOpenWithSameInstanceId() {
    final Map<String, Object> map = new HashMap<String, Object>();
    map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
    map.put(UNIQUE_INSTANCE_ID.toStringWithoutRoot(), "not-unique");
    final MapConfiguration config = new MapConfiguration(map);
    final StandardJanusGraph graph1 = new StandardJanusGraph(new GraphDatabaseConfiguration(new CommonsConfiguration(config)));
    assertEquals(graph1.openManagement().getOpenInstances().size(), 1);
    assertEquals(graph1.openManagement().getOpenInstances().toArray()[0], "not-unique");
    thrown.expect(JanusGraphException.class);
    final String err = "A JanusGraph graph with the same instance id [not-unique] is already open. Might required forced shutdown.";
    thrown.expectMessage(equalTo(err));
    final StandardJanusGraph graph2 = new StandardJanusGraph(new GraphDatabaseConfiguration(new CommonsConfiguration(config)));
    graph1.close();
}
Also used : HashMap(java.util.HashMap) MapConfiguration(org.apache.commons.configuration.MapConfiguration) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Test(org.junit.Test)

Example 9 with GraphDatabaseConfiguration

use of org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration in project janusgraph by JanusGraph.

the class GraphDatabaseConfigurationInstanceIdTest method graphShouldOpenWithSameInstanceId.

@Test
public void graphShouldOpenWithSameInstanceId() {
    final Map<String, Object> map = new HashMap<String, Object>();
    map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
    map.put(UNIQUE_INSTANCE_ID.toStringWithoutRoot(), "not-unique");
    map.put(REPLACE_INSTANCE_IF_EXISTS.toStringWithoutRoot(), true);
    final MapConfiguration config = new MapConfiguration(map);
    final StandardJanusGraph graph1 = new StandardJanusGraph(new GraphDatabaseConfiguration(new CommonsConfiguration(config)));
    assertEquals(graph1.openManagement().getOpenInstances().size(), 1);
    assertEquals(graph1.openManagement().getOpenInstances().toArray()[0], "not-unique");
    final StandardJanusGraph graph2 = new StandardJanusGraph(new GraphDatabaseConfiguration(new CommonsConfiguration(config)));
    assertEquals(graph1.openManagement().getOpenInstances().size(), 1);
    assertEquals(graph1.openManagement().getOpenInstances().toArray()[0], "not-unique");
    assertEquals(graph2.openManagement().getOpenInstances().size(), 1);
    assertEquals(graph2.openManagement().getOpenInstances().toArray()[0], "not-unique");
    graph1.close();
    graph2.close();
}
Also used : HashMap(java.util.HashMap) MapConfiguration(org.apache.commons.configuration.MapConfiguration) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Test(org.junit.Test)

Example 10 with GraphDatabaseConfiguration

use of org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration 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 = new MapConfiguration(map);
    final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfiguration(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) HashMap(java.util.HashMap) MapConfiguration(org.apache.commons.configuration.MapConfiguration) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) Settings(org.apache.tinkerpop.gremlin.server.Settings) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Test(org.junit.Test)

Aggregations

GraphDatabaseConfiguration (org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration)13 StandardJanusGraph (org.janusgraph.graphdb.database.StandardJanusGraph)11 CommonsConfiguration (org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration)9 MapConfiguration (org.apache.commons.configuration.MapConfiguration)8 HashMap (java.util.HashMap)6 Test (org.junit.Test)6 JanusGraphManager (org.janusgraph.graphdb.management.JanusGraphManager)4 Backend (org.janusgraph.diskstorage.Backend)2 ManagementSystem (org.janusgraph.graphdb.database.management.ManagementSystem)2 ConfigurationManagementGraph (org.janusgraph.graphdb.management.ConfigurationManagementGraph)2 Preconditions (com.google.common.base.Preconditions)1 Iterators (com.google.common.collect.Iterators)1 File (java.io.File)1 Instant (java.time.Instant)1 java.util (java.util)1 Pattern (java.util.regex.Pattern)1 BaseConfiguration (org.apache.commons.configuration.BaseConfiguration)1 Configuration (org.apache.commons.configuration.Configuration)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)1