Search in sources :

Example 6 with ConfigCenterConfig

use of org.apache.dubbo.config.ConfigCenterConfig in project dubbo by alibaba.

the class DubboBootstrap method registryAsConfigCenter.

private ConfigCenterConfig registryAsConfigCenter(RegistryConfig registryConfig) {
    String protocol = registryConfig.getProtocol();
    Integer port = registryConfig.getPort();
    String id = "config-center-" + protocol + "-" + port;
    if (configManager.getConfigCenter(id) != null) {
        return null;
    }
    ConfigCenterConfig cc = new ConfigCenterConfig();
    cc.setId(id);
    if (cc.getParameters() == null) {
        cc.setParameters(new HashMap<>());
    }
    if (registryConfig.getParameters() != null) {
        // copy the parameters
        cc.getParameters().putAll(registryConfig.getParameters());
    }
    cc.getParameters().put(CLIENT_KEY, registryConfig.getClient());
    cc.setProtocol(protocol);
    cc.setPort(port);
    if (StringUtils.isNotEmpty(registryConfig.getGroup())) {
        cc.setGroup(registryConfig.getGroup());
    }
    cc.setAddress(getRegistryCompatibleAddress(registryConfig));
    cc.setNamespace(registryConfig.getGroup());
    cc.setUsername(registryConfig.getUsername());
    cc.setPassword(registryConfig.getPassword());
    if (registryConfig.getTimeout() != null) {
        cc.setTimeout(registryConfig.getTimeout().longValue());
    }
    cc.setHighestPriority(false);
    return cc;
}
Also used : ConfigCenterConfig(org.apache.dubbo.config.ConfigCenterConfig)

Example 7 with ConfigCenterConfig

use of org.apache.dubbo.config.ConfigCenterConfig in project dubbo by alibaba.

the class Environment method initialize.

@Override
public void initialize() throws IllegalStateException {
    ConfigManager configManager = ApplicationModel.getConfigManager();
    Optional<Collection<ConfigCenterConfig>> defaultConfigs = configManager.getDefaultConfigCenter();
    defaultConfigs.ifPresent(configs -> {
        for (ConfigCenterConfig config : configs) {
            this.setExternalConfigMap(config.getExternalConfiguration());
            this.setAppExternalConfigMap(config.getAppExternalConfiguration());
        }
    });
    this.externalConfiguration.setProperties(externalConfigurationMap);
    this.appExternalConfiguration.setProperties(appExternalConfigurationMap);
}
Also used : ConfigCenterConfig(org.apache.dubbo.config.ConfigCenterConfig) Collection(java.util.Collection) ConfigManager(org.apache.dubbo.config.context.ConfigManager)

Example 8 with ConfigCenterConfig

use of org.apache.dubbo.config.ConfigCenterConfig in project dubbo by alibaba.

the class ConfigManagerTest method testConfigCenterConfig.

// Test ConfigCenterConfig correlative methods
@Test
public void testConfigCenterConfig() {
    ConfigCenterConfig config = new ConfigCenterConfig();
    configManager.addConfigCenters(asList(config, null));
    Collection<ConfigCenterConfig> configs = configManager.getConfigCenters();
    assertEquals(1, configs.size());
    assertEquals(config, configs.iterator().next());
}
Also used : ConfigCenterConfig(org.apache.dubbo.config.ConfigCenterConfig) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigCenterConfig (org.apache.dubbo.config.ConfigCenterConfig)8 Test (org.junit.jupiter.api.Test)4 Collection (java.util.Collection)1 CompositeDynamicConfiguration (org.apache.dubbo.common.config.configcenter.wrapper.CompositeDynamicConfiguration)1 AbstractInterfaceConfig (org.apache.dubbo.config.AbstractInterfaceConfig)1 ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)1 MetadataReportConfig (org.apache.dubbo.config.MetadataReportConfig)1 ModuleConfig (org.apache.dubbo.config.ModuleConfig)1 MonitorConfig (org.apache.dubbo.config.MonitorConfig)1 RegistryConfig (org.apache.dubbo.config.RegistryConfig)1 ConfigManager (org.apache.dubbo.config.context.ConfigManager)1