Search in sources :

Example 1 with ConfigCenterConfig

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

the class AbstractInterfaceBuilderTest method build.

@Test
void build() {
    MonitorConfig monitorConfig = new MonitorConfig("123");
    ApplicationConfig applicationConfig = new ApplicationConfig();
    ModuleConfig moduleConfig = new ModuleConfig();
    RegistryConfig registryConfig = new RegistryConfig();
    MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
    ConfigCenterConfig configCenterConfig = new ConfigCenterConfig();
    InterfaceBuilder builder = new InterfaceBuilder();
    builder.id("id").prefix("prefix").local(true).stub(false).monitor("123").proxy("mockproxyfactory").cluster("mockcluster").filter("mockfilter").listener("mockinvokerlistener").owner("owner").connections(1).layer("layer").application(applicationConfig).module(moduleConfig).addRegistry(registryConfig).registryIds("registryIds").onconnect("onconnet").ondisconnect("ondisconnect").metadataReportConfig(metadataReportConfig).configCenter(configCenterConfig).callbacks(2).scope("scope");
    InterfaceConfig config = builder.build();
    InterfaceConfig config2 = builder.build();
    Assertions.assertEquals("id", config.getId());
    Assertions.assertEquals("prefix", config.getPrefix());
    Assertions.assertEquals("true", config.getLocal());
    Assertions.assertEquals("false", config.getStub());
    Assertions.assertEquals(monitorConfig, config.getMonitor());
    Assertions.assertEquals("mockproxyfactory", config.getProxy());
    Assertions.assertEquals("mockcluster", config.getCluster());
    Assertions.assertEquals("mockfilter", config.getFilter());
    Assertions.assertEquals("mockinvokerlistener", config.getListener());
    Assertions.assertEquals("owner", config.getOwner());
    Assertions.assertEquals(1, config.getConnections().intValue());
    Assertions.assertEquals("layer", config.getLayer());
    Assertions.assertEquals(applicationConfig, config.getApplication());
    Assertions.assertEquals(moduleConfig, config.getModule());
    Assertions.assertEquals(registryConfig, config.getRegistry());
    Assertions.assertEquals("registryIds", config.getRegistryIds());
    Assertions.assertEquals("onconnet", config.getOnconnect());
    Assertions.assertEquals("ondisconnect", config.getOndisconnect());
    Assertions.assertEquals(metadataReportConfig, config.getMetadataReportConfig());
    Assertions.assertEquals(configCenterConfig, config.getConfigCenter());
    Assertions.assertEquals(2, config.getCallbacks().intValue());
    Assertions.assertEquals("scope", config.getScope());
    Assertions.assertNotSame(config, config2);
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ConfigCenterConfig(org.apache.dubbo.config.ConfigCenterConfig) AbstractInterfaceConfig(org.apache.dubbo.config.AbstractInterfaceConfig) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) ModuleConfig(org.apache.dubbo.config.ModuleConfig) MetadataReportConfig(org.apache.dubbo.config.MetadataReportConfig) MonitorConfig(org.apache.dubbo.config.MonitorConfig) Test(org.junit.jupiter.api.Test)

Example 2 with ConfigCenterConfig

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

the class DubboBootstrap method startConfigCenter.

private void startConfigCenter() {
    useRegistryAsConfigCenterIfNecessary();
    Collection<ConfigCenterConfig> configCenters = configManager.getConfigCenters();
    // check Config Center
    if (CollectionUtils.isEmpty(configCenters)) {
        ConfigCenterConfig configCenterConfig = new ConfigCenterConfig();
        configCenterConfig.refresh();
        if (configCenterConfig.isValid()) {
            configManager.addConfigCenter(configCenterConfig);
            configCenters = configManager.getConfigCenters();
        }
    } else {
        for (ConfigCenterConfig configCenterConfig : configCenters) {
            configCenterConfig.refresh();
            ConfigValidationUtils.validateConfigCenterConfig(configCenterConfig);
        }
    }
    if (CollectionUtils.isNotEmpty(configCenters)) {
        CompositeDynamicConfiguration compositeDynamicConfiguration = new CompositeDynamicConfiguration();
        for (ConfigCenterConfig configCenter : configCenters) {
            compositeDynamicConfiguration.addConfiguration(prepareEnvironment(configCenter));
        }
        environment.setDynamicConfiguration(compositeDynamicConfiguration);
    }
    configManager.refreshAll();
}
Also used : ConfigCenterConfig(org.apache.dubbo.config.ConfigCenterConfig) CompositeDynamicConfiguration(org.apache.dubbo.common.config.configcenter.wrapper.CompositeDynamicConfiguration)

Example 3 with ConfigCenterConfig

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

the class ConfigCenterBuilder method build.

public ConfigCenterConfig build() {
    ConfigCenterConfig configCenter = new ConfigCenterConfig();
    super.build(configCenter);
    configCenter.setProtocol(protocol);
    configCenter.setAddress(address);
    configCenter.setCluster(cluster);
    configCenter.setNamespace(namespace);
    configCenter.setGroup(group);
    configCenter.setUsername(username);
    configCenter.setPassword(password);
    configCenter.setTimeout(timeout);
    configCenter.setHighestPriority(highestPriority);
    configCenter.setCheck(check);
    configCenter.setConfigFile(configFile);
    configCenter.setAppConfigFile(appConfigFile);
    configCenter.setParameters(parameters);
    return configCenter;
}
Also used : ConfigCenterConfig(org.apache.dubbo.config.ConfigCenterConfig)

Example 4 with ConfigCenterConfig

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

the class AbstractInterfaceBuilderTest method configCenter.

@Test
void configCenter() {
    ConfigCenterConfig configCenterConfig = new ConfigCenterConfig();
    InterfaceBuilder builder = new InterfaceBuilder();
    builder.configCenter(configCenterConfig);
    Assertions.assertEquals(configCenterConfig, builder.build().getConfigCenter());
}
Also used : ConfigCenterConfig(org.apache.dubbo.config.ConfigCenterConfig) Test(org.junit.jupiter.api.Test)

Example 5 with ConfigCenterConfig

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

the class ConfigCenterBuilderTest method build.

@Test
void build() {
    ConfigCenterBuilder builder = new ConfigCenterBuilder();
    builder.check(true).protocol("protocol").address("address").appConfigFile("appConfigFile").cluster("cluster").configFile("configFile").group("group").highestPriority(false).namespace("namespace").password("password").timeout(1000L).username("usernama").appendParameter("default.num", "one").id("id").prefix("prefix");
    ConfigCenterConfig config = builder.build();
    ConfigCenterConfig config2 = builder.build();
    Assertions.assertTrue(config.isCheck());
    Assertions.assertFalse(config.isHighestPriority());
    Assertions.assertEquals(1000L, config.getTimeout());
    Assertions.assertEquals("protocol", config.getProtocol());
    Assertions.assertEquals("address", config.getAddress());
    Assertions.assertEquals("appConfigFile", config.getAppConfigFile());
    Assertions.assertEquals("cluster", config.getCluster());
    Assertions.assertEquals("configFile", config.getConfigFile());
    Assertions.assertEquals("group", config.getGroup());
    Assertions.assertEquals("namespace", config.getNamespace());
    Assertions.assertEquals("password", config.getPassword());
    Assertions.assertEquals("usernama", config.getUsername());
    Assertions.assertTrue(config.getParameters().containsKey("default.num"));
    Assertions.assertEquals("one", config.getParameters().get("default.num"));
    Assertions.assertEquals("id", config.getId());
    Assertions.assertEquals("prefix", config.getPrefix());
    Assertions.assertNotSame(config, config2);
}
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