Search in sources :

Example 1 with MicroserviceConfigurationSource

use of org.apache.servicecomb.config.archaius.sources.MicroserviceConfigurationSource in project incubator-servicecomb-java-chassis by apache.

the class ConfigUtil method createLocalConfig.

public static ConcurrentCompositeConfiguration createLocalConfig(List<ConfigModel> configModelList) {
    ConcurrentCompositeConfiguration config = new ConcurrentCompositeConfiguration();
    duplicateServiceCombConfigToCse(config, new ConcurrentMapConfiguration(new SystemConfiguration()), "configFromSystem");
    duplicateServiceCombConfigToCse(config, convertEnvVariable(new ConcurrentMapConfiguration(new EnvironmentConfiguration())), "configFromEnvironment");
    duplicateServiceCombConfigToCse(config, new DynamicConfiguration(new MicroserviceConfigurationSource(configModelList), new NeverStartPollingScheduler()), "configFromYamlFile");
    return config;
}
Also used : MicroserviceConfigurationSource(org.apache.servicecomb.config.archaius.sources.MicroserviceConfigurationSource) DynamicConfiguration(com.netflix.config.DynamicConfiguration) EnvironmentConfiguration(org.apache.commons.configuration.EnvironmentConfiguration) ConcurrentMapConfiguration(com.netflix.config.ConcurrentMapConfiguration) SystemConfiguration(org.apache.commons.configuration.SystemConfiguration) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration) NeverStartPollingScheduler(org.apache.servicecomb.config.archaius.scheduler.NeverStartPollingScheduler)

Example 2 with MicroserviceConfigurationSource

use of org.apache.servicecomb.config.archaius.sources.MicroserviceConfigurationSource in project java-chassis by ServiceComb.

the class ConfigUtil method createLocalConfig.

private static ConcurrentCompositeConfiguration createLocalConfig(List<ConfigModel> configModelList) {
    ConcurrentCompositeConfiguration config = new ConcurrentCompositeConfiguration();
    duplicateCseConfigToServicecomb(config, new ConcurrentMapConfigurationExt(new SystemConfiguration()), "configFromSystem");
    duplicateCseConfigToServicecomb(config, convertEnvVariable(new ConcurrentMapConfigurationExt(new EnvironmentConfiguration())), "configFromEnvironment");
    // If there is extra configurations, add it into config.
    EXTRA_CONFIG_MAP.entrySet().stream().filter(mapEntry -> !mapEntry.getValue().isEmpty()).forEachOrdered(configMapEntry -> duplicateCseConfigToServicecomb(config, new ConcurrentMapConfigurationExt(configMapEntry.getValue()), configMapEntry.getKey()));
    // we have already copy the cse config to the serviceComb config when we load the config from local yaml files
    // hence, we do not need duplicate copy it.
    config.addConfiguration(new DynamicConfigurationExt(new MicroserviceConfigurationSource(configModelList), new NeverStartPollingScheduler()), "configFromYamlFile");
    duplicateCseConfigToServicecombAtFront(config, new ConcurrentMapConfigurationExt(ConfigMapping.getConvertedMap(config)), "configFromMapping");
    return config;
}
Also used : Configuration(org.apache.commons.configuration.Configuration) CONFIG_KEY_SPLITER(org.apache.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_KEY_SPLITER) StringUtils(org.apache.commons.lang.StringUtils) WatchedUpdateListener(com.netflix.config.WatchedUpdateListener) DynamicConfigurationChangedEvent(org.apache.servicecomb.config.event.DynamicConfigurationChangedEvent) FieldUtils(org.apache.commons.lang.reflect.FieldUtils) ConfigModel(org.apache.servicecomb.config.archaius.sources.ConfigModel) CONFIG_CSE_PREFIX(org.apache.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_CSE_PREFIX) ConcurrentMapConfiguration(com.netflix.config.ConcurrentMapConfiguration) LoggerFactory(org.slf4j.LoggerFactory) SPIServiceUtils(org.apache.servicecomb.foundation.common.utils.SPIServiceUtils) HashMap(java.util.HashMap) ConfigCenterConfigurationSource(org.apache.servicecomb.config.spi.ConfigCenterConfigurationSource) LinkedHashMap(java.util.LinkedHashMap) EventManager(org.apache.servicecomb.foundation.common.event.EventManager) AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) DynamicProperty(com.netflix.config.DynamicProperty) SystemConfiguration(org.apache.commons.configuration.SystemConfiguration) Map(java.util.Map) Nonnull(javax.annotation.Nonnull) NeverStartPollingScheduler(org.apache.servicecomb.config.archaius.scheduler.NeverStartPollingScheduler) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) MicroserviceConfigurationSource(org.apache.servicecomb.config.archaius.sources.MicroserviceConfigurationSource) ConfigCenterConfigurationSourceLoader(org.apache.servicecomb.config.spi.ConfigCenterConfigurationSourceLoader) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConfigurationManager(com.netflix.config.ConfigurationManager) CONFIG_SERVICECOMB_PREFIX(org.apache.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_SERVICECOMB_PREFIX) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) Collectors(java.util.stream.Collectors) WatchedUpdateResult(com.netflix.config.WatchedUpdateResult) DynamicPropertyFactory(com.netflix.config.DynamicPropertyFactory) EnvironmentConfiguration(org.apache.commons.configuration.EnvironmentConfiguration) Objects(java.util.Objects) List(java.util.List) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration) MicroserviceConfigLoader(org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader) PropertyConverter(org.apache.commons.configuration.PropertyConverter) MicroserviceConfigurationSource(org.apache.servicecomb.config.archaius.sources.MicroserviceConfigurationSource) EnvironmentConfiguration(org.apache.commons.configuration.EnvironmentConfiguration) SystemConfiguration(org.apache.commons.configuration.SystemConfiguration) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration) NeverStartPollingScheduler(org.apache.servicecomb.config.archaius.scheduler.NeverStartPollingScheduler)

Aggregations

ConcurrentCompositeConfiguration (com.netflix.config.ConcurrentCompositeConfiguration)2 ConcurrentMapConfiguration (com.netflix.config.ConcurrentMapConfiguration)2 EnvironmentConfiguration (org.apache.commons.configuration.EnvironmentConfiguration)2 SystemConfiguration (org.apache.commons.configuration.SystemConfiguration)2 NeverStartPollingScheduler (org.apache.servicecomb.config.archaius.scheduler.NeverStartPollingScheduler)2 MicroserviceConfigurationSource (org.apache.servicecomb.config.archaius.sources.MicroserviceConfigurationSource)2 ConfigurationManager (com.netflix.config.ConfigurationManager)1 DynamicConfiguration (com.netflix.config.DynamicConfiguration)1 DynamicProperty (com.netflix.config.DynamicProperty)1 DynamicPropertyFactory (com.netflix.config.DynamicPropertyFactory)1 WatchedUpdateListener (com.netflix.config.WatchedUpdateListener)1 WatchedUpdateResult (com.netflix.config.WatchedUpdateResult)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)1