List of usage examples for org.apache.commons.configuration Configuration clearProperty
void clearProperty(String key);
From source file:com.cloudera.whirr.cm.integration.BaseITServer.java
private static int clusterBootstrap(Map<String, String> configuration) { int returnValue = 0; try {/*from w ww . j a v a2s . c om*/ if (!isClusterBootstrapped()) { log.logOperationStartedSync("ClusterBootstrap"); Configuration configurationAggregate = clusterConfig(); for (String key : configuration.keySet()) { if (configurationAggregate.containsKey(key)) { configurationAggregate.clearProperty(key); } configurationAggregate.addProperty(key, configuration.get(key)); } new ClusterController().launchCluster(ClusterSpec.withNoDefaults(configurationAggregate)); log.logOperationFinishedSync("ClusterBootstrap"); } } catch (Exception exception) { returnValue = 1; } return returnValue; }
From source file:io.wcm.caravan.io.http.impl.CaravanHttpThreadPoolConfig.java
/** * Removes OSGi configuration from archaius configuration. * @param threadPoolName Thread pool name *//*ww w . java 2 s .co m*/ private void clearArchiausProperties(String threadPoolName) { Configuration archaiusConfig = ArchaiusConfig.getConfiguration(); archaiusConfig .clearProperty(HYSTRIX_THREADPOOL_PREFIX + threadPoolName + HYSTRIX_PARAM_THREADPOOL_CORESIZE); archaiusConfig .clearProperty(HYSTRIX_THREADPOOL_PREFIX + threadPoolName + HYSTRIX_PARAM_THREADPOOL_MAXQUEUESIZE); archaiusConfig.clearProperty( HYSTRIX_THREADPOOL_PREFIX + threadPoolName + HYSTRIX_PARAM_THREADPOOL_QUEUESIZEREJECTIONTHRESHOLD); }
From source file:io.wcm.caravan.io.http.impl.ResilientHttpServiceConfig.java
/** * Removes OSGi configuration from archaius configuration. * @param serviceName Service name//from w ww. j a v a 2 s. c o m */ private void clearArchiausProperties(String serviceName) { Configuration archaiusConfig = ArchaiusConfig.getConfiguration(); // ribbon parameters archaiusConfig.clearProperty(serviceName + RIBBON_PARAM_LISTOFSERVERS); archaiusConfig.clearProperty(serviceName + RIBBON_PARAM_MAXAUTORETRIES); archaiusConfig.clearProperty(serviceName + RIBBON_PARAM_MAXAUTORETRIESONSERVER); archaiusConfig.clearProperty(serviceName + RIBBON_PARAM_OKTORETRYONALLOPERATIONS); // hystrix parameters archaiusConfig.clearProperty(HYSTRIX_COMMAND_PREFIX + serviceName + HYSTRIX_PARAM_TIMEOUT_MS); archaiusConfig.clearProperty(HYSTRIX_COMMAND_PREFIX + serviceName + HYSTRIX_PARAM_FALLBACK_ENABLED); archaiusConfig.clearProperty(HYSTRIX_COMMAND_PREFIX + serviceName + HYSTRIX_PARAM_CIRCUITBREAKER_ENABLED); archaiusConfig.clearProperty( HYSTRIX_COMMAND_PREFIX + serviceName + HYSTRIX_PARAM_CIRCUITBREAKER_REQUESTVOLUMETHRESHOLD); archaiusConfig .clearProperty(HYSTRIX_COMMAND_PREFIX + serviceName + HYSTRIX_PARAM_CIRCUITBREAKER_SLEEPWINDOW_MS); archaiusConfig.clearProperty( HYSTRIX_COMMAND_PREFIX + serviceName + HYSTRIX_PARAM_CIRCUITBREAKER_ERRORTHRESHOLDPERCENTAGE); archaiusConfig.clearProperty(HYSTRIX_COMMAND_PREFIX + serviceName + HYSTRIX_PARAM_CIRCUITBREAKER_FORCEOPEN); archaiusConfig .clearProperty(HYSTRIX_COMMAND_PREFIX + serviceName + HYSTRIX_PARAM_CIRCUITBREAKER_FORCECLOSED); }
From source file:io.servicecomb.serviceregistry.config.TestServiceRegistryConfig.java
@Test public void getMicroserviceVersionFactory() { DynamicPropertyFactory.getInstance(); Configuration config = (Configuration) DynamicPropertyFactory.getBackingConfigurationSource(); config.addProperty(ServiceRegistryConfig.MICROSERVICE_VERSION_FACTORY, "test"); Assert.assertEquals("test", ServiceRegistryConfig.INSTANCE.getMicroserviceVersionFactory()); config.clearProperty(ServiceRegistryConfig.MICROSERVICE_VERSION_FACTORY); }
From source file:com.netflix.config.util.ConfigurationUtils.java
private static String getNextLoad(Configuration propConfig, String... nextLoadPropertyKeys) { String nextLoadKeyToUse = null; for (String key : nextLoadPropertyKeys) { if (propConfig.getProperty(key) != null) { nextLoadKeyToUse = key;/*from w ww.java2 s . c o m*/ break; } } // there is no next load for this properties file if (nextLoadKeyToUse == null) { return null; } // make a copy of current existing properties ConcurrentMapConfiguration config = new ConcurrentMapConfiguration(); // need to have all the properties to interpolate next load property value copyProperties(ConfigurationManager.getConfigInstance(), config); copyProperties(propConfig, config); // In case this is a list of files to load, always treat the value as a list List<Object> list = config.getList(nextLoadKeyToUse); StringBuilder sb = new StringBuilder(); for (Object value : list) { sb.append(value).append(","); } String nextLoad = sb.toString(); propConfig.clearProperty(nextLoadKeyToUse); return nextLoad; }
From source file:io.wcm.caravan.io.http.impl.CaravanHttpServiceConfig.java
/** * Removes OSGi configuration from archaius configuration. * @param serviceId Service ID//from w w w .jav a2 s . c om */ private void clearArchiausProperties(String serviceId) { Configuration archaiusConfig = ArchaiusConfig.getConfiguration(); // ribbon parameters archaiusConfig.clearProperty(serviceId + RIBBON_PARAM_LISTOFSERVERS); archaiusConfig.clearProperty(serviceId + RIBBON_PARAM_MAXAUTORETRIES); archaiusConfig.clearProperty(serviceId + RIBBON_PARAM_MAXAUTORETRIESONSERVER); archaiusConfig.clearProperty(serviceId + RIBBON_PARAM_OKTORETRYONALLOPERATIONS); // hystrix parameters archaiusConfig.clearProperty(HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_TIMEOUT_MS); archaiusConfig.clearProperty(HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_FALLBACK_ENABLED); archaiusConfig.clearProperty(HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_CIRCUITBREAKER_ENABLED); archaiusConfig.clearProperty( HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_CIRCUITBREAKER_REQUESTVOLUMETHRESHOLD); archaiusConfig .clearProperty(HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_CIRCUITBREAKER_SLEEPWINDOW_MS); archaiusConfig.clearProperty( HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_CIRCUITBREAKER_ERRORTHRESHOLDPERCENTAGE); archaiusConfig.clearProperty(HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_CIRCUITBREAKER_FORCEOPEN); archaiusConfig.clearProperty(HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_CIRCUITBREAKER_FORCECLOSED); archaiusConfig.clearProperty( HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_EXECUTIONISOLATIONTHREADPOOLKEY_OVERRIDE); // others archaiusConfig.clearProperty(serviceId + HTTP_PARAM_PROTOCOL); }
From source file:at.salzburgresearch.kmt.zkconfig.ZookeeperConfigurationTest.java
@Test public void testBasicCRUD() throws IOException { Configuration config = new ZookeeperConfiguration(zkConnection, 5000, "/test"); final String key = UUID.randomUUID().toString(); final String v1 = UUID.randomUUID().toString(), v2 = UUID.randomUUID().toString(), v3 = UUID.randomUUID().toString(), v4 = UUID.randomUUID().toString(), v5 = UUID.randomUUID().toString(); assertNull(config.getString(key));/*from w w w . j a v a2s . c o m*/ assertEquals(v5, config.getString(key, v5)); config.setProperty(key, v1); assertEquals(v1, config.getString(key, v5)); config.addProperty(key, v2); assertEquals(v1, config.getString(key, v5)); assertThat(config.getList(key), CoreMatchers.<Object>hasItems(v1, v2)); config.addProperty(key, v3); config.addProperty(key, v4); assertEquals(v1, config.getString(key, v5)); assertThat(config.getList(key), CoreMatchers.<Object>hasItems(v1, v2, v3, v4)); config.clearProperty(key); assertNull(config.getString(key)); assertEquals(v5, config.getString(key, v5)); config.addProperty(key, v5); assertEquals(v5, config.getString(key)); config.clearProperty(key); config.setProperty(key, Arrays.asList(v3, v2, v4, v1, v5)); assertEquals(v3, config.getString(key)); assertThat(config.getList(key), CoreMatchers.<Object>hasItems(v3, v2, v4, v1, v5)); }
From source file:edu.kit.dama.rest.client.DataManagerPropertiesHelper.java
/** * Test access to webDAV server.//from w w w . j ava 2s . c o m * <b>Attention:<b><br/> * This method should only chosen if the credentials are not fixed. The chosen * authentication is slow but allows you to test several credentials. * * @param pAuthenticationClass Class used for authentication. * @return success */ private boolean genericWebDavAccess(String pAuthenticationClass) { boolean returnValue = false; StagingServiceRESTClient ssrc = new StagingServiceRESTClient(restServerUrl + REST_STAGING_PATH, context); try { StagingAccessPointConfigurationWrapper allAccessPoints = ssrc .getAllAccessPoints(properties.getAccessPoint(), properties.getUserGroup(), context); String webDavUrl = ssrc.getAccessPointById(allAccessPoints.getEntities().get(0).getId(), context) .getEntities().get(0).getRemoteBaseUrl(); // Method to overwrite the Webdav configuration class with a custom configuration class for (String protocol : new String[] { "http", "https" }) { Configuration configuration = ProtocolSettings.getSingleton().getConfiguration(protocol); configuration.setProperty("authClass", pAuthenticationClass); Iterator iter = configuration.getKeys(); while (iter.hasNext()) { String key = (String) iter.next(); String value = configuration.getString(key); configuration.clearProperty(key); configuration.addProperty(protocol + "." + key, value); } ProtocolSettings.getSingleton().overwriteConfiguration(configuration); } LOGGER.debug( "Overwriting the default configuration with the specific configuration of generic ingest client."); AbstractFile af = new AbstractFile(new URL(webDavUrl + "/USERS")); af.list(); AbstractFile createDirectory = af.createDirectory(UUID.randomUUID().toString()); if (createDirectory.exists()) { createDirectory.delete(); returnValue = true; } } catch (MalformedURLException | AdalapiException e) { LOGGER.error(invalidWebDavSettings, e); } return returnValue; }
From source file:at.salzburgresearch.kmt.zkconfig.ZookeeperConfigurationTest.java
@Test public void testCuncurrent() throws IOException { Configuration con1 = new ZookeeperConfiguration(zkConnection, 5000, "/concurrent/"); Configuration con2 = new ZookeeperConfiguration(zkConnection, 5000, "/concurrent/"); final String key = UUID.randomUUID().toString(); final String v1 = UUID.randomUUID().toString(), v2 = UUID.randomUUID().toString(), v3 = UUID.randomUUID().toString(), v4 = UUID.randomUUID().toString(), v5 = UUID.randomUUID().toString(); assertNull(con1.getString(key));//from w w w .j a va 2 s.c om assertNull(con2.getString(key)); assertEquals(v5, con1.getString(key, v5)); assertEquals(v5, con2.getString(key, v5)); con1.setProperty(key, v1); assertEquals(v1, con2.getString(key, v5)); assertEquals(v1, con1.getString(key, v5)); con2.addProperty(key, v2); assertEquals(v1, con1.getString(key, v5)); assertEquals(v1, con2.getString(key, v5)); assertThat(con2.getList(key), CoreMatchers.<Object>hasItems(v1, v2)); assertThat(con1.getList(key), CoreMatchers.<Object>hasItems(v1, v2)); con2.addProperty(key, v3); con1.addProperty(key, v4); assertEquals(v1, con2.getString(key, v5)); assertEquals(v1, con1.getString(key, v5)); assertThat(con2.getList(key), CoreMatchers.<Object>hasItems(v1, v2, v3, v4)); assertThat(con1.getList(key), CoreMatchers.<Object>hasItems(v1, v2, v3, v4)); con2.clearProperty(key); assertNull(con2.getString(key)); assertNull(con1.getString(key)); assertEquals(v5, con1.getString(key, v5)); assertEquals(v5, con2.getString(key, v5)); con1.addProperty(key, v5); assertEquals(v5, con2.getString(key)); con1.clearProperty(key); con2.setProperty(key, Arrays.asList(v3, v2, v4, v1, v5)); assertEquals(v3, con1.getString(key)); assertThat(con2.getList(key), CoreMatchers.<Object>hasItems(v3, v2, v4, v1, v5)); }
From source file:org.apache.servicecomb.springboot.starter.transport.TestRestServletInitializer.java
@Before public void setUp() throws Exception { Configuration configuration = (Configuration) DynamicPropertyFactory.getBackingConfigurationSource(); configuration.clearProperty(ServletConfig.KEY_SERVLET_URL_PATTERN); configuration.setProperty(ServletConfig.SERVICECOMB_REST_ADDRESS, LISTEN_ADDRESS); PowerMockito.mockStatic(NetUtils.class); PowerMockito.when(NetUtils.parseIpPortFromURI(anyString())) .thenReturn(new IpPort(LISTEN_ADDRESS, TEST_PORT)); PowerMockito.when(NetUtils.canTcpListen(anyObject(), anyInt())).thenReturn(false); }