List of usage examples for org.apache.commons.configuration MapConfiguration MapConfiguration
public MapConfiguration(Map map)
From source file:org.janusgraph.core.ConfiguredGraphFactoryTest.java
@Test public void ensureCallingGraphCloseResultsInNewGraphReferenceOnNextCallToOpen() throws Exception { try {/*from www . j a v a 2s .c o m*/ final Map<String, Object> map = new HashMap<>(); map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory"); ConfiguredGraphFactory.createTemplateConfiguration(new MapConfiguration(map)); final StandardJanusGraph graph = (StandardJanusGraph) ConfiguredGraphFactory.create("graph1"); assertNotNull(graph); assertEquals("graph1", graph.getConfiguration().getConfiguration().get(GRAPH_NAME)); graph.close(); assertTrue(graph.isClosed()); final StandardJanusGraph newGraph = (StandardJanusGraph) ConfiguredGraphFactory.open("graph1"); assertFalse(newGraph.isClosed()); } finally { ConfiguredGraphFactory.removeConfiguration("graph1"); ConfiguredGraphFactory.close("graph1"); } }
From source file:org.janusgraph.graphdb.GraphDatabaseConfigurationInstanceIdTest.java
@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 GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config))); assertEquals(graph1.openManagement().getOpenInstances().size(), 1); assertEquals(graph1.openManagement().getOpenInstances().toArray()[0], "not-unique"); final StandardJanusGraph graph2 = new StandardJanusGraph( new GraphDatabaseConfigurationBuilder().build(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();/*from w w w.ja va 2 s. co m*/ graph2.close(); }
From source file:org.janusgraph.graphdb.GraphDatabaseConfigurationInstanceIdTest.java
@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 GraphDatabaseConfigurationBuilder().build(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));//w w w . j a v a2 s . co m final StandardJanusGraph graph2 = new StandardJanusGraph( new GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config))); graph1.close(); }
From source file:org.janusgraph.graphdb.GraphDatabaseConfigurationInstanceIdTest.java
@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 GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config))); assertEquals(graph.openManagement().getOpenInstances().size(), 1); assertEquals(graph.openManagement().getOpenInstances().toArray()[0], Inet4Address.getLocalHost().getHostName()); graph.close();/*from w w w . j a v a 2 s .c o m*/ }
From source file:org.janusgraph.graphdb.GraphDatabaseConfigurationInstanceIdTest.java
@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 GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config))); assertEquals(graph.openManagement().getOpenInstances().size(), 1); assertEquals(graph.openManagement().getOpenInstances().toArray()[0], Inet4Address.getLocalHost().getHostName() + "1"); graph.close();/*www . ja v a2 s. c om*/ }
From source file:org.janusgraph.graphdb.management.ConfigurationManagementGraphTest.java
@Test public void shouldReindexIfPropertyKeyExists() throws Exception { final JanusGraphManager gm = new JanusGraphManager(new Settings()); 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 GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config))); final String propertyKeyName = "Created_Using_Template"; final Class dataType = Boolean.class; JanusGraphManagement management = graph.openManagement(); final PropertyKey key = management.makePropertyKey(propertyKeyName).dataType(dataType).make(); management.commit();//from w w w .jav a 2 s . c o m // Instantiate the ConfigurationManagementGraph Singleton // This is purposefully done after a property key is created to ensure that a REDINDEX is initiated new ConfigurationManagementGraph(graph); management = graph.openManagement(); final JanusGraphIndex index = management.getGraphIndex("Created_Using_Template_Index"); final PropertyKey propertyKey = management.getPropertyKey("Created_Using_Template"); assertNotNull(index); assertNotNull(propertyKey); assertEquals(ENABLED, index.getIndexStatus(propertyKey)); management.commit(); }
From source file:org.janusgraph.graphdb.management.ManagementLoggerGraphCacheEvictionTest.java
@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 GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config))); final ManagementSystem mgmt = (ManagementSystem) graph.openManagement(); mgmt.evictGraphFromCache();// w ww. jav a2s .c o m mgmt.commit(); assertNull(JanusGraphManager.getInstance()); }
From source file:org.janusgraph.graphdb.management.ManagementLoggerGraphCacheEvictionTest.java
@Test public void graphShouldBeRemovedFromCache() throws InterruptedException { final JanusGraphManager jgm = new JanusGraphManager(new Settings()); assertNotNull(jgm);//from ww w . jav a2 s .c o m 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 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")); }
From source file:org.jbake.maven.GenerateMojo.java
protected JBakeConfiguration createConfiguration() throws ConfigurationException { JBakeConfigurationFactory jbakeConfigurationFactory = new JBakeConfigurationFactory(); // load base config (cast to DefaultJBakeConfig) DefaultJBakeConfiguration baseConfiguration = (DefaultJBakeConfiguration) jbakeConfigurationFactory .getConfigUtil().loadConfig(inputDirectory); final CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(baseConfiguration.getCompositeConfiguration()); config.addConfiguration(new MapConfiguration(this.project.getProperties())); return jbakeConfigurationFactory.createDefaultJbakeConfiguration(inputDirectory, outputDirectory, config, isClearCache);/*from w w w . java 2s . com*/ }
From source file:org.matsim.contrib.taxi.optimizer.DefaultTaxiOptimizerProvider.java
@Override public TaxiOptimizer get() { Configuration optimizerConfig = new MapConfiguration(taxiCfg.getOptimizerConfigGroup().getParams()); OptimizerType type = OptimizerType.valueOf(optimizerConfig.getString(TYPE)); switch (type) { case ASSIGNMENT: return new AssignmentTaxiOptimizer(taxiCfg, fleet, network, timer, travelTime, travelDisutility, scheduler, new AssignmentTaxiOptimizerParams(optimizerConfig)); case FIFO:/*w ww .ja v a2s . c om*/ return new FifoTaxiOptimizer(taxiCfg, fleet, network, timer, travelTime, travelDisutility, scheduler, new FifoTaxiOptimizerParams(optimizerConfig)); case RULE_BASED: return RuleBasedTaxiOptimizer.create(taxiCfg, fleet, scheduler, network, timer, travelTime, travelDisutility, new RuleBasedTaxiOptimizerParams(optimizerConfig)); case ZONAL: return ZonalTaxiOptimizer.create(taxiCfg, fleet, scheduler, network, timer, travelTime, travelDisutility, new ZonalTaxiOptimizerParams(optimizerConfig)); default: throw new IllegalStateException(); } }