List of usage examples for org.apache.commons.configuration MapConfiguration MapConfiguration
public MapConfiguration(Map map)
From source file:org.apache.tinkerpop.gremlin.tinkergraph.process.TinkerGraphComputerProvider.java
@Override public GraphTraversalSource traversal(final Graph graph) { return RANDOM.nextBoolean() ? graph.traversal() .withStrategies(VertexProgramStrategy.create(new MapConfiguration(new HashMap<String, Object>() { {//from ww w. ja v a 2 s .co m put(VertexProgramStrategy.WORKERS, RANDOM.nextInt(Runtime.getRuntime().availableProcessors()) + 1); put(VertexProgramStrategy.GRAPH_COMPUTER, RANDOM.nextBoolean() ? GraphComputer.class.getCanonicalName() : TinkerGraphComputer.class.getCanonicalName()); } }))) : graph.traversal(GraphTraversalSource.computer()); }
From source file:org.apache.tinkerpop.gremlin.tinkergraph.process.traversal.strategy.decoration.HaltedTraverserStrategyTest.java
@Test public void shouldReturnDetachedElements() { final Graph graph = TinkerFactory.createModern(); final GraphTraversalSource g = graph.traversal().withComputer() .withStrategies(HaltedTraverserStrategy.create(new MapConfiguration(new HashMap<String, Object>() { {/* w w w . ja v a 2 s. c om*/ put(HaltedTraverserStrategy.HALTED_TRAVERSER_FACTORY, DetachedFactory.class.getCanonicalName()); } }))); g.V().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass())); g.V().out().properties("name").forEachRemaining( vertexProperty -> assertEquals(DetachedVertexProperty.class, vertexProperty.getClass())); g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass())); g.V().out().outE().forEachRemaining(edge -> assertEquals(DetachedEdge.class, edge.getClass())); g.V().out().outE().properties("weight") .forEachRemaining(property -> assertEquals(DetachedProperty.class, property.getClass())); g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass())); g.V().out().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass())); g.V().out().out().path().forEachRemaining(path -> assertEquals(DetachedPath.class, path.getClass())); g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass())); g.V().out().pageRank().out() .forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass())); }
From source file:org.debux.webmotion.server.ConfigurationTest.java
@Test public void testMap() throws ConfigurationException { Map<String, Object> map = new HashMap<String, Object>(); map.put("test", "10"); map.put("var", "${test}"); MapConfiguration configuration = new MapConfiguration(map); AssertJUnit.assertEquals(10, configuration.getInt("test")); AssertJUnit.assertEquals(10, configuration.getInt("var")); }
From source file:org.hawkular.inventory.impl.tinkerpop.provider.TinkerGraphProvider.java
@Override public WrappedTinkerGraph instantiateGraph(Configuration configuration) { return new WrappedTinkerGraph(new MapConfiguration( configuration.getImplementationConfiguration(Collections.singleton(PropertyKey.DIRECTORY_NAME)))); }
From source file:org.hawkular.inventory.impl.tinkerpop.provider.TitanProvider.java
@Override public TitanGraph instantiateGraph(Configuration configuration) { return TitanFactory.open(new MapConfiguration(configuration.prefixedWith(ALLOWED_PREFIXES) .getImplementationConfiguration(EnumSet.allOf(PropertyKeys.class)))); }
From source file:org.hawkular.inventory.impl.tinkerpop.sql.impl.SqlGraph.java
public SqlGraph(Map<String, Object> configuration) throws Exception { this(new MapConfiguration(configuration)); }
From source file:org.hawkular.inventory.impl.tinkerpop.sql.SqlGraphProvider.java
@Override public SqlGraph instantiateGraph(Configuration configuration) { try {// w w w. j av a 2s.c o m Map<String, String> conf = configuration.prefixedWith("sql.") .getImplementationConfiguration(sysPropsAsProperties()); String jndi = conf.get("sql.datasource.jndi"); if (jndi == null || jndi.isEmpty()) { Log.LOG.iUsingJdbcUrl(conf.get("sql.datasource.url")); return new SqlGraph(new MapConfiguration(conf)); } else { InitialContext ctx = new InitialContext(); DataSource ds = (DataSource) ctx.lookup(jndi); Log.LOG.iUsingDatasource(jndi); return new SqlGraph(ds, new MapConfiguration(conf)); } } catch (Exception e) { throw new IllegalArgumentException("Could not instantiate the SQL graph.", e); } }
From source file:org.janusgraph.core.ConfiguredGraphFactory.java
/** * Creates a {@link JanusGraph} configuration stored in the {@link ConfigurationManagementGraph} * graph and a {@link JanusGraph} graph reference according to the single * Template Configuration previously created by the {@link ConfigurationManagementGraph} API; * A configuration for this graph must not already exist, and a Template Configuration must * exist. If the Template Configuration does not include its * backend's respective keyspace/table/storage_directory parameter, we set the keyspace/table * to the supplied graphName or we append the graphName to the supplied * storage_root parameter.//from w ww. j a v a 2 s .co m * * @param graphName * * @return JanusGraph */ public static synchronized JanusGraph create(final String graphName) { final ConfigurationManagementGraph configManagementGraph = getConfigGraphManagementInstance(); final Map<String, Object> graphConfigMap = configManagementGraph.getConfiguration(graphName); Preconditions.checkState(null == graphConfigMap, String.format("Configuration for graph %s already exists.", graphName)); final Map<String, Object> templateConfigMap = configManagementGraph.getTemplateConfiguration(); Preconditions.checkState(null != templateConfigMap, "Please create a template Configuration using the ConfigurationManagementGraph#createTemplateConfiguration API."); templateConfigMap.put(ConfigurationManagementGraph.PROPERTY_GRAPH_NAME, graphName); templateConfigMap.put(ConfigurationManagementGraph.PROPERTY_CREATED_USING_TEMPLATE, true); final JanusGraphManager jgm = JanusGraphManagerUtility.getInstance(); Preconditions.checkState(jgm != null, JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG); final CommonsConfiguration config = new CommonsConfiguration(new MapConfiguration(templateConfigMap)); final JanusGraph g = (JanusGraph) jgm.openGraph(graphName, (String gName) -> new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(config))); configManagementGraph.createConfiguration(new MapConfiguration(templateConfigMap)); return g; }
From source file:org.janusgraph.core.ConfiguredGraphFactory.java
/** * Open a {@link JanusGraph} using a previously created Configuration using the * {@link ConfigurationManagementGraph} API. A corresponding configuration must exist. * * <p>NOTE: If your configuration corresponding to this graph does not contain information about * the backend's keyspace/table/storage directory, then we set the keyspace/table to the * graphName or set the storage directory to the storage_root + /graphName.</p> * * @param graphName/* www. j a v a 2s . c o m*/ * * @return JanusGraph */ public static JanusGraph open(String graphName) { final ConfigurationManagementGraph configManagementGraph = getConfigGraphManagementInstance(); final Map<String, Object> graphConfigMap = configManagementGraph.getConfiguration(graphName); Preconditions.checkState(null != graphConfigMap, "Please create configuration for this graph using the ConfigurationManagementGraph#createConfiguration API."); final JanusGraphManager jgm = JanusGraphManagerUtility.getInstance(); Preconditions.checkState(jgm != null, JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG); final CommonsConfiguration config = new CommonsConfiguration(new MapConfiguration(graphConfigMap)); return (JanusGraph) jgm.openGraph(graphName, (String gName) -> new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(config))); }
From source file:org.janusgraph.core.ConfiguredGraphFactoryTest.java
@Test public void shouldOpenGraphUsingConfiguration() throws Exception { try {// w w w . j a v a 2s. com 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"); } }