Search in sources :

Example 6 with StandardJanusGraph

use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.

the class ConfiguredGraphFactoryTest method graphConfigurationShouldBeWhatWeExpect.

@Test
public void graphConfigurationShouldBeWhatWeExpect() throws Exception {
    try {
        final Map<String, Object> map = new HashMap<>();
        map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
        map.put(GRAPH_NAME.toStringWithoutRoot(), "graph1");
        ConfiguredGraphFactory.createConfiguration(new MapConfiguration(map));
        final StandardJanusGraph graph = (StandardJanusGraph) ConfiguredGraphFactory.open("graph1");
        assertNotNull(graph);
        assertEquals("graph1", graph.getConfiguration().getConfiguration().get(GRAPH_NAME));
        assertEquals("inmemory", graph.getConfiguration().getConfiguration().get(STORAGE_BACKEND));
    } finally {
        ConfiguredGraphFactory.removeConfiguration("graph1");
        ConfiguredGraphFactory.close("graph1");
    }
}
Also used : HashMap(java.util.HashMap) MapConfiguration(org.apache.commons.configuration.MapConfiguration) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Test(org.junit.Test)

Example 7 with StandardJanusGraph

use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.

the class ConfiguredGraphFactoryTest method shouldOpenGraphUsingConfiguration.

@Test
public void shouldOpenGraphUsingConfiguration() throws Exception {
    try {
        final Map<String, Object> map = new HashMap<>();
        map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
        map.put(GRAPH_NAME.toStringWithoutRoot(), "graph1");
        ConfiguredGraphFactory.createConfiguration(new MapConfiguration(map));
        final StandardJanusGraph graph = (StandardJanusGraph) ConfiguredGraphFactory.open("graph1");
        assertNotNull(graph);
    } finally {
        ConfiguredGraphFactory.removeConfiguration("graph1");
        ConfiguredGraphFactory.close("graph1");
    }
}
Also used : HashMap(java.util.HashMap) MapConfiguration(org.apache.commons.configuration.MapConfiguration) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Test(org.junit.Test)

Example 8 with StandardJanusGraph

use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.

the class GraphDatabaseConfigurationInstanceIdTest method instanceIdShouldEqualHostnamePlusSuffix.

@Test
public void instanceIdShouldEqualHostnamePlusSuffix() 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);
    map.put(UNIQUE_INSTANCE_ID_SUFFIX.toStringWithoutRoot(), 1);
    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() + "1");
    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 9 with StandardJanusGraph

use of org.janusgraph.graphdb.database.StandardJanusGraph 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 10 with StandardJanusGraph

use of org.janusgraph.graphdb.database.StandardJanusGraph 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)

Aggregations

StandardJanusGraph (org.janusgraph.graphdb.database.StandardJanusGraph)29 Test (org.junit.Test)18 MapConfiguration (org.apache.commons.configuration.MapConfiguration)16 HashMap (java.util.HashMap)14 GraphDatabaseConfiguration (org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration)11 CommonsConfiguration (org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration)9 JanusGraphManagement (org.janusgraph.core.schema.JanusGraphManagement)4 JanusGraphManager (org.janusgraph.graphdb.management.JanusGraphManager)4 Graph (org.apache.tinkerpop.gremlin.structure.Graph)3 JanusGraphTransaction (org.janusgraph.core.JanusGraphTransaction)3 PropertyKey (org.janusgraph.core.PropertyKey)3 Instant (java.time.Instant)2 JanusGraph (org.janusgraph.core.JanusGraph)2 JanusGraphIndex (org.janusgraph.core.schema.JanusGraphIndex)2 Backend (org.janusgraph.diskstorage.Backend)2 TimestampProvider (org.janusgraph.diskstorage.util.time.TimestampProvider)2 ManagementSystem (org.janusgraph.graphdb.database.management.ManagementSystem)2 ElementCategory (org.janusgraph.graphdb.internal.ElementCategory)2 GraknTxJanus (ai.grakn.kb.internal.GraknTxJanus)1 Preconditions (com.google.common.base.Preconditions)1