Search in sources :

Example 51 with StandardJanusGraph

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

the class GraphDatabaseConfigurationInstanceExecutorServiceTest method shouldCreateCustomBackendCachedThreadPoolSize.

@Test
public void shouldCreateCustomBackendCachedThreadPoolSize() {
    final Map<String, Object> map = getStorageConfiguration();
    map.put(UNIQUE_INSTANCE_ID_HOSTNAME.toStringWithoutRoot(), true);
    map.put(PARALLEL_BACKEND_OPS.toStringWithoutRoot(), true);
    map.put(PARALLEL_BACKEND_EXECUTOR_SERVICE_CLASS.toStringWithoutRoot(), ExecutorServiceBuilder.CACHED_THREAD_POOL_CLASS);
    map.put(PARALLEL_BACKEND_EXECUTOR_SERVICE_CORE_POOL_SIZE.toStringWithoutRoot(), 15);
    map.put(PARALLEL_BACKEND_EXECUTOR_SERVICE_KEEP_ALIVE_TIME.toStringWithoutRoot(), 30000);
    final MapConfiguration config = ConfigurationUtil.loadMapConfiguration(map);
    assertDoesNotThrow(() -> {
        final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config)));
        graph.traversal().V().hasNext();
        graph.close();
    });
}
Also used : GraphDatabaseConfigurationBuilder(org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder) MapConfiguration(org.apache.commons.configuration2.MapConfiguration) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Test(org.junit.jupiter.api.Test)

Example 52 with StandardJanusGraph

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

the class AbstractConfiguredGraphFactoryTest method shouldOpenGraphUsingConfiguration.

@Test
public void shouldOpenGraphUsingConfiguration() throws Exception {
    final MapConfiguration graphConfig = getGraphConfig();
    final String graphName = graphConfig.getString(GRAPH_NAME.toStringWithoutRoot());
    try {
        ConfiguredGraphFactory.createConfiguration(graphConfig);
        final StandardJanusGraph graph = (StandardJanusGraph) ConfiguredGraphFactory.open(graphName);
        assertNotNull(graph);
    } finally {
        ConfiguredGraphFactory.removeConfiguration(graphName);
        ConfiguredGraphFactory.close(graphName);
    }
}
Also used : MapConfiguration(org.apache.commons.configuration2.MapConfiguration) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Test(org.junit.jupiter.api.Test)

Example 53 with StandardJanusGraph

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

the class AbstractConfiguredGraphFactoryTest method dropShouldCleanUpTraversalSourceAndBindings.

@Test
public void dropShouldCleanUpTraversalSourceAndBindings() throws Exception {
    final MapConfiguration graphConfig = getGraphConfig();
    final String graphName = graphConfig.getString(GRAPH_NAME.toStringWithoutRoot());
    final String graphNameTraversal = graphName + "_traversal";
    try {
        ConfiguredGraphFactory.createConfiguration(graphConfig);
        final JanusGraphManager jgm = JanusGraphManager.getInstance();
        final Bindings bindings = new SimpleBindings();
        jgm.configureGremlinExecutor(mockGremlinExecutor(bindings));
        final StandardJanusGraph graph = (StandardJanusGraph) ConfiguredGraphFactory.open(graphName);
        jgm.putTraversalSource(ConfiguredGraphFactory.toTraversalSourceName(graphName), graph.traversal());
        assertNotNull(jgm.getGraph(graphName));
        assertEquals(ConfiguredGraphFactory.toTraversalSourceName(graphName), jgm.getTraversalSourceNames().iterator().next());
        // Confirm the graph and traversal source were added to the Gremlin Script Engine bindings
        assertTrue(bindings.containsKey(graphName));
        assertTrue(bindings.containsKey(graphNameTraversal));
        // Drop the graph and confirm that the graph and traversal source
        ConfiguredGraphFactory.drop(graphName);
        assertNull(jgm.getGraph(graphName));
        assertTrue(jgm.getTraversalSourceNames().isEmpty());
        // Confirm the graph and traversal source were removed from the Gremlin Script Engine bindings
        assertFalse(bindings.containsKey(graphName));
        assertFalse(bindings.containsKey(graphNameTraversal));
    } finally {
        ConfiguredGraphFactory.removeConfiguration(graphName);
        ConfiguredGraphFactory.close(graphName);
    }
}
Also used : SimpleBindings(javax.script.SimpleBindings) MapConfiguration(org.apache.commons.configuration2.MapConfiguration) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager) Bindings(javax.script.Bindings) SimpleBindings(javax.script.SimpleBindings) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Test(org.junit.jupiter.api.Test)

Example 54 with StandardJanusGraph

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

the class AbstractConfiguredGraphFactoryTest method shouldCreateTwoGraphsUsingSameTemplateConfiguration.

@Test
public void shouldCreateTwoGraphsUsingSameTemplateConfiguration() throws Exception {
    try {
        ConfiguredGraphFactory.createTemplateConfiguration(getTemplateConfig());
        final StandardJanusGraph graph1 = (StandardJanusGraph) ConfiguredGraphFactory.create("graph1");
        final StandardJanusGraph graph2 = (StandardJanusGraph) ConfiguredGraphFactory.create("graph2");
        assertNotNull(graph1);
        assertNotNull(graph2);
        assertEquals("graph1", graph1.getConfiguration().getConfiguration().get(GRAPH_NAME));
        assertEquals("graph2", graph2.getConfiguration().getConfiguration().get(GRAPH_NAME));
    } finally {
        ConfiguredGraphFactory.removeConfiguration("graph1");
        ConfiguredGraphFactory.removeConfiguration("graph2");
        ConfiguredGraphFactory.close("graph1");
        ConfiguredGraphFactory.close("graph2");
    }
}
Also used : StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Test(org.junit.jupiter.api.Test)

Example 55 with StandardJanusGraph

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

the class AbstractConfiguredGraphFactoryTest method removeConfigurationShouldRemoveGraphFromCache.

@Test
public void removeConfigurationShouldRemoveGraphFromCache() throws Exception {
    final MapConfiguration graphConfig = getGraphConfig();
    final String graphName = graphConfig.getString(GRAPH_NAME.toStringWithoutRoot());
    try {
        ConfiguredGraphFactory.createConfiguration(graphConfig);
        final StandardJanusGraph graph = (StandardJanusGraph) ConfiguredGraphFactory.open(graphName);
        assertNotNull(graph);
        ConfiguredGraphFactory.removeConfiguration(graphName);
        assertNull(gm.getGraph(graphName));
    } finally {
        ConfiguredGraphFactory.removeConfiguration(graphName);
        ConfiguredGraphFactory.close(graphName);
    }
}
Also used : MapConfiguration(org.apache.commons.configuration2.MapConfiguration) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Test(org.junit.jupiter.api.Test)

Aggregations

StandardJanusGraph (org.janusgraph.graphdb.database.StandardJanusGraph)68 Test (org.junit.jupiter.api.Test)38 MapConfiguration (org.apache.commons.configuration2.MapConfiguration)25 CommonsConfiguration (org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration)18 GraphDatabaseConfigurationBuilder (org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder)18 HashMap (java.util.HashMap)13 JanusGraphManagement (org.janusgraph.core.schema.JanusGraphManagement)9 Test (org.junit.Test)9 MapConfiguration (org.apache.commons.configuration.MapConfiguration)8 JanusGraphManager (org.janusgraph.graphdb.management.JanusGraphManager)8 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)6 GraphDatabaseConfiguration (org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration)6 PropertyKey (org.janusgraph.core.PropertyKey)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 Graph (org.apache.tinkerpop.gremlin.structure.Graph)4 Backend (org.janusgraph.diskstorage.Backend)4 WriteConfiguration (org.janusgraph.diskstorage.configuration.WriteConfiguration)4 TimestampProvider (org.janusgraph.diskstorage.util.time.TimestampProvider)4 StandardJanusGraphTx (org.janusgraph.graphdb.transaction.StandardJanusGraphTx)4 JanusGraph (org.janusgraph.core.JanusGraph)3