List of usage examples for org.apache.commons.configuration CompositeConfiguration addConfiguration
public void addConfiguration(Configuration config)
From source file:org.apache.whirr.service.pig.integration.PigServiceTest.java
@BeforeClass public static void setUp() throws Exception { CompositeConfiguration config = new CompositeConfiguration(); if (System.getProperty("config") != null) { config.addConfiguration(new PropertiesConfiguration(System.getProperty("config"))); }//from w ww. j a v a 2 s . c o m config.addConfiguration(new PropertiesConfiguration("whirr-pig-test.properties")); clusterSpec = ClusterSpec.withTemporaryKeys(config); controller = new ClusterController(); controller.launchCluster(clusterSpec); }
From source file:org.apache.whirr.service.puppet.integration.PuppetServiceTest.java
@Before public void setUp() throws Exception { CompositeConfiguration config = new CompositeConfiguration(); if (System.getProperty("config") != null) { config.addConfiguration(new PropertiesConfiguration(System.getProperty("config"))); }// w w w .j a v a2s . c o m config.addConfiguration(new PropertiesConfiguration("whirr-puppet-test.properties")); clusterSpec = ClusterSpec.withTemporaryKeys(config); controller = new ClusterController(); cluster = controller.launchCluster(clusterSpec); socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), 60, 1, TimeUnit.SECONDS); }
From source file:org.apache.whirr.service.solr.integration.SolrServiceTest.java
@BeforeClass public static void beforeClass() throws ConfigurationException, JSchException, IOException, InterruptedException { String solrConfigTarballDestination = "target/solrconfig.tar.gz"; Tarball.createFromDirectory("src/test/resources/conf", solrConfigTarballDestination); LOG.info("Created Solr config tarball at " + solrConfigTarballDestination); CompositeConfiguration config = new CompositeConfiguration(); if (System.getProperty("conf") != null) { config.addConfiguration(new PropertiesConfiguration(System.getProperty("conf"))); }// ww w. ja v a 2 s. co m config.addConfiguration(new PropertiesConfiguration("whirr-solr-test.properties")); clusterSpec = ClusterSpec.withTemporaryKeys(config); controller = new ClusterController(); cluster = controller.launchCluster(clusterSpec); }
From source file:org.apache.whirr.service.vblob.integration.VBlobServiceTest.java
@Before public void setUp() throws Exception { CompositeConfiguration config = new CompositeConfiguration(); if (System.getProperty("config") != null) { config.addConfiguration(new PropertiesConfiguration(System.getProperty("config"))); }/*from w w w .j a v a 2s. com*/ config.addConfiguration(new PropertiesConfiguration("whirr-vblob-test.properties")); config.addConfiguration(new PropertiesConfiguration("whirr-vblob-default.properties")); clusterSpec = ClusterSpec.withTemporaryKeys(config); vBlobConfig = new CommonsConfigurationToVBlobConfig("vblob", clusterSpec.getClusterUser()).apply(config); controller = new ClusterController(); cluster = controller.launchCluster(clusterSpec); }
From source file:org.apache.whirr.service.voldemort.integration.VoldemortServiceTest.java
@Before public void setUp() throws Exception { CompositeConfiguration config = new CompositeConfiguration(); if (System.getProperty("config") != null) { config.addConfiguration(new PropertiesConfiguration(System.getProperty("config"))); }/*from w w w . j av a2s. c o m*/ config.addConfiguration(new PropertiesConfiguration("whirr-voldemort-test.properties")); clusterSpec = ClusterSpec.withTemporaryKeys(config); controller = new ClusterController(); cluster = controller.launchCluster(clusterSpec); waitForBootstrap(); }
From source file:org.apache.whirr.service.yarn.integration.HadoopServiceController.java
public synchronized void startup() throws Exception { LOG.info("Starting up cluster..."); CompositeConfiguration config = new CompositeConfiguration(); if (System.getProperty("config") != null) { config.addConfiguration(new PropertiesConfiguration(System.getProperty("config"))); }//w w w.j a v a2s.co m config.addConfiguration(configuration); clusterSpec = ClusterSpec.withTemporaryKeys(config); controller = new ClusterController(); cluster = controller.launchCluster(clusterSpec); proxy = new HadoopProxy(clusterSpec, cluster); proxy.start(); Configuration conf = getConfiguration(); JobConf job = new JobConf(conf, HadoopServiceController.class); JobClient client = new JobClient(job); waitToExitSafeMode(client); waitForTaskTrackers(client); running = true; }
From source file:org.apache.whirr.service.zookeeper.integration.ZooKeeperServiceTest.java
@Before public void setUp() throws Exception { CompositeConfiguration config = new CompositeConfiguration(); if (System.getProperty("config") != null) { config.addConfiguration(new PropertiesConfiguration(System.getProperty("config"))); }//from ww w . j a v a 2s .co m config.addConfiguration(new PropertiesConfiguration("whirr-zookeeper-test.properties")); clusterSpec = ClusterSpec.withTemporaryKeys(config); controller = new ClusterControllerFactory().create(clusterSpec.getServiceName()); cluster = controller.launchCluster(clusterSpec); hosts = ZooKeeperCluster.getHosts(cluster); }
From source file:org.apereo.lap.services.ConfigurationService.java
@PostConstruct public void init() throws IOException { logger.info("INIT started"); logger.info("App Home: " + appHome().getAbsolutePath()); CompositeConfiguration config = new CompositeConfiguration(); // load internal config defaults first config.setProperty("app.name", "LAP"); File dbDefaults = resourceLoader.getResource("classpath:db.properties").getFile(); try {//from w w w . j a va2 s. c o m config.addConfiguration(new PropertiesConfiguration(dbDefaults)); } catch (ConfigurationException e) { logger.error("Unable to load default db.properties file"); } File appDefaults = resourceLoader.getResource("classpath:app.properties").getFile(); try { config.addConfiguration(new PropertiesConfiguration(appDefaults)); logger.info("Default app configuration loaded from: " + appDefaults.getAbsolutePath()); } catch (ConfigurationException e) { logger.error("Unable to load default app.properties file"); } // now try to load external config settings config.addConfiguration(new SystemConfiguration()); File lapConfigProps = new File(appHome(), "lap.properties"); if (lapConfigProps.exists() && lapConfigProps.canRead()) { try { config.addConfiguration(new PropertiesConfiguration(lapConfigProps)); } catch (ConfigurationException e) { logger.warn("Unable to load lap.properties file"); } } else { IOUtils.copy( SampleCSVInputHandlerService.class.getClassLoader() .getResourceAsStream("config" + SLASH + "lap.properties"), new FileOutputStream(new File(appHome(), "lap.properties"))); logger.info("No external LAP config found: " + lapConfigProps.getAbsolutePath() + ", copied default sample lap.properties"); } this.config = config; // verify the existence of the various dirs pipelinesDirectory = verifyDir("dir.pipelines", "piplines"); inputDirectory = verifyDir("dir.inputs", "inputs"); outputDirectory = verifyDir("dir.outputs", "outputs"); pipelineConfigs = new ConcurrentHashMap<>(); // first load the internal ones (must be listed explicitly for now) Resource pipelineSample = resourceLoader.getResource("classpath:pipelines" + SLASH + "sample.xml"); PipelineConfig plcfg = processPipelineConfigFile(pipelineSample.getFile()); if (plcfg != null) { pipelineConfigs.put(plcfg.getType(), plcfg); } // then try to load the external ones File[] pipelineFiles = pipelinesDirectory.listFiles(); if (pipelineFiles != null && pipelineFiles.length > 0) { for (final File fileEntry : pipelineFiles) { if (fileEntry.isFile()) { PipelineConfig filePLC = processPipelineConfigFile(pipelineSample.getFile()); if (filePLC != null) { pipelineConfigs.put(filePLC.getType(), filePLC); } } } } logger.info("INIT complete: " + config.getString("app.name") + ", home=" + applicationHomeDirectory.getAbsolutePath()); }
From source file:org.cesecore.config.ConfigurationHolderTest.java
@Test public void testGetDefaultValuesWithCommas() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException, IOException, ConfigurationException { // Make sure we handle comma in default values String val = ConfigurationHolder.getString("intresources.preferredlanguage"); assertEquals("en", val); // A little reflection magic just to avoid dumping a test value in defaultvalues.properties file. Field field = ConfigurationHolder.class.getDeclaredField("defaultValues"); field.setAccessible(true);//w w w . j av a 2 s . c om CompositeConfiguration defaultValues = (CompositeConfiguration) field.get(null); val = ConfigurationHolder.getString("test.comma.in.defaultvalue"); assertNull(val); File f = File.createTempFile("cesecore", "test"); try { FileWriter fw = new FileWriter(f); fw.write("test.comma.in.defaultvalue=EN,DE,FR\n"); fw.close(); defaultValues.addConfiguration(new PropertiesConfiguration(f)); val = ConfigurationHolder.getString("test.comma.in.defaultvalue"); assertEquals("EN,DE,FR", val); } finally { f.deleteOnExit(); } }
From source file:org.dataone.proto.trove.mn.dao.v1.SolrLogIndexer.java
/** * Include additional properties in the global configuration. Properties included in the given file will override * existing properties in the global configuration if they are present. * * @param addProperties/*from w ww. j a va 2 s .co m*/ * @return Configuration * @throws ConfigurationException * @throws java.io.IOException */ public Configuration getApacheConfiguration(Properties addProperties) throws ConfigurationException, IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); addProperties.store(baos, "hold your comments please"); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); PropertiesConfiguration propertyConfiguration = new PropertiesConfiguration(); propertyConfiguration.load(bais); CompositeConfiguration compositeConfiguration = new CompositeConfiguration(); compositeConfiguration.addConfiguration(propertyConfiguration); return compositeConfiguration; }