Search in sources :

Example 1 with MonitorConfig

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

the class DubboBootstrapTest method testLoadMonitor.

@Test
public void testLoadMonitor() {
    System.setProperty("dubbo.monitor.address", "monitor-addr:12080");
    System.setProperty("dubbo.monitor.protocol", "monitor");
    AbstractInterfaceConfigTest.InterfaceConfig interfaceConfig = new AbstractInterfaceConfigTest.InterfaceConfig();
    interfaceConfig.setApplication(new ApplicationConfig("testLoadMonitor"));
    interfaceConfig.setMonitor(new MonitorConfig());
    URL url = ConfigValidationUtils.loadMonitor(interfaceConfig, new URL("dubbo", "addr1", 9090));
    Assertions.assertEquals("monitor-addr:12080", url.getAddress());
    Assertions.assertEquals(MonitorService.class.getName(), url.getParameter("interface"));
    Assertions.assertNotNull(url.getParameter("dubbo"));
    Assertions.assertNotNull(url.getParameter("pid"));
    Assertions.assertNotNull(url.getParameter("timestamp"));
}
Also used : AbstractInterfaceConfigTest(org.apache.dubbo.config.AbstractInterfaceConfigTest) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) MonitorService(org.apache.dubbo.monitor.MonitorService) URL(org.apache.dubbo.common.URL) MonitorConfig(org.apache.dubbo.config.MonitorConfig) AbstractInterfaceConfigTest(org.apache.dubbo.config.AbstractInterfaceConfigTest) Test(org.junit.jupiter.api.Test)

Example 2 with MonitorConfig

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

the class MonitorBuilderTest method build.

@Test
void build() {
    MonitorBuilder builder = new MonitorBuilder();
    builder.protocol("protocol").address("address").group("group").interval("interval").isDefault(true).password("password").username("username").version("version").appendParameter("default.num", "one").id("id").prefix("prefix");
    MonitorConfig config = builder.build();
    MonitorConfig config2 = builder.build();
    Assertions.assertEquals("protocol", config.getProtocol());
    Assertions.assertEquals("address", config.getAddress());
    Assertions.assertEquals("group", config.getGroup());
    Assertions.assertEquals("interval", config.getInterval());
    Assertions.assertEquals("password", config.getPassword());
    Assertions.assertEquals("username", config.getUsername());
    Assertions.assertEquals("version", config.getVersion());
    Assertions.assertTrue(config.isDefault());
    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 : MonitorConfig(org.apache.dubbo.config.MonitorConfig) Test(org.junit.jupiter.api.Test)

Example 3 with MonitorConfig

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

the class AbstractInterfaceBuilderTest method monitor1.

@Test
void monitor1() {
    MonitorConfig monitorConfig = new MonitorConfig("123");
    InterfaceBuilder builder = new InterfaceBuilder();
    builder.monitor(monitorConfig);
    Assertions.assertEquals(monitorConfig, builder.build().getMonitor());
}
Also used : MonitorConfig(org.apache.dubbo.config.MonitorConfig) Test(org.junit.jupiter.api.Test)

Example 4 with MonitorConfig

use of org.apache.dubbo.config.MonitorConfig 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 5 with MonitorConfig

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

the class ApplicationBuilderTest method build.

@Test
void build() {
    MonitorConfig monitor = new MonitorConfig("monitor-addr");
    RegistryConfig registry = new RegistryConfig();
    ApplicationBuilder builder = new ApplicationBuilder();
    builder.id("id").prefix("prefix").name("name").version("version").owner("owner").organization("organization").architecture("architecture").environment("develop").compiler("compiler").logger("log4j").monitor(monitor).isDefault(false).dumpDirectory("dumpDirectory").qosEnable(true).qosPort(8080).qosAcceptForeignIp(false).shutwait("shutwait").registryIds("registryIds").addRegistry(registry).appendParameter("default.num", "one").metadataServicePort(12345);
    ApplicationConfig config = builder.build();
    ApplicationConfig config2 = builder.build();
    Assertions.assertEquals("id", config.getId());
    Assertions.assertEquals("prefix", config.getPrefix());
    Assertions.assertEquals("name", config.getName());
    Assertions.assertEquals("version", config.getVersion());
    Assertions.assertEquals("owner", config.getOwner());
    Assertions.assertEquals("organization", config.getOrganization());
    Assertions.assertEquals("architecture", config.getArchitecture());
    Assertions.assertEquals("develop", config.getEnvironment());
    Assertions.assertEquals("compiler", config.getCompiler());
    Assertions.assertEquals("log4j", config.getLogger());
    Assertions.assertSame(monitor, config.getMonitor());
    Assertions.assertFalse(config.isDefault());
    Assertions.assertEquals("dumpDirectory", config.getDumpDirectory());
    Assertions.assertTrue(config.getQosEnable());
    Assertions.assertEquals(8080, config.getQosPort());
    Assertions.assertFalse(config.getQosAcceptForeignIp());
    Assertions.assertEquals("shutwait", config.getShutwait());
    Assertions.assertEquals("registryIds", config.getRegistryIds());
    Assertions.assertSame(registry, config.getRegistry());
    Assertions.assertTrue(config.getParameters().containsKey("default.num"));
    Assertions.assertEquals("one", config.getParameters().get("default.num"));
    Assertions.assertEquals(12345, config.getMetadataServicePort());
    Assertions.assertNotSame(config, config2);
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) MonitorConfig(org.apache.dubbo.config.MonitorConfig) Test(org.junit.jupiter.api.Test)

Aggregations

MonitorConfig (org.apache.dubbo.config.MonitorConfig)16 Test (org.junit.jupiter.api.Test)11 ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)5 RegistryConfig (org.apache.dubbo.config.RegistryConfig)4 ModuleConfig (org.apache.dubbo.config.ModuleConfig)3 MonitorService (org.apache.dubbo.monitor.MonitorService)2 HashMap (java.util.HashMap)1 URL (org.apache.dubbo.common.URL)1 AbstractInterfaceConfig (org.apache.dubbo.config.AbstractInterfaceConfig)1 AbstractInterfaceConfigTest (org.apache.dubbo.config.AbstractInterfaceConfigTest)1 ConfigCenterConfig (org.apache.dubbo.config.ConfigCenterConfig)1 ConsumerConfig (org.apache.dubbo.config.ConsumerConfig)1 MetadataReportConfig (org.apache.dubbo.config.MetadataReportConfig)1 ProtocolConfig (org.apache.dubbo.config.ProtocolConfig)1 ProviderConfig (org.apache.dubbo.config.ProviderConfig)1 MonitorFactory (org.apache.dubbo.monitor.MonitorFactory)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1