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;
}
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);
}
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());
}
Aggregations