List of usage examples for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration
public PropertiesConfiguration()
From source file:com.pinterest.secor.common.FileRegistryTest.java
public void setUp() throws Exception { super.setUp(); PropertiesConfiguration properties = new PropertiesConfiguration(); properties.addProperty("secor.file.reader.writer.factory", "com.pinterest.secor.io.impl.SequenceFileReaderWriterFactory"); SecorConfig secorConfig = new SecorConfig(properties); mRegistry = new FileRegistry(secorConfig); mLogFilePath = new LogFilePath("/some_parent_dir", PATH); mTopicPartition = new TopicPartition("some_topic", 0); mLogFilePathGz = new LogFilePath("/some_parent_dir", PATH_GZ); }
From source file:com.linkedin.pinot.server.integration.HelixStarterTest.java
@Test public void testSingleHelixServerStartAndTakingSegment() throws Exception { Configuration pinotHelixProperties = new PropertiesConfiguration(); pinotHelixProperties.addProperty("pinot.server.instance.id", "localhost:0000"); ServerConf serverConf = DefaultHelixStarterServerConfig.getDefaultHelixServerConfig(pinotHelixProperties); ServerInstance serverInstance = new ServerInstance(); serverInstance.init(serverConf, new MetricsRegistry()); serverInstance.start();//ww w . j av a2 s . c om File segmentDir0 = new File(INDEX_DIR, "segment0"); setupSegment(segmentDir0, "testTable0"); File[] segment0Files = segmentDir0.listFiles(); Assert.assertNotNull(segment0Files); File segmentDir1 = new File(INDEX_DIR, "segment1"); setupSegment(segmentDir1, "testTable1"); File[] segment1Files = segmentDir1.listFiles(); Assert.assertNotNull(segment1Files); File segmentDir2 = new File(INDEX_DIR, "segment2"); setupSegment(segmentDir2, "testTable2"); File[] segment2Files = segmentDir2.listFiles(); Assert.assertNotNull(segment2Files); DataManager instanceDataManager = serverInstance.getInstanceDataManager(); instanceDataManager.addSegment( columnarSegmentMetadataLoader.loadIndexSegmentMetadataFromDir(segment0Files[0].getAbsolutePath()), null, null); instanceDataManager.addSegment( columnarSegmentMetadataLoader.loadIndexSegmentMetadataFromDir(segment1Files[0].getAbsolutePath()), null, null); instanceDataManager.addSegment( columnarSegmentMetadataLoader.loadIndexSegmentMetadataFromDir(segment2Files[0].getAbsolutePath()), null, null); }
From source file:com.linkedin.pinot.common.metadata.IndexLoadingConfigMetadataTest.java
private Configuration getTestResourceMetadata() { Configuration resourceMetadata = new PropertiesConfiguration(); String columnNames = null;//from w w w . ja v a 2 s. c o m for (int i = 0; i < 10; ++i) { if (columnNames == null) { columnNames = ("col" + i); } else { columnNames += (", col" + i); } } resourceMetadata.addProperty(KEY_OF_LOADING_INVERTED_INDEX, columnNames); resourceMetadata.addProperty(KEY_OF_ENABLE_DEFAULT_COLUMNS, true); return resourceMetadata; }
From source file:com.thoughtworks.go.agent.service.AgentAutoRegistrationProperties.java
public void scrubRegistrationProperties() { if (!exist()) { return;/*from ww w. j a va 2 s. c o m*/ } try { PropertiesConfiguration config = new PropertiesConfiguration(); config.setIOFactory(new FilteringOutputWriterFactory()); PropertiesConfigurationLayout layout = new PropertiesConfigurationLayout(config); layout.setLineSeparator("\n"); layout.load(reader()); layout.save(new FileWriter(this.configFile)); } catch (ConfigurationException | IOException e) { LOG.warn("[Agent Auto Registration] Unable to scrub registration key.", e); } }
From source file:com.pinterest.pinlater.backends.mysql.MySQLQueueMonitorTest.java
@Before public void beforeTest() throws Exception { // If there is no local MySQL, skip this test. boolean isLocalMysqlRunning = LocalMySQLChecker.isRunning(); Assume.assumeTrue(isLocalMysqlRunning); configuration = new PropertiesConfiguration(); try {//from ww w . j a v a 2 s. c o m configuration.load(ClassLoader.getSystemResourceAsStream("pinlater.test.properties")); } catch (ConfigurationException e) { throw new RuntimeException(e); } System.setProperty("backend_config", "mysql.local.json"); backend = new PinLaterMySQLBackend(configuration, "localhost", System.currentTimeMillis()); // Delete the test queue, if it exists already, for some reason. backend.deleteQueue(QUEUE_NAME).get(); // Now create it. backend.createQueue(QUEUE_NAME).get(); }
From source file:com.sourcesense.opencmis.server.AbstractJaxrsSpringTestCase.java
protected Configuration getContainerConfiguration() { return new PropertiesConfiguration(); }
From source file:edu.berkeley.sparrow.daemon.nodemonitor.TestTaskScheduler.java
/** * Tests the fifo task scheduler./*from w w w .ja v a 2 s . c o m*/ */ @Test public void testFifo() { TaskScheduler scheduler = new FifoTaskScheduler(4); scheduler.initialize(new PropertiesConfiguration(), 12345); final String testApp = "test app"; final InetSocketAddress backendAddress = new InetSocketAddress("123.4.5.6", 2); // Make sure that tasks are launched right away, if resources are available. scheduler.submitTaskReservations(createTaskReservationRequest(1, scheduler, testApp), backendAddress); assertEquals(1, scheduler.runnableTasks()); TaskSpec task = scheduler.getNextTask(); assertEquals("1", task.requestId); assertEquals(0, scheduler.runnableTasks()); scheduler.submitTaskReservations(createTaskReservationRequest(2, scheduler, testApp), backendAddress); assertEquals(2, scheduler.runnableTasks()); // Make sure the request to schedule 3 tasks is appropriately split, with one task running // now and others started later. scheduler.submitTaskReservations(createTaskReservationRequest(3, scheduler, testApp), backendAddress); /* 4 tasks have been launched but one was already removed from the runnable queue using * getTask(), leaving 3 runnable tasks. */ assertEquals(3, scheduler.runnableTasks()); task = scheduler.getNextTask(); assertEquals("2", task.requestId); task = scheduler.getNextTask(); assertEquals("2", task.requestId); /* Make a list of task ids to use in every call to tasksFinished, and just update the request * id for each call. */ TFullTaskId fullTaskId = new TFullTaskId(); fullTaskId.taskId = ""; List<TFullTaskId> completedTasks = Lists.newArrayList(); completedTasks.add(fullTaskId); // Have a few tasks complete before the last runnable task is removed from the queue. fullTaskId.requestId = "2"; scheduler.tasksFinished(completedTasks); scheduler.tasksFinished(completedTasks); fullTaskId.requestId = "1"; scheduler.tasksFinished(completedTasks); task = scheduler.getNextTask(); assertEquals("3", task.requestId); task = scheduler.getNextTask(); assertEquals("3", task.requestId); task = scheduler.getNextTask(); assertEquals("3", task.requestId); assertEquals(0, scheduler.runnableTasks()); }
From source file:com.nesscomputing.config.TestPrefix.java
@Test public void testSystemStillWins() { Assert.assertThat(cfg, is(notNullValue())); PropertiesConfiguration pc = new PropertiesConfiguration(); pc.setProperty("prefix.of.three.string-null-value", "NULL"); pc.setProperty("prefix.of.three.string-value", "another test value"); PropertiesSaver ps = new PropertiesSaver("prefix.of.three.string-value"); try {//from w ww.j a v a 2s . c om System.setProperty("prefix.of.three.string-value", "system-value"); Config c2 = Config.getOverriddenConfig(cfg, pc); final Configuration config = c2.getConfiguration("prefix.of.three"); Assert.assertThat(config, is(notNullValue())); final String s_cfg2 = config.getString("string-value"); Assert.assertThat(s_cfg2, is("system-value")); } finally { ps.apply(); } }
From source file:com.vmware.aurora.global.Configuration.java
/** * //from w w w . j a v a 2s. co m * @return a memory view of all properties inside serengeti.properties and vc.properties */ private static PropertiesConfiguration init() { PropertiesConfiguration config = null; String homeDir = System.getProperties().getProperty("serengeti.home.dir"); String ngcConfigFile = NGC_PROP_FILE; if (homeDir != null && homeDir.length() > 0) { StringBuilder builder = new StringBuilder(); builder.append(homeDir).append(File.separator).append("conf").append(File.separator); configFileName = builder.toString() + "serengeti.properties"; ngcConfigFile = builder.toString() + NGC_PROP_FILE; } else { configFileName = "serengeti.properties"; } try { URL url = ConfigurationUtils.locate(null, configFileName); logger.info("Reading properties file serengeti.properties from " + url.getPath()); serengetiCfg = new PropertiesConfiguration(); serengetiCfg.setEncoding("UTF-8"); serengetiCfg.setFileName(configFileName); serengetiCfg.load(); config = (PropertiesConfiguration) serengetiCfg.clone(); } catch (ConfigurationException ex) { String message = "Failed to load serengeti.properties file."; logger.fatal(message, ex); throw AuroraException.APP_INIT_ERROR(ex, message); } String propertyFilePrefix = System.getProperty("PROPERTY_FILE_PREFIX", "vc"); String propertyFileName = propertyFilePrefix + ".properties"; try { logger.info("Reading properties file " + propertyFileName); vcCfg = new PropertiesConfiguration(propertyFileName); Iterator<?> keys = vcCfg.getKeys(); while (keys.hasNext()) { String key = (String) keys.next(); config.setProperty(key, vcCfg.getProperty(key)); } } catch (ConfigurationException ex) { // error out if the configuration file is not there String message = "Failed to load vc.properties file."; logger.fatal(message, ex); throw AuroraException.APP_INIT_ERROR(ex, message); } // load ngc_registrar.properties try { logger.info("Reading properties file " + ngcConfigFile); ngcCfg = new PropertiesConfiguration(ngcConfigFile); ngcCfg.setEncoding("UTF-8"); Iterator<?> keys = ngcCfg.getKeys(); while (keys.hasNext()) { String key = (String) keys.next(); config.setProperty(key, ngcCfg.getProperty(key)); } } catch (ConfigurationException ex) { // error out if the configuration file is not there String message = "Failed to load file " + NGC_PROP_FILE; logger.fatal(message, ex); throw AuroraException.APP_INIT_ERROR(ex, message); } logConfig(config); return config; }
From source file:edu.cmu.lti.oaqa.bioasq.document.retrieval.GoPubMedDocumentRetrievalExecutor.java
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); String conf = UimaContextHelper.getConfigParameterStringValue(context, "conf"); PropertiesConfiguration gopubmedProperties = new PropertiesConfiguration(); try {//from w w w .j av a 2 s .c o m gopubmedProperties.load(getClass().getResourceAsStream(conf)); } catch (ConfigurationException e) { throw new ResourceInitializationException(e); } service = new GoPubMedService(gopubmedProperties); pages = UimaContextHelper.getConfigParameterIntValue(context, "pages", 1); hits = UimaContextHelper.getConfigParameterIntValue(context, "hits", 100); queryStringConstructor = new PubMedQueryStringConstructor(); }