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