Search in sources :

Example 6 with MetadataReportConfig

use of org.apache.dubbo.config.MetadataReportConfig in project dubbo by apache.

the class DubboServiceProviderBootstrap method multipleRegistries.

private static void multipleRegistries() {
    ProtocolConfig restProtocol = new ProtocolConfig();
    restProtocol.setName("rest");
    restProtocol.setId("rest");
    restProtocol.setPort(-1);
    RegistryConfig interfaceRegistry = new RegistryConfig();
    interfaceRegistry.setId("interfaceRegistry");
    interfaceRegistry.setAddress("zookeeper://127.0.0.1:2181");
    RegistryConfig serviceRegistry = new RegistryConfig();
    serviceRegistry.setId("serviceRegistry");
    serviceRegistry.setAddress("zookeeper://127.0.0.1:2181?registry-type=service");
    ServiceConfig<EchoService> echoService = new ServiceConfig<>();
    echoService.setInterface(EchoService.class.getName());
    echoService.setRef(new EchoServiceImpl());
    // echoService.setRegistries(Arrays.asList(interfaceRegistry, serviceRegistry));
    ServiceConfig<UserService> userService = new ServiceConfig<>();
    userService.setInterface(UserService.class.getName());
    userService.setRef(new UserServiceImpl());
    userService.setProtocol(restProtocol);
    // userService.setRegistries(Arrays.asList(interfaceRegistry, serviceRegistry));
    ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-provider-demo");
    applicationConfig.setMetadataType("remote");
    DubboBootstrap.getInstance().application(applicationConfig).registries(Arrays.asList(interfaceRegistry, serviceRegistry)).protocol(builder -> builder.port(-1).name("dubbo")).metadataReport(new MetadataReportConfig("zookeeper://127.0.0.1:2181")).service(echoService).service(userService).start().await();
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) Arrays(java.util.Arrays) UserServiceImpl(org.apache.dubbo.config.bootstrap.rest.UserServiceImpl) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) RegistryConfig(org.apache.dubbo.config.RegistryConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) ServiceConfig(org.apache.dubbo.config.ServiceConfig) MetadataReportConfig(org.apache.dubbo.config.MetadataReportConfig) UserService(org.apache.dubbo.config.bootstrap.rest.UserService) ServiceConfig(org.apache.dubbo.config.ServiceConfig) UserService(org.apache.dubbo.config.bootstrap.rest.UserService) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) UserServiceImpl(org.apache.dubbo.config.bootstrap.rest.UserServiceImpl) MetadataReportConfig(org.apache.dubbo.config.MetadataReportConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig)

Example 7 with MetadataReportConfig

use of org.apache.dubbo.config.MetadataReportConfig in project dubbo by apache.

the class AbstractInterfaceBuilderTest method metadataReportConfig.

@Test
void metadataReportConfig() {
    MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
    InterfaceBuilder builder = new InterfaceBuilder();
    builder.metadataReportConfig(metadataReportConfig);
    Assertions.assertEquals(metadataReportConfig, builder.build().getMetadataReportConfig());
}
Also used : MetadataReportConfig(org.apache.dubbo.config.MetadataReportConfig) Test(org.junit.jupiter.api.Test)

Example 8 with MetadataReportConfig

use of org.apache.dubbo.config.MetadataReportConfig in project framework by wcnnkh.

the class XmlDubboInitializer method postProcessApplication.

@Override
public void postProcessApplication(ConfigurableApplication application) throws Throwable {
    if (application.isInstance(DubboConfigure.class)) {
        DubboConfigure configure = application.getInstance(DubboConfigure.class);
        List<RegistryConfig> registryConfigs = configure.getRegistryConfigList();
        for (ApplicationConfig config : configure.getApplicationConfigList()) {
            config.setRegistries(registryConfigs);
            ApplicationModel.defaultModel().getApplicationConfigManager().setApplication(config);
        }
        for (ProtocolConfig config : configure.getProtocolConfigList()) {
            ApplicationModel.defaultModel().getApplicationConfigManager().addProtocol(config);
        }
        for (MetadataReportConfig config : configure.getMetadataReportConfigList()) {
            ApplicationModel.defaultModel().getApplicationConfigManager().addMetadataReport(config);
        }
        for (SslConfig config : configure.getSslConfigList()) {
            ApplicationModel.defaultModel().getApplicationConfigManager().setSsl(config);
        }
        for (MetricsConfig config : configure.getMetricsConfigList()) {
            ApplicationModel.defaultModel().getApplicationConfigManager().setMetrics(config);
        }
        for (MonitorConfig config : configure.getMonitorConfigList()) {
            ApplicationModel.defaultModel().getApplicationConfigManager().setMonitor(config);
        }
        for (ModuleConfig config : configure.getModuleConfigList()) {
            ApplicationModel.defaultModel().getDefaultModule().getConfigManager().setModule(config);
        }
        for (ProviderConfig config : configure.getProviderConfigList()) {
            ApplicationModel.defaultModel().getDefaultModule().getConfigManager().addProvider(config);
        }
        for (ConsumerConfig config : configure.getConsumerConfigList()) {
            ApplicationModel.defaultModel().getDefaultModule().getConfigManager().addConsumer(config);
        }
    }
    if (application.isInstance(DubboServiceConfigure.class)) {
        DubboServiceConfigure configure = application.getInstance(DubboServiceConfigure.class);
        for (ServiceConfig<?> config : configure.getServiceConfigList()) {
            // TODO 按理说不用设置的{@link org.apache.dubbo.config.AbstractMethodConfig},但在升级到3.0.5时出现了异常,还未找到原因(可能是classloader的问题)
            config.setScopeModel(ApplicationModel.defaultModel().getDefaultModule());
            config.export();
        }
    }
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ProviderConfig(org.apache.dubbo.config.ProviderConfig) MetadataReportConfig(org.apache.dubbo.config.MetadataReportConfig) ModuleConfig(org.apache.dubbo.config.ModuleConfig) MetricsConfig(org.apache.dubbo.config.MetricsConfig) SslConfig(org.apache.dubbo.config.SslConfig) DubboServiceConfigure(io.basc.framework.dubbo.DubboServiceConfigure) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) DubboConfigure(io.basc.framework.dubbo.DubboConfigure) ConsumerConfig(org.apache.dubbo.config.ConsumerConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) MonitorConfig(org.apache.dubbo.config.MonitorConfig)

Example 9 with MetadataReportConfig

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

the class AbstractInterfaceBuilderTest method metadataReportConfig.

@Test
void metadataReportConfig() {
    MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
    InterfaceBuilder builder = new InterfaceBuilder();
    builder.metadataReportConfig(metadataReportConfig);
    Assertions.assertEquals(metadataReportConfig, builder.build().getMetadataReportConfig());
}
Also used : MetadataReportConfig(org.apache.dubbo.config.MetadataReportConfig) Test(org.junit.jupiter.api.Test)

Example 10 with MetadataReportConfig

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

the class MetadataReportBuilderTest method build.

@Test
void build() {
    MetadataReportBuilder builder = new MetadataReportBuilder();
    builder.address("address").username("username").password("password").timeout(1000).group("group").retryTimes(1).retryPeriod(2).cycleReport(true).syncReport(false).file("file").appendParameter("default.num", "one").id("id").prefix("prefix");
    MetadataReportConfig config = builder.build();
    MetadataReportConfig config2 = builder.build();
    Assertions.assertTrue(config.getCycleReport());
    Assertions.assertFalse(config.getSyncReport());
    Assertions.assertEquals(1000, config.getTimeout());
    Assertions.assertEquals(1, config.getRetryTimes());
    Assertions.assertEquals(2, config.getRetryPeriod());
    Assertions.assertEquals("address", config.getAddress());
    Assertions.assertEquals("username", config.getUsername());
    Assertions.assertEquals("password", config.getPassword());
    Assertions.assertEquals("group", config.getGroup());
    Assertions.assertEquals("file", config.getFile());
    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 : MetadataReportConfig(org.apache.dubbo.config.MetadataReportConfig) Test(org.junit.jupiter.api.Test)

Aggregations

MetadataReportConfig (org.apache.dubbo.config.MetadataReportConfig)17 ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)7 Test (org.junit.jupiter.api.Test)6 RegistryConfig (org.apache.dubbo.config.RegistryConfig)5 ConsumerConfig (org.apache.dubbo.config.ConsumerConfig)3 ModuleConfig (org.apache.dubbo.config.ModuleConfig)3 MonitorConfig (org.apache.dubbo.config.MonitorConfig)3 ProtocolConfig (org.apache.dubbo.config.ProtocolConfig)3 ProviderConfig (org.apache.dubbo.config.ProviderConfig)3 Arrays (java.util.Arrays)2 AbstractInterfaceConfig (org.apache.dubbo.config.AbstractInterfaceConfig)2 ConfigCenterConfig (org.apache.dubbo.config.ConfigCenterConfig)2 ServiceConfig (org.apache.dubbo.config.ServiceConfig)2 UserService (org.apache.dubbo.config.bootstrap.rest.UserService)2 UserServiceImpl (org.apache.dubbo.config.bootstrap.rest.UserServiceImpl)2 DubboConfigure (io.basc.framework.dubbo.DubboConfigure)1 DubboServiceConfigure (io.basc.framework.dubbo.DubboServiceConfigure)1 MetricsConfig (org.apache.dubbo.config.MetricsConfig)1 SslConfig (org.apache.dubbo.config.SslConfig)1