org.apache.commons.configuration.AbstractConfiguration Java Examples
The following examples show how to use
org.apache.commons.configuration.AbstractConfiguration.
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: ConfigUtil.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
private static void duplicateCseConfigToServicecomb(AbstractConfiguration source) { Iterator<String> keys = source.getKeys(); while (keys.hasNext()) { String key = keys.next(); if (!key.startsWith(CONFIG_CSE_PREFIX)) { continue; } String servicecombKey = CONFIG_SERVICECOMB_PREFIX + key.substring(key.indexOf(".") + 1); if (!source.containsKey(servicecombKey)) { source.addProperty(servicecombKey, source.getProperty(key)); } else { LOGGER .warn( "Key {} with an ambiguous item {} exists, it's recommended to use only one of them.", key, servicecombKey); } } }
Example #2
Source File: InitializeServletListener.java From s2g-zuul with MIT License | 6 votes |
private void initZuul() throws Exception { LOGGER.info("Starting Groovy Filter file manager"); final AbstractConfiguration config = ConfigurationManager.getConfigInstance(); final String preFiltersPath = config.getString(Constants.ZUUL_FILTER_PRE_PATH); final String postFiltersPath = config.getString(Constants.ZUUL_FILTER_POST_PATH); final String routeFiltersPath = config.getString(Constants.ZUUL_FILTER_ROUTE_PATH); final String errorFiltersPath = config.getString(Constants.ZUUL_FILTER_ERROR_PATH); final String customPath = config.getString(Constants.Zuul_FILTER_CUSTOM_PATH); //load local filter files FilterLoader.getInstance().setCompiler(new GroovyCompiler()); FilterFileManager.setFilenameFilter(new GroovyFileFilter()); if (customPath == null) { FilterFileManager.init(5, preFiltersPath, postFiltersPath, routeFiltersPath, errorFiltersPath); } else { FilterFileManager.init(5, preFiltersPath, postFiltersPath, routeFiltersPath, errorFiltersPath, customPath); } //load filters in DB startZuulFilterPoller(); LOGGER.info("Groovy Filter file manager started"); }
Example #3
Source File: ConfigurationHelperTest.java From googleads-java-lib with Apache License 2.0 | 6 votes |
@Before public void setUp() { AbstractConfiguration.setDefaultListDelimiter(','); clearTestSystemProperties(); this.configurationHelper = new ConfigurationHelper(); this.test1Properties = ImmutableMap.of( "a.b.c", "efgh", "a.b.d", "1234"); this.test3Properties = ImmutableMap.of( "a.b.c", "jklm", "e.f.h", "90123", "i.j.k", "foo"); }
Example #4
Source File: EagleMailClient.java From Eagle with Apache License 2.0 | 6 votes |
public EagleMailClient(AbstractConfiguration configuration) { try { ConcurrentMapConfiguration con = (ConcurrentMapConfiguration)configuration; velocityEngine = new VelocityEngine(); velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); velocityEngine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName()); velocityEngine.init(); con.setProperty("mail.transport.protocol", "smtp"); final Properties config = con.getProperties(); if(Boolean.parseBoolean(config.getProperty(AUTH_CONFIG))){ session = Session.getDefaultInstance(config, new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(config.getProperty(USER_CONFIG), config.getProperty(PWD_CONFIG)); } }); } else session = Session.getDefaultInstance(config, new Authenticator() {}); final String debugMode = config.getProperty(DEBUG_CONFIG, "false"); final boolean debug = Boolean.parseBoolean(debugMode); session.setDebug(debug); } catch (Exception e) { LOG.error("Failed connect to smtp server",e); } }
Example #5
Source File: RedisSyncSingleStorageImpl.java From mithqtt with Apache License 2.0 | 6 votes |
@Override public void init(AbstractConfiguration config) { if (!config.getString("redis.type").equals("single")) { throw new IllegalStateException("RedisSyncSingleStorageImpl class can only be used with single redis setup, but redis.type value is " + config.getString("redis.type")); } List<String> address = parseRedisAddress(config.getString("redis.address"), 6379); int databaseNumber = config.getInt("redis.database", 0); String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : ""; // lettuce RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber); this.lettuce = RedisClient.create(lettuceURI); this.lettuceConn = this.lettuce.connect(); // params initParams(config); }
Example #6
Source File: LogConfigUtils.java From singer with Apache License 2.0 | 6 votes |
private static LogStreamReaderConfig parseLogStreamReaderConfig(AbstractConfiguration readerConfiguration) throws ConfigurationException { readerConfiguration.setThrowExceptionOnMissing(true); String readerTypeString = readerConfiguration.getString("type"); ReaderType type = ReaderType.valueOf(readerTypeString.toUpperCase()); LogStreamReaderConfig readerConfig = new LogStreamReaderConfig(type); if (type.equals(ReaderType.THRIFT)) { ThriftReaderConfig thriftReaderConfig = parseThriftReaderConfig( new SubsetConfiguration(readerConfiguration, readerTypeString + ".")); readerConfig.setThriftReaderConfig(thriftReaderConfig); } else if (type.equals(ReaderType.TEXT)) { TextReaderConfig textReaderConfig = parseTextReaderConfig( new SubsetConfiguration(readerConfiguration, readerTypeString + ".")); readerConfig.setTextReaderConfig(textReaderConfig); } return readerConfig; }
Example #7
Source File: ConfigurationHelperTest.java From googleads-java-lib with Apache License 2.0 | 6 votes |
@Test public void testFromSystem_containsListValues() throws Exception { AbstractConfiguration.setDefaultListDelimiter('|'); Map<String, String> properties = Maps.newHashMap(); properties.put("testProperty", "b,bee"); properties.forEach(System::setProperty); Splitter splitter = Splitter.on(','); Configuration systemConfiguration = configurationHelper.fromSystem(); for (Entry<String, String> entry : properties.entrySet()) { String[] actualValues = systemConfiguration.getStringArray(entry.getKey()); String[] expectedValues; if ("line.separator".equals(entry.getKey())) { expectedValues = new String[] {SystemUtils.LINE_SEPARATOR}; } else { expectedValues = splitter.splitToList(entry.getValue()).toArray(new String[0]); } assertArrayEquals(String.format("Values for key %s do not match", entry.getKey()), expectedValues, actualValues); } }
Example #8
Source File: RedisSyncMasterSlaveStorageImpl.java From mithqtt with Apache License 2.0 | 6 votes |
@Override public void init(AbstractConfiguration config) { if (!config.getString("redis.type").equals("master_slave")) { throw new IllegalStateException("RedisSyncSingleStorageImpl class can only be used with master slave redis setup, but redis.type value is " + config.getString("redis.type")); } List<String> address = parseRedisAddress(config.getString("redis.address"), 6379); int databaseNumber = config.getInt("redis.database", 0); String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : ""; // lettuce RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber); this.lettuceMasterSlave = RedisClient.create(lettuceURI); this.lettuceMasterSlaveConn = MasterSlave.connect(this.lettuceMasterSlave, new Utf8StringCodec(), lettuceURI); this.lettuceMasterSlaveConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read"))); // params initParams(config); }
Example #9
Source File: ArchaiusPropertyResolverTest.java From ribbon with Apache License 2.0 | 6 votes |
@Test public void mapFromPrefixedKeys() { final String prefix = "client.ribbon." + testName.getMethodName(); final AbstractConfiguration config = ConfigurationManager.getConfigInstance(); config.setProperty(prefix + ".a", "1"); config.setProperty(prefix + ".b", "2"); config.setProperty(prefix + ".c", "3"); final ArchaiusPropertyResolver resolver = ArchaiusPropertyResolver.INSTANCE; final Map<String, String> map = new TreeMap<>(); resolver.forEach(prefix, map::put); final Map<String, String> expected = new TreeMap<>(); expected.put("a", "1"); expected.put("b", "2"); expected.put("c", "3"); Assert.assertEquals(expected, map); }
Example #10
Source File: PropertiesServlet.java From chassis with Apache License 2.0 | 6 votes |
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // get list of properties TreeSet<String> properties = new TreeSet<String>(); AbstractConfiguration config = ConfigurationManager.getConfigInstance(); Iterator<String> keys = config.getKeys(); while (keys.hasNext()) { String key = keys.next(); Object value = config.getProperty(key); if ("aws.accessId".equals(key) || "aws.secretKey".equals(key) || "experiments-service.secret".equals(key) || "java.class.path".equals(key) || key.contains("framework.securityDefinition") || key.contains("password") || key.contains("secret")) { value = "*****"; } properties.add(key + "=" + value.toString()); } // write them out in sorted order for (String line : properties) { resp.getWriter().append(line).println(); } }
Example #11
Source File: ConfigUtils.java From singer with Apache License 2.0 | 6 votes |
public static LoggingAuditClientConfig parseCommonConfig(AbstractConfiguration conf) throws ConfigurationException { LoggingAuditClientConfig loggingAuditClientConfig = new LoggingAuditClientConfig(); try { loggingAuditClientConfig.setStage(LoggingAuditStage .valueOf(conf.getString(LoggingAuditClientConfigDef.STAGE).toUpperCase())); } catch (Exception e) { throw new ConfigurationException("STAGE is not properly set!"); } if (conf.containsKey(LoggingAuditClientConfigDef.DEFAULT_ENABLE_AUDIT_FOR_ALL_TOPICS)) { loggingAuditClientConfig.setEnableAuditForAllTopicsByDefault( conf.getBoolean(LoggingAuditClientConfigDef.DEFAULT_ENABLE_AUDIT_FOR_ALL_TOPICS)); } if (conf.containsKey(LoggingAuditClientConfigDef.QUEUE_SIZE)) { loggingAuditClientConfig.setQueueSize(conf.getInt(LoggingAuditClientConfigDef.QUEUE_SIZE)); } if (conf.containsKey(LoggingAuditClientConfigDef.ENQUEUE_WAIT_IN_MILLISECONDS)) { loggingAuditClientConfig.setEnqueueWaitInMilliseconds( conf.getInt(LoggingAuditClientConfigDef.ENQUEUE_WAIT_IN_MILLISECONDS)); } return loggingAuditClientConfig; }
Example #12
Source File: Application.java From chassis with Apache License 2.0 | 6 votes |
@Override public void onApplicationEvent(ContextRefreshedEvent event) { logger.debug("Received ContextRefreshedEvent {}", event); if (event.getSource().equals(getBootstrapApplicationContext())) { //the root context is fully started appMetadata = bootstrapApplicationContext.getBean(AppMetadata.class); configuration = bootstrapApplicationContext.getBean(AbstractConfiguration.class); configurationProvider = bootstrapApplicationContext.getBean(ConfigurationProvider.class); logger.debug("Root context started"); initClientApplication(); return; } if (event.getSource() instanceof ApplicationContext && ((ApplicationContext) event.getSource()).getId().equals(appMetadata.getName())) { //the child context is fully started this.applicationContext = (AbstractApplicationContext) event.getSource(); logger.debug("Child context started"); } state.compareAndSet(State.STARTING, State.RUNNING); }
Example #13
Source File: SecureGetTest.java From ribbon with Apache License 2.0 | 6 votes |
@Test public void testSunnyDayNoClientAuth() throws Exception{ AbstractConfiguration cm = ConfigurationManager.getConfigInstance(); String name = "GetPostSecureTest" + ".testSunnyDayNoClientAuth"; String configPrefix = name + "." + "ribbon"; cm.setProperty(configPrefix + "." + CommonClientConfigKey.IsSecure, "true"); cm.setProperty(configPrefix + "." + CommonClientConfigKey.SecurePort, Integer.toString(testServer2.getPort())); cm.setProperty(configPrefix + "." + CommonClientConfigKey.IsHostnameValidationRequired, "false"); cm.setProperty(configPrefix + "." + CommonClientConfigKey.TrustStore, FILE_TS2.getAbsolutePath()); cm.setProperty(configPrefix + "." + CommonClientConfigKey.TrustStorePassword, PASSWORD); RestClient rc = (RestClient) ClientFactory.getNamedClient(name); testServer2.accept(); URI getUri = new URI(SERVICE_URI2 + "test/"); HttpRequest request = HttpRequest.newBuilder().uri(getUri).queryParams("name", "test").build(); HttpResponse response = rc.execute(request); assertEquals(200, response.getStatus()); }
Example #14
Source File: ConfigUtils.java From singer with Apache License 2.0 | 6 votes |
public static LoggingAuditEventSenderConfig parseSenderConfig(AbstractConfiguration conf) throws ConfigurationException { try { LoggingAuditEventSenderConfig senderConfig = new LoggingAuditEventSenderConfig(); SenderType senderType = SenderType.valueOf(conf.getString( LoggingAuditClientConfigDef.SENDER_TYPE).toUpperCase()); if (!senderType.equals(SenderType.KAFKA)) { throw new ConfigurationException("Only Kafka Sender is supported now."); } senderConfig.setSenderType(senderType); senderConfig.setKafkaSenderConfig(parseKafkaSenderConfig(new SubsetConfiguration(conf, LoggingAuditClientConfigDef.KAFKA_SENDER_PREFIX))); return senderConfig; } catch (Exception e) { throw new ConfigurationException( "LoggingAuditEventSenderConfig can't be properly parsed due to " + e.getMessage()); } }
Example #15
Source File: TestConfigUtil.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
@Test public void testCreateDynamicConfigNoConfigCenterSPI() { new Expectations(SPIServiceUtils.class) { { SPIServiceUtils.getTargetService(ConfigCenterConfigurationSource.class); result = null; } }; AbstractConfiguration dynamicConfig = ConfigUtil.createDynamicConfig(); MicroserviceConfigLoader loader = ConfigUtil.getMicroserviceConfigLoader(dynamicConfig); List<ConfigModel> list = loader.getConfigModels(); Assert.assertEquals(loader, ConfigUtil.getMicroserviceConfigLoader(dynamicConfig)); Assert.assertEquals(1, list.size()); Assert.assertNotEquals(DynamicWatchedConfiguration.class, ((ConcurrentCompositeConfiguration) dynamicConfig).getConfiguration(0).getClass()); }
Example #16
Source File: ConfigUtils.java From singer with Apache License 2.0 | 6 votes |
public static AuditConfig parseAuditConfig(AbstractConfiguration conf) throws ConfigurationException { AuditConfig topicAuditConfig = new AuditConfig(); try { if (conf.containsKey(LoggingAuditClientConfigDef.SAMPLING_RATE)) { topicAuditConfig .setSamplingRate(conf.getDouble(LoggingAuditClientConfigDef.SAMPLING_RATE)); } if (conf.containsKey(LoggingAuditClientConfigDef.START_AT_CURRENT_STAGE)) { topicAuditConfig.setStartAtCurrentStage( conf.getBoolean(LoggingAuditClientConfigDef.START_AT_CURRENT_STAGE)); } if (conf.containsKey(LoggingAuditClientConfigDef.STOP_AT_CURRENT_STAGE)) { topicAuditConfig .setStopAtCurrentStage( conf.getBoolean(LoggingAuditClientConfigDef.STOP_AT_CURRENT_STAGE)); } return topicAuditConfig; } catch (Exception e) { throw new ConfigurationException("Can't create TopicAuditConfig from configuration.", e); } }
Example #17
Source File: DefaultAstyanaxClusterClientProvider.java From staash with Apache License 2.0 | 5 votes |
@Inject public DefaultAstyanaxClusterClientProvider( AbstractConfiguration configuration, Map<String, HostSupplierProvider> hostSupplierProviders, AstyanaxConfigurationProvider configurationProvider, AstyanaxConnectionPoolConfigurationProvider cpProvider, AstyanaxConnectionPoolMonitorProvider monitorProvider) { this.configurationProvider = configurationProvider; this.cpProvider = cpProvider; this.monitorProvider = monitorProvider; this.hostSupplierProviders = hostSupplierProviders; this.configuration = configuration; }
Example #18
Source File: ConfigurationBuilder.java From chassis with Apache License 2.0 | 5 votes |
/** * Build the Configuration * * @return the configuration */ public AbstractConfiguration build() { initApplicationFileConfiguration(); initAppVersion(); initApplicationConfiguration(); initModuleConfiguration(); ConcurrentCompositeConfiguration finalConfiguration = new ConcurrentCompositeConfiguration(); if (addSystemConfigs) { finalConfiguration.addConfiguration(new ConcurrentMapConfiguration(new SystemConfiguration())); } finalConfiguration.addProperty(BootstrapConfigKeys.APP_VERSION_KEY.getPropertyName(), appVersion); addServerInstanceProperties(finalConfiguration); if (applicationConfiguration == null) { LOGGER.warn("\n\n ****** Default configuration being used ******\n client application \"" + appName + "\" is being configured with modules defaults. Defaults should only be used in development environments.\n In non-developement environments, a configuration provider should be used to configure the client application and it should define ALL required configuration properties.\n"); finalConfiguration.addConfiguration(applicationFileConfiguration); finalConfiguration.addConfiguration(moduleDefaultConfiguration); } else { finalConfiguration.addConfiguration(applicationConfiguration); finalConfiguration.addConfiguration(applicationFileConfiguration); } finalConfiguration.setProperty(BootstrapConfigKeys.APP_VERSION_KEY.getPropertyName(), appVersion); configureArchaius(finalConfiguration); logConfiguration(finalConfiguration); return finalConfiguration; }
Example #19
Source File: DatabaseJobHistoryStoreSchemaManager.java From incubator-gobblin with Apache License 2.0 | 5 votes |
private static Properties getProperties(Configuration config) { Properties props = new Properties(); char delimiter = (config instanceof AbstractConfiguration) ? ((AbstractConfiguration) config).getListDelimiter() : ','; Iterator keys = config.getKeys(); while (keys.hasNext()) { String key = (String) keys.next(); List list = config.getList(key); props.setProperty("flyway." + key, StringUtils.join(list.iterator(), delimiter)); } return props; }
Example #20
Source File: MetricsGraphiteConfiguration.java From chassis with Apache License 2.0 | 5 votes |
private void addConfigurationListener() { final MetricsGraphiteConfiguration springConfig = this; ConfigurationManager.getConfigInstance().addConfigurationListener(new ConfigurationListener() { @Override public synchronized void configurationChanged(ConfigurationEvent event) { if (!(event.getType() == AbstractConfiguration.EVENT_SET_PROPERTY || event.getType() == AbstractConfiguration.EVENT_ADD_PROPERTY)) { return; } if (event.isBeforeUpdate()) { return; } String name = event.getPropertyName(); if (!(name.equals(METRICS_GRAPHITE_ENABLED) || name.equals(METRICS_GRAPHITE_SERVER) || name.equals(METRICS_GRAPHITE_PORT) || name.equals(METRICS_GRAPHITE_FILTER) || name.equals(METRICS_GRAPHITE_PUBLISH_INTERVAL) || name.equals(METRICS_GRAPHITE_PUBLISH_INTERVAL_UNIT))) { return; } springConfig.enabled = name.equals(METRICS_GRAPHITE_ENABLED) ? Boolean.parseBoolean(event.getPropertyValue() + "") : springConfig.enabled; destroyReporterLoader(); if (springConfig.enabled) { createReporterLoader(); } } }); }
Example #21
Source File: MetricsCloudWatchConfiguration.java From chassis with Apache License 2.0 | 5 votes |
private void addConfigurationListener() { final MetricsCloudWatchConfiguration springConfig = this; ConfigurationManager.getConfigInstance().addConfigurationListener(new ConfigurationListener() { @Override public synchronized void configurationChanged(ConfigurationEvent event) { if (!(event.getType() == AbstractConfiguration.EVENT_SET_PROPERTY || event.getType() == AbstractConfiguration.EVENT_ADD_PROPERTY)) { return; } if (event.isBeforeUpdate()) { return; } String name = event.getPropertyName(); if (!(name.equals(METRICS_AWS_ENABLED) || name.equals(METRICS_AWS_FILTER) || name.equals(METRICS_AWS_PUBLISH_INTERVAL) || name.equals(METRICS_AWS_PUBLISH_INTERVAL_UNIT))) { return; } springConfig.enabled = name.equals(METRICS_AWS_ENABLED) ? Boolean.parseBoolean(event.getPropertyValue() + "") : springConfig.enabled; destroyReporter(); if (springConfig.enabled) { createReporter(); } } }); }
Example #22
Source File: ZookeeperConfigurationProvider.java From chassis with Apache License 2.0 | 5 votes |
/** * @see ConfigurationProvider#getApplicationConfiguration(String, String, String, com.kixeye.chassis.bootstrap.aws.ServerInstanceContext) */ @Override public AbstractConfiguration getApplicationConfiguration(String environment, String applicationName, String applicationVersion, ServerInstanceContext serverInstanceContext) { String instanceId = serverInstanceContext == null ? "local" : serverInstanceContext.getInstanceId(); String configRoot = getPath(environment, applicationName, applicationVersion); String primaryConfigPath = configRoot += "/config"; String instanceConfigNode = instanceId + "-config"; checkPath(primaryConfigPath); ZooKeeperConfigurationSource source = new ZooKeeperConfigurationSource(curatorFramework, primaryConfigPath); try { source.start(); } catch (Exception e) { source.close(); BootstrapException.zookeeperInitializationFailed(zookeeperConnectionString, primaryConfigPath, e); } logger.debug("Initializing zookeeper configuration from host " + zookeeperConnectionString + " at path " + primaryConfigPath); ConcurrentCompositeConfiguration configuration = new ConcurrentCompositeConfiguration(); configuration.addConfiguration(getServerInstanceSpecificApplicationConfiguration(configRoot, instanceConfigNode)); configuration.addConfiguration(new DynamicWatchedConfiguration(source)); return configuration; }
Example #23
Source File: DefautConfiguration.java From resilient-transport-service with Apache License 2.0 | 5 votes |
@RefreshScope @Bean public AbstractConfiguration archaiusConfiguration() throws Exception { LOGGER.info("Enable Archaius Configuration"); ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration(); return concurrentMapConfiguration; }
Example #24
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 #25
Source File: RedisSyncClusterStorageImpl.java From mithqtt with Apache License 2.0 | 5 votes |
@Override public void init(AbstractConfiguration config) { if (!config.getString("redis.type").equals("cluster")) { throw new IllegalStateException("RedisSyncSingleStorageImpl class can only be used with cluster redis setup, but redis.type value is " + config.getString("redis.type")); } List<String> address = parseRedisAddress(config.getString("redis.address"), 6379); int databaseNumber = config.getInt("redis.database", 0); String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : ""; // lettuce RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber); this.lettuceCluster = RedisClusterClient.create(lettuceURI); this.lettuceCluster.setOptions(ClusterClientOptions.builder() .topologyRefreshOptions(ClusterTopologyRefreshOptions.builder() .enablePeriodicRefresh(config.getBoolean("redis.cluster.periodicRefreshEnabled", ClusterTopologyRefreshOptions.DEFAULT_PERIODIC_REFRESH_ENABLED)) .refreshPeriod(config.getLong("redis.cluster.refreshPeriod", ClusterTopologyRefreshOptions.DEFAULT_REFRESH_PERIOD), TimeUnit.SECONDS) .closeStaleConnections(config.getBoolean("redis.cluster.closeStaleConnections", ClusterTopologyRefreshOptions.DEFAULT_CLOSE_STALE_CONNECTIONS)) .build()) .validateClusterNodeMembership(config.getBoolean("redis.cluster.validateClusterNodeMembership", ClusterClientOptions.DEFAULT_VALIDATE_CLUSTER_MEMBERSHIP)) .maxRedirects(config.getInt("redis.cluster.refreshPeriod", ClusterClientOptions.DEFAULT_MAX_REDIRECTS)) .build()); this.lettuceClusterConn = this.lettuceCluster.connect(); this.lettuceClusterConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read"))); // params initParams(config); }
Example #26
Source File: TestInstancePropertyDiscoveryFilter.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@BeforeClass public static void beforeCls() { AbstractConfiguration configuration = new BaseConfiguration(); configuration.addProperty("servicecomb.loadbalance.test.flowsplitFilter.policy", "org.apache.servicecomb.loadbalance.filter.SimpleFlowsplitFilter"); configuration.addProperty("servicecomb.loadbalance.test.flowsplitFilter.options.tag0", "value0"); }
Example #27
Source File: ConfigUtil.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
private static void duplicateCseConfigToServicecomb(ConcurrentCompositeConfiguration compositeConfiguration, AbstractConfiguration source, String sourceName) { duplicateCseConfigToServicecomb(source); compositeConfiguration.addConfiguration(source, sourceName); }
Example #28
Source File: ConfigUtil.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
private static void duplicateCseConfigToServicecombAtFront(ConcurrentCompositeConfiguration compositeConfiguration, AbstractConfiguration source, String sourceName) { duplicateCseConfigToServicecomb(source); compositeConfiguration.addConfigurationAtFront(source, sourceName); }
Example #29
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 #30
Source File: TestConfigUtil.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@Test public void testConvertEnvVariable() { String someProperty = "cse_service_registry_address"; AbstractConfiguration config = new DynamicConfiguration(); config.addProperty(someProperty, "testing"); AbstractConfiguration result = ConfigUtil.convertEnvVariable(config); assertThat(result.getString("cse.service.registry.address"), equalTo("testing")); assertThat(result.getString("cse_service_registry_address"), equalTo("testing")); }