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();
}
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());
}
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();
}
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();
}
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"));
}
Aggregations