use of org.apache.dubbo.config.ProviderConfig in project dubbo by alibaba.
the class ConfigTest method testAppendFilter.
@Test
public void testAppendFilter() throws Exception {
ApplicationConfig application = new ApplicationConfig("provider");
ProviderConfig provider = new ProviderConfig();
provider.setFilter("classloader,monitor");
ConsumerConfig consumer = new ConsumerConfig();
consumer.setFilter("classloader,monitor");
ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
service.setFilter("accesslog,trace");
service.setProvider(provider);
service.setProtocol(new ProtocolConfig("dubbo", 20880));
service.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
service.setInterface(DemoService.class);
service.setRef(new DemoServiceImpl());
ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>();
reference.setFilter("accesslog,trace");
reference.setConsumer(consumer);
reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
reference.setInterface(DemoService.class);
reference.setUrl("dubbo://" + NetUtils.getLocalHost() + ":20880?" + DemoService.class.getName() + "?check=false");
DubboBootstrap bootstrap = DubboBootstrap.getInstance().application(application).provider(provider).service(service).reference(reference).start();
try {
List<URL> urls = service.getExportedUrls();
assertNotNull(urls);
assertEquals(1, urls.size());
assertEquals("classloader,monitor,accesslog,trace", urls.get(0).getParameter("service.filter"));
urls = reference.getExportedUrls();
assertNotNull(urls);
assertEquals(1, urls.size());
assertEquals("classloader,monitor,accesslog,trace", urls.get(0).getParameter("reference.filter"));
} finally {
bootstrap.stop();
}
}
use of org.apache.dubbo.config.ProviderConfig in project dubbo by alibaba.
the class ProviderBuilderTest method build.
@Test
void build() {
ProviderBuilder builder = new ProviderBuilder();
builder.host("host").port(8080).contextPath("contextpath").threadPool("mockthreadpool").threads(2).ioThreads(3).queues(4).accepts(5).codec("mockcodec").charset("utf-8").payload(6).buffer(1024).transporter("mocktransporter").exchanger("mockexchanger").dispatcher("mockdispatcher").networker("networker").server("server").client("client").telnet("mocktelnethandler").prompt("prompt").status("mockstatuschecker").wait(Integer.valueOf(1000)).isDefault(true).id("id").prefix("prefix");
ProviderConfig config = builder.build();
ProviderConfig config2 = builder.build();
Assertions.assertEquals(8080, config.getPort());
Assertions.assertEquals(2, config.getThreads());
Assertions.assertEquals(3, config.getIothreads());
Assertions.assertEquals(4, config.getQueues());
Assertions.assertEquals(5, config.getAccepts());
Assertions.assertEquals(6, config.getPayload());
Assertions.assertEquals(1024, config.getBuffer());
Assertions.assertEquals(1000, config.getWait());
Assertions.assertEquals("host", config.getHost());
Assertions.assertEquals("contextpath", config.getContextpath());
Assertions.assertEquals("mockthreadpool", config.getThreadpool());
Assertions.assertEquals("mockcodec", config.getCodec());
Assertions.assertEquals("utf-8", config.getCharset());
Assertions.assertEquals("mocktransporter", config.getTransporter());
Assertions.assertEquals("mockexchanger", config.getExchanger());
Assertions.assertEquals("mockdispatcher", config.getDispatcher());
Assertions.assertEquals("networker", config.getNetworker());
Assertions.assertEquals("server", config.getServer());
Assertions.assertEquals("client", config.getClient());
Assertions.assertEquals("mocktelnethandler", config.getTelnet());
Assertions.assertEquals("prompt", config.getPrompt());
Assertions.assertEquals("mockstatuschecker", config.getStatus());
Assertions.assertTrue(config.isDefault());
Assertions.assertEquals("id", config.getId());
Assertions.assertEquals("prefix", config.getPrefix());
Assertions.assertNotSame(config, config2);
}
use of org.apache.dubbo.config.ProviderConfig in project dubbo by alibaba.
the class DubboNamespaceHandlerTest method testTimeoutConfig.
@Test
public void testTimeoutConfig() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/provider-nested-service.xml");
ctx.start();
Map<String, ProviderConfig> providerConfigMap = ctx.getBeansOfType(ProviderConfig.class);
assertThat(providerConfigMap.get("org.apache.dubbo.config.ProviderConfig").getTimeout(), is(2000));
ctx.close();
}
use of org.apache.dubbo.config.ProviderConfig in project dubbo by alibaba.
the class DubboBootstrap method checkGlobalConfigs.
private void checkGlobalConfigs() {
// check Application
ConfigValidationUtils.validateApplicationConfig(getApplication());
// check Metadata
Collection<MetadataReportConfig> metadatas = configManager.getMetadataConfigs();
if (CollectionUtils.isEmpty(metadatas)) {
MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
metadataReportConfig.refresh();
if (metadataReportConfig.isValid()) {
configManager.addMetadataReport(metadataReportConfig);
metadatas = configManager.getMetadataConfigs();
}
}
if (CollectionUtils.isNotEmpty(metadatas)) {
for (MetadataReportConfig metadataReportConfig : metadatas) {
metadataReportConfig.refresh();
ConfigValidationUtils.validateMetadataConfig(metadataReportConfig);
}
}
// check Provider
Collection<ProviderConfig> providers = configManager.getProviders();
if (CollectionUtils.isEmpty(providers)) {
configManager.getDefaultProvider().orElseGet(() -> {
ProviderConfig providerConfig = new ProviderConfig();
configManager.addProvider(providerConfig);
providerConfig.refresh();
return providerConfig;
});
}
for (ProviderConfig providerConfig : configManager.getProviders()) {
ConfigValidationUtils.validateProviderConfig(providerConfig);
}
// check Consumer
Collection<ConsumerConfig> consumers = configManager.getConsumers();
if (CollectionUtils.isEmpty(consumers)) {
configManager.getDefaultConsumer().orElseGet(() -> {
ConsumerConfig consumerConfig = new ConsumerConfig();
configManager.addConsumer(consumerConfig);
consumerConfig.refresh();
return consumerConfig;
});
}
for (ConsumerConfig consumerConfig : configManager.getConsumers()) {
ConfigValidationUtils.validateConsumerConfig(consumerConfig);
}
// check Monitor
ConfigValidationUtils.validateMonitorConfig(getMonitor());
// check Metrics
ConfigValidationUtils.validateMetricsConfig(getMetrics());
// check Module
ConfigValidationUtils.validateModuleConfig(getModule());
// check Ssl
ConfigValidationUtils.validateSslConfig(getSsl());
}
use of org.apache.dubbo.config.ProviderConfig in project dubbo by alibaba.
the class ProviderBuilder method build.
public ProviderConfig build() {
ProviderConfig provider = new ProviderConfig();
super.build(provider);
provider.setHost(host);
provider.setPort(port);
provider.setContextpath(contextpath);
provider.setThreadpool(threadpool);
provider.setThreads(threads);
provider.setIothreads(iothreads);
provider.setQueues(queues);
provider.setAccepts(accepts);
provider.setCodec(codec);
provider.setPayload(payload);
provider.setCharset(charset);
provider.setBuffer(buffer);
provider.setTransporter(transporter);
provider.setExchanger(exchanger);
provider.setDispatcher(dispatcher);
provider.setNetworker(networker);
provider.setServer(server);
provider.setClient(client);
provider.setTelnet(telnet);
provider.setPrompt(prompt);
provider.setStatus(status);
provider.setWait(wait);
provider.setDefault(isDefault);
return provider;
}
Aggregations