Search in sources :

Example 11 with ProviderConfig

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

the class DubboHealthIndicator method resolveStatusCheckerNamesMapFromProviderConfig.

private Map<String, String> resolveStatusCheckerNamesMapFromProviderConfig() {
    Map<String, String> statusCheckerNamesMap = new LinkedHashMap<>();
    for (Map.Entry<String, ProviderConfig> entry : providerConfigs.entrySet()) {
        String beanName = entry.getKey();
        ProviderConfig providerConfig = entry.getValue();
        Set<String> statusCheckerNames = getStatusCheckerNames(providerConfig);
        for (String statusCheckerName : statusCheckerNames) {
            String source = buildSource(beanName, providerConfig);
            statusCheckerNamesMap.put(statusCheckerName, source);
        }
    }
    return statusCheckerNamesMap;
}
Also used : ProviderConfig(org.apache.dubbo.config.ProviderConfig) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 12 with ProviderConfig

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

the class ConfigManagerTest method testProviderConfig.

// Test ProviderConfig correlative methods
@Test
public void testProviderConfig() {
    ProviderConfig config = new ProviderConfig();
    configManager.addProviders(asList(config, null));
    Collection<ProviderConfig> configs = configManager.getProviders();
    assertEquals(1, configs.size());
    assertEquals(config, configs.iterator().next());
    assertTrue(configManager.getDefaultProvider().isPresent());
    config.setId(DEFAULT_KEY);
    configManager.addProvider(config);
    assertTrue(configManager.getDefaultProvider().isPresent());
    configs = configManager.getProviders();
    assertEquals(2, configs.size());
}
Also used : ProviderConfig(org.apache.dubbo.config.ProviderConfig) Test(org.junit.jupiter.api.Test)

Example 13 with ProviderConfig

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

the class ConfigManagerTest method testAddConfig.

@Test
public void testAddConfig() {
    configManager.addConfig(new ApplicationConfig());
    configManager.addConfig(new ProviderConfig());
    configManager.addConfig(new ProtocolConfig());
    assertTrue(configManager.getApplication().isPresent());
    assertFalse(configManager.getProviders().isEmpty());
    assertFalse(configManager.getProtocols().isEmpty());
}
Also used : ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) ProviderConfig(org.apache.dubbo.config.ProviderConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) Test(org.junit.jupiter.api.Test)

Example 14 with ProviderConfig

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

the class EnableDubboConfigTest method testSingle.

@Test
public void testSingle() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.register(TestConfig.class);
    context.refresh();
    // application
    ApplicationConfig applicationConfig = context.getBean("applicationBean", ApplicationConfig.class);
    Assertions.assertEquals("dubbo-demo-application", applicationConfig.getName());
    // module
    ModuleConfig moduleConfig = context.getBean("moduleBean", ModuleConfig.class);
    Assertions.assertEquals("dubbo-demo-module", moduleConfig.getName());
    // registry
    RegistryConfig registryConfig = context.getBean(RegistryConfig.class);
    Assertions.assertEquals("zookeeper://192.168.99.100:32770", registryConfig.getAddress());
    // protocol
    ProtocolConfig protocolConfig = context.getBean(ProtocolConfig.class);
    Assertions.assertEquals("dubbo", protocolConfig.getName());
    Assertions.assertEquals(Integer.valueOf(20880), protocolConfig.getPort());
    // monitor
    MonitorConfig monitorConfig = context.getBean(MonitorConfig.class);
    Assertions.assertEquals("zookeeper://127.0.0.1:32770", monitorConfig.getAddress());
    // provider
    ProviderConfig providerConfig = context.getBean(ProviderConfig.class);
    Assertions.assertEquals("127.0.0.1", providerConfig.getHost());
    // consumer
    ConsumerConfig consumerConfig = context.getBean(ConsumerConfig.class);
    Assertions.assertEquals("netty", consumerConfig.getClient());
    // asserts aliases
    assertFalse(hasAlias(context, "org.apache.dubbo.config.RegistryConfig#0", "zookeeper"));
    assertFalse(hasAlias(context, "org.apache.dubbo.config.MonitorConfig#0", "zookeeper"));
    context.close();
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) ProviderConfig(org.apache.dubbo.config.ProviderConfig) ModuleConfig(org.apache.dubbo.config.ModuleConfig) ConsumerConfig(org.apache.dubbo.config.ConsumerConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) MonitorConfig(org.apache.dubbo.config.MonitorConfig) Test(org.junit.jupiter.api.Test)

Aggregations

ProviderConfig (org.apache.dubbo.config.ProviderConfig)14 Test (org.junit.jupiter.api.Test)9 ProtocolConfig (org.apache.dubbo.config.ProtocolConfig)6 RegistryConfig (org.apache.dubbo.config.RegistryConfig)4 ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)3 ConsumerConfig (org.apache.dubbo.config.ConsumerConfig)3 MethodConfig (org.apache.dubbo.config.MethodConfig)2 ServiceConfig (org.apache.dubbo.config.ServiceConfig)2 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 URL (org.apache.dubbo.common.URL)1 MetadataReportConfig (org.apache.dubbo.config.MetadataReportConfig)1 ModuleConfig (org.apache.dubbo.config.ModuleConfig)1 MonitorConfig (org.apache.dubbo.config.MonitorConfig)1 ReferenceConfig (org.apache.dubbo.config.ReferenceConfig)1 DemoService (org.apache.dubbo.config.api.DemoService)1 DubboBootstrap (org.apache.dubbo.config.bootstrap.DubboBootstrap)1 ConfigTest (org.apache.dubbo.config.spring.ConfigTest)1 DemoService (org.apache.dubbo.config.spring.api.DemoService)1 DemoServiceImpl (org.apache.dubbo.config.spring.impl.DemoServiceImpl)1