Java Code Examples for com.netflix.config.ConfigurationManager#install()
The following examples show how to use
com.netflix.config.ConfigurationManager#install() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZkUtils.java From DDMQ with Apache License 2.0 | 6 votes |
public static void init() { try { curatorClient = CuratorFrameworkFactory .builder() .connectString(zkConfig.getZkAddrs()) .sessionTimeoutMs(zkConfig.getZkSessionTimeoutMs()) .retryPolicy(new BoundedExponentialBackoffRetry(zkConfig.getBaseSleepTimeMs(), zkConfig.getMaxSleepMs(), zkConfig.getMaxRetries())) .build(); if (curatorClient.getState() == CuratorFrameworkState.LATENT) { curatorClient.start(); } ZooKeeperConfigurationSource zkConfigSource = new ZooKeeperConfigurationSource(curatorClient, Constants.META_BASE_ZK_PATH); zkConfigSource.start(); DynamicWatchedConfiguration zkDynamicConfig = new DynamicWatchedConfiguration(zkConfigSource); ConfigurationManager.install(zkDynamicConfig); } catch (Exception e) { LOGGER.error("ZkUtils getCuratorClient err:{}", e.getMessage(), e); } }
Example 2
Source File: ZkUtils.java From DDMQ with Apache License 2.0 | 6 votes |
public static void init() { try { curatorClient = CuratorFrameworkFactory .builder() .connectString(zkConfig.getZkAddrs()) .sessionTimeoutMs(zkConfig.getZkSessionTimeoutMs()) .retryPolicy(new BoundedExponentialBackoffRetry(zkConfig.getBaseSleepTimeMs(), zkConfig.getMaxSleepMs(), zkConfig.getMaxRetries())) .build(); if (curatorClient.getState() == CuratorFrameworkState.LATENT) { curatorClient.start(); } ZooKeeperConfigurationSource zkConfigSource = new ZooKeeperConfigurationSource(curatorClient, Constants.META_BASE_ZK_PATH); zkConfigSource.start(); DynamicWatchedConfiguration zkDynamicConfig = new DynamicWatchedConfiguration(zkConfigSource); ConfigurationManager.install(zkDynamicConfig); } catch (Exception e) { LOGGER.error("ZkUtils getCuratorClient err:{}", e.getMessage(), e); } }
Example 3
Source File: ConfigUtil.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
public static void installDynamicConfig() { if (ConfigurationManager.isConfigurationInstalled()) { LOGGER.warn("Configuration installed by others, will ignore this configuration."); return; } ConcurrentCompositeConfiguration compositeConfig = ConfigUtil.createLocalConfig(); ConfigCenterConfigurationSource configCenterConfigurationSource = createConfigCenterConfigurationSource(compositeConfig); if (configCenterConfigurationSource != null) { createDynamicWatchedConfiguration(compositeConfig, configCenterConfigurationSource); } ConfigurationManager.install(compositeConfig); if (configCenterConfigurationSource != null) { configCenterConfigurationSource.init(compositeConfig); } }
Example 4
Source File: TestMicroServiceInstance.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@Test public void testCreateMicroserviceInstanceFromFile() { AbstractConfiguration config = ConfigUtil.createDynamicConfig(); ConcurrentCompositeConfiguration configuration = new ConcurrentCompositeConfiguration(); configuration.addConfiguration(config); ConfigurationManager.install(configuration); MicroserviceInstance instance = MicroserviceInstance.createFromDefinition(config); Assert.assertEquals(instance.getDataCenterInfo().getName(), "myDC"); Assert.assertEquals(instance.getDataCenterInfo().getRegion(), "my-Region"); Assert.assertEquals(instance.getDataCenterInfo().getAvailableZone(), "my-Zone"); }
Example 5
Source File: TestRegistry.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@BeforeClass public static void initSetup() { AbstractConfiguration dynamicConfig = ConfigUtil.createDynamicConfig(); ConcurrentCompositeConfiguration configuration = new ConcurrentCompositeConfiguration(); configuration.addConfiguration(dynamicConfig); configuration.addConfiguration(inMemoryConfig); ConfigurationManager.install(configuration); }
Example 6
Source File: ConsulController.java From james with Apache License 2.0 | 5 votes |
private void setupConsulWatcher(ConsulControllerConfiguration configuration, InformationPointService informationPointService) { ConsulClient client = new ConsulClient(configuration.getHost(), configuration.getPort()); ConsulWatchedConfigurationSource configurationSource = new ConsulWatchedConfigurationSource(configuration.getFolderPath(), client); DynamicWatchedConfiguration dynamicConfig = new DynamicWatchedConfiguration(configurationSource); dynamicConfig.addConfigurationListener(event -> { if (!event.isBeforeUpdate()) { switch (event.getType()) { case AbstractConfiguration.EVENT_ADD_PROPERTY: onInformationPointAdded(event, informationPointService); break; case AbstractConfiguration.EVENT_SET_PROPERTY: onInformationPointModified(event, informationPointService); break; case AbstractConfiguration.EVENT_CLEAR_PROPERTY: onInformationPointRemoved(event, informationPointService); break; case AbstractConfiguration.EVENT_CLEAR: onInformationPointsCleared(informationPointService); break; default: LOG.debug(() -> "Unsupported event type: " + event.getType()); } } }); configurationSource.startAsync(); ConcurrentCompositeConfiguration compositeConfig = new ConcurrentCompositeConfiguration(); compositeConfig.addConfiguration(dynamicConfig, "consul-dynamic"); ConfigurationManager.install(compositeConfig); }
Example 7
Source File: ConfigurationBuilder.java From chassis with Apache License 2.0 | 5 votes |
private void configureArchaius(ConcurrentCompositeConfiguration finalConfiguration) { if (configureArchaius) { Properties systemProps = System.getProperties(); if (systemProps.getProperty(ARCHAIUS_DEPLOYMENT_ENVIRONMENT) == null) { systemProps.setProperty(ARCHAIUS_DEPLOYMENT_ENVIRONMENT, appEnvironment); } ConfigurationManager.install(finalConfiguration); } }
Example 8
Source File: SSLOptionTest.java From servicecomb-java-chassis with Apache License 2.0 | 4 votes |
@Test public void testSSLOptionYaml() { // configuration from yaml files: default microservice.yaml DynamicConfiguration configFromYamlFile = new DynamicConfiguration(yamlConfigSource(), new FixedDelayPollingScheduler()); // configuration from system properties ConcurrentMapConfiguration configFromSystemProperties = new ConcurrentMapConfiguration(new SystemConfiguration()); // create a hierarchy of configuration that makes // 1) dynamic configuration source override system properties ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration(); finalConfig.addConfiguration(configFromSystemProperties, "systemEnvConfig"); finalConfig.addConfiguration(configFromYamlFile, "configFromYamlFile"); ConfigurationManager.install(finalConfig); SSLOption option = SSLOption.buildFromYaml("server"); String protocols = option.getProtocols(); option.setProtocols(protocols); Assert.assertEquals("TLSv1.2,TLSv1.1,TLSv1,SSLv2Hello", protocols); String ciphers = option.getCiphers(); option.setCiphers(ciphers); Assert.assertEquals( "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_DSS_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SH" + "A,TLS_DHE_DSS_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA", ciphers); boolean authPeer = option.isAuthPeer(); option.setAuthPeer(authPeer); Assert.assertEquals(true, authPeer); boolean checkCNHost = option.isCheckCNHost(); option.setCheckCNHost(checkCNHost); Assert.assertEquals(true, checkCNHost); boolean checkCNWhite = option.isCheckCNWhite(); option.setCheckCNWhite(checkCNWhite); Assert.assertEquals(true, checkCNWhite); String checkCNWhiteFile = option.getCheckCNWhiteFile(); option.setCheckCNWhiteFile(checkCNWhiteFile); Assert.assertEquals("white.list", checkCNWhiteFile); boolean allowRenegociate = option.isAllowRenegociate(); option.setAllowRenegociate(allowRenegociate); Assert.assertEquals(false, allowRenegociate); String storePath = option.getStorePath(); option.setStorePath(storePath); Assert.assertEquals("internal", storePath); String trustStore = option.getTrustStore(); option.setTrustStore(trustStore); Assert.assertEquals("trust.jks", trustStore); String trustStoreType = option.getTrustStoreType(); option.setTrustStoreType(trustStoreType); Assert.assertEquals("JKS", trustStoreType); String trustStoreValue = option.getTrustStoreValue(); option.setTrustStoreValue(trustStoreValue); Assert.assertEquals("Changeme_123", trustStoreValue); String keyStore = option.getKeyStore(); option.setKeyStore(keyStore); Assert.assertEquals("server.p12", keyStore); String keyStoreType = option.getKeyStoreType(); option.setKeyStoreType(keyStoreType); Assert.assertEquals("PKCS12", keyStoreType); String keyStoreValue = option.getKeyStoreValue(); option.setKeyStoreValue(keyStoreValue); Assert.assertEquals("Changeme_123", keyStoreValue); String crl = option.getCrl(); option.setCrl(crl); Assert.assertEquals("revoke.crl", crl); option.setSslCustomClass("123"); SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass()); Assert.assertArrayEquals(custom.decode("123".toCharArray()), "123".toCharArray()); }
Example 9
Source File: DynamicPropertiesImpl.java From servicecomb-java-chassis with Apache License 2.0 | 4 votes |
DynamicPropertiesImpl(AbstractConfiguration... configurations) { ConcurrentCompositeConfiguration configuration = new ConcurrentCompositeConfiguration(); Arrays.stream(configurations).forEach(configuration::addConfiguration); ConfigurationManager.install(configuration); }