Search in sources :

Example 26 with MapConfiguration

use of org.apache.commons.configuration2.MapConfiguration in project janusgraph by JanusGraph.

the class GraphDatabaseConfigurationInstanceExecutorServiceTest method shouldCreateCustomBackendExecutorServiceWithExecutorServiceConfigurationConstructor.

@Test
public void shouldCreateCustomBackendExecutorServiceWithExecutorServiceConfigurationConstructor() {
    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_CORE_POOL_SIZE.toStringWithoutRoot(), 15);
    map.put(PARALLEL_BACKEND_EXECUTOR_SERVICE_CLASS.toStringWithoutRoot(), CustomExecutorServiceImplementation.class.getName());
    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 27 with MapConfiguration

use of org.apache.commons.configuration2.MapConfiguration in project janusgraph by JanusGraph.

the class GraphDatabaseConfigurationInstanceExecutorServiceTest method checkExceptionIsThrownDuringInit.

private <T extends Exception> void checkExceptionIsThrownDuringInit(Class<T> exceptionType, Map<String, Object> configMap, String message) {
    final MapConfiguration config = ConfigurationUtil.loadMapConfiguration(configMap);
    T exception = assertThrows(exceptionType, () -> {
        final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config)));
        graph.traversal().V().hasNext();
        graph.close();
    });
    assertEquals(message, exception.getMessage());
}
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)

Example 28 with MapConfiguration

use of org.apache.commons.configuration2.MapConfiguration in project janusgraph by JanusGraph.

the class EnsureCacheTest method NopTest.

@Test
public void NopTest() {
    final Map<String, Object> map = new HashMap<>();
    map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
    final MapConfiguration config = ConfigurationUtil.loadMapConfiguration(map);
    final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config)));
    graph.traversal().addV().iterate();
}
Also used : GraphDatabaseConfigurationBuilder(org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder) HashMap(java.util.HashMap) 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 29 with MapConfiguration

use of org.apache.commons.configuration2.MapConfiguration in project janusgraph by JanusGraph.

the class CQLConfiguredGraphFactoryTest method dropGraphShouldRemoveGraphKeyspace.

@Test
public void dropGraphShouldRemoveGraphKeyspace() 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.drop(graphName);
        Session cql = cqlContainer.getCluster().connect();
        Object graph_keyspace = cql.execute("SELECT * FROM system_schema.keyspaces WHERE keyspace_name = ?", graphName).one();
        cql.close();
        assertNull(graph_keyspace);
    } finally {
        ConfiguredGraphFactory.removeConfiguration(graphName);
        ConfiguredGraphFactory.close(graphName);
    }
}
Also used : MapConfiguration(org.apache.commons.configuration2.MapConfiguration) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Session(com.datastax.driver.core.Session) Test(org.junit.jupiter.api.Test) AbstractConfiguredGraphFactoryTest(org.janusgraph.core.AbstractConfiguredGraphFactoryTest)

Example 30 with MapConfiguration

use of org.apache.commons.configuration2.MapConfiguration 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

MapConfiguration (org.apache.commons.configuration2.MapConfiguration)34 StandardJanusGraph (org.janusgraph.graphdb.database.StandardJanusGraph)25 Test (org.junit.jupiter.api.Test)25 CommonsConfiguration (org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration)16 GraphDatabaseConfigurationBuilder (org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder)16 HashMap (java.util.HashMap)6 JanusGraphManager (org.janusgraph.graphdb.management.JanusGraphManager)3 Test (org.testng.annotations.Test)3 Configuration (org.apache.commons.configuration2.Configuration)2 Settings (org.apache.tinkerpop.gremlin.server.Settings)2 AbstractConfiguredGraphFactoryTest (org.janusgraph.core.AbstractConfiguredGraphFactoryTest)2 ManagementSystem (org.janusgraph.graphdb.database.management.ManagementSystem)2 ConfigurationManagementGraph (org.janusgraph.graphdb.management.ConfigurationManagementGraph)2 Session (com.datastax.driver.core.Session)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Bindings (javax.script.Bindings)1 SimpleBindings (javax.script.SimpleBindings)1 CompositeConfiguration (org.apache.commons.configuration2.CompositeConfiguration)1 JanusGraphException (org.janusgraph.core.JanusGraphException)1 PropertyKey (org.janusgraph.core.PropertyKey)1