com.alibaba.dubbo.registry.integration.RegistryProtocol Java Examples
The following examples show how to use
com.alibaba.dubbo.registry.integration.RegistryProtocol.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testExport() { RegistryProtocol registryProtocol = new RegistryProtocol(); registryProtocol.setCluster(new FailfastCluster()); registryProtocol.setRegistryFactory(ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension()); Protocol dubboProtocol = DubboProtocol.getDubboProtocol(); registryProtocol.setProtocol(dubboProtocol); URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); DubboInvoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class, newRegistryUrl, new ExchangeClient[] { new MockedClient("10.20.20.20", 2222, true) }); Exporter<DemoService> exporter = registryProtocol.export(invoker); Exporter<DemoService> exporter2 = registryProtocol.export(invoker); //同一个invoker,多次export的exporter不同 Assert.assertNotSame(exporter, exporter2); exporter.unexport(); exporter2.unexport(); }
Example #2
Source File: RegistryProtocolTest.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
@Test public void testNotifyOverride() throws Exception{ URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); Invoker<RegistryProtocolTest> invoker = new MockInvoker<RegistryProtocolTest>(RegistryProtocolTest.class, newRegistryUrl); Exporter<?> exporter = protocol.export(invoker); RegistryProtocol rprotocol = RegistryProtocol.getRegistryProtocol(); NotifyListener listener = getListener(rprotocol); List<URL> urls = new ArrayList<URL>(); urls.add(URL.valueOf("override://0.0.0.0/?timeout=1000")); urls.add(URL.valueOf("override://0.0.0.0/"+ service + "?timeout=100")); urls.add(URL.valueOf("override://0.0.0.0/"+ service + "?x=y")); listener.notify(urls); assertEquals(true, exporter.getInvoker().isAvailable()); assertEquals("100", exporter.getInvoker().getUrl().getParameter("timeout")); assertEquals("y", exporter.getInvoker().getUrl().getParameter("x")); exporter.unexport(); assertEquals(false, exporter.getInvoker().isAvailable()); destroyRegistryProtocol(); }
Example #3
Source File: RegistryProtocolTest.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
@Test public void testExport() { RegistryProtocol registryProtocol = new RegistryProtocol(); registryProtocol.setCluster(new FailfastCluster()); registryProtocol.setRegistryFactory(ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension()); Protocol dubboProtocol = DubboProtocol.getDubboProtocol(); registryProtocol.setProtocol(dubboProtocol); URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); DubboInvoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class, newRegistryUrl, new ExchangeClient[] { new MockedClient("10.20.20.20", 2222, true) }); Exporter<DemoService> exporter = registryProtocol.export(invoker); Exporter<DemoService> exporter2 = registryProtocol.export(invoker); //同一个invoker,多次export的exporter不同 Assert.assertNotSame(exporter, exporter2); exporter.unexport(); exporter2.unexport(); }
Example #4
Source File: RegistryProtocolTest.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
/** * 服务名称不匹配,不能override invoker * 服务名称匹配,服务版本号不匹配 */ @Test public void testNotifyOverride_notmatch() throws Exception{ URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); Invoker<RegistryProtocolTest> invoker = new MockInvoker<RegistryProtocolTest>(RegistryProtocolTest.class, newRegistryUrl); Exporter<?> exporter = protocol.export(invoker); RegistryProtocol rprotocol = RegistryProtocol.getRegistryProtocol(); NotifyListener listener = getListener(rprotocol); List<URL> urls = new ArrayList<URL>(); urls.add(URL.valueOf("override://0.0.0.0/com.alibaba.dubbo.registry.protocol.HackService?timeout=100")); listener.notify(urls); assertEquals(true, exporter.getInvoker().isAvailable()); assertEquals(null, exporter.getInvoker().getUrl().getParameter("timeout")); exporter.unexport(); destroyRegistryProtocol(); }
Example #5
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testExport() { RegistryProtocol registryProtocol = new RegistryProtocol(); registryProtocol.setCluster(new FailfastCluster()); registryProtocol.setRegistryFactory(ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension()); Protocol dubboProtocol = DubboProtocol.getDubboProtocol(); registryProtocol.setProtocol(dubboProtocol); URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); DubboInvoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class, newRegistryUrl, new ExchangeClient[] { new MockedClient("10.20.20.20", 2222, true) }); Exporter<DemoService> exporter = registryProtocol.export(invoker); Exporter<DemoService> exporter2 = registryProtocol.export(invoker); //同一个invoker,多次export的exporter不同 Assert.assertNotSame(exporter, exporter2); exporter.unexport(); exporter2.unexport(); }
Example #6
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testNotifyOverride() throws Exception{ URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); Invoker<RegistryProtocolTest> invoker = new MockInvoker<RegistryProtocolTest>(RegistryProtocolTest.class, newRegistryUrl); Exporter<?> exporter = protocol.export(invoker); RegistryProtocol rprotocol = RegistryProtocol.getRegistryProtocol(); NotifyListener listener = getListener(rprotocol); List<URL> urls = new ArrayList<URL>(); urls.add(URL.valueOf("override://0.0.0.0/?timeout=1000")); urls.add(URL.valueOf("override://0.0.0.0/"+ service + "?timeout=100")); urls.add(URL.valueOf("override://0.0.0.0/"+ service + "?x=y")); listener.notify(urls); assertEquals(true, exporter.getInvoker().isAvailable()); assertEquals("100", exporter.getInvoker().getUrl().getParameter("timeout")); assertEquals("y", exporter.getInvoker().getUrl().getParameter("x")); exporter.unexport(); assertEquals(false, exporter.getInvoker().isAvailable()); destroyRegistryProtocol(); }
Example #7
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 6 votes |
/** * 服务名称不匹配,不能override invoker * 服务名称匹配,服务版本号不匹配 */ @Test public void testNotifyOverride_notmatch() throws Exception{ URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); Invoker<RegistryProtocolTest> invoker = new MockInvoker<RegistryProtocolTest>(RegistryProtocolTest.class, newRegistryUrl); Exporter<?> exporter = protocol.export(invoker); RegistryProtocol rprotocol = RegistryProtocol.getRegistryProtocol(); NotifyListener listener = getListener(rprotocol); List<URL> urls = new ArrayList<URL>(); urls.add(URL.valueOf("override://0.0.0.0/com.alibaba.dubbo.registry.protocol.HackService?timeout=100")); listener.notify(urls); assertEquals(true, exporter.getInvoker().isAvailable()); assertEquals(null, exporter.getInvoker().getUrl().getParameter("timeout")); exporter.unexport(); destroyRegistryProtocol(); }
Example #8
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testNotifyOverride() throws Exception{ URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); Invoker<RegistryProtocolTest> invoker = new MockInvoker<RegistryProtocolTest>(RegistryProtocolTest.class, newRegistryUrl); Exporter<?> exporter = protocol.export(invoker); RegistryProtocol rprotocol = RegistryProtocol.getRegistryProtocol(); NotifyListener listener = getListener(rprotocol); List<URL> urls = new ArrayList<URL>(); urls.add(URL.valueOf("override://0.0.0.0/?timeout=1000")); urls.add(URL.valueOf("override://0.0.0.0/"+ service + "?timeout=100")); urls.add(URL.valueOf("override://0.0.0.0/"+ service + "?x=y")); listener.notify(urls); assertEquals(true, exporter.getInvoker().isAvailable()); assertEquals("100", exporter.getInvoker().getUrl().getParameter("timeout")); assertEquals("y", exporter.getInvoker().getUrl().getParameter("x")); exporter.unexport(); assertEquals(false, exporter.getInvoker().isAvailable()); destroyRegistryProtocol(); }
Example #9
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 6 votes |
/** * 服务名称不匹配,不能override invoker * 服务名称匹配,服务版本号不匹配 */ @Test public void testNotifyOverride_notmatch() throws Exception{ URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); Invoker<RegistryProtocolTest> invoker = new MockInvoker<RegistryProtocolTest>(RegistryProtocolTest.class, newRegistryUrl); Exporter<?> exporter = protocol.export(invoker); RegistryProtocol rprotocol = RegistryProtocol.getRegistryProtocol(); NotifyListener listener = getListener(rprotocol); List<URL> urls = new ArrayList<URL>(); urls.add(URL.valueOf("override://0.0.0.0/com.alibaba.dubbo.registry.protocol.HackService?timeout=100")); listener.notify(urls); assertEquals(true, exporter.getInvoker().isAvailable()); assertEquals(null, exporter.getInvoker().getUrl().getParameter("timeout")); exporter.unexport(); destroyRegistryProtocol(); }
Example #10
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testExport() { RegistryProtocol registryProtocol = new RegistryProtocol(); registryProtocol.setCluster(new FailfastCluster()); registryProtocol.setRegistryFactory(ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension()); Protocol dubboProtocol = DubboProtocol.getDubboProtocol(); registryProtocol.setProtocol(dubboProtocol); URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); DubboInvoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class, newRegistryUrl, new ExchangeClient[] { new MockedClient("10.20.20.20", 2222, true) }); Exporter<DemoService> exporter = registryProtocol.export(invoker); Exporter<DemoService> exporter2 = registryProtocol.export(invoker); //同一个invoker,多次export的exporter不同 Assert.assertNotSame(exporter, exporter2); exporter.unexport(); exporter2.unexport(); }
Example #11
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testNotifyOverride() throws Exception{ URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); Invoker<RegistryProtocolTest> invoker = new MockInvoker<RegistryProtocolTest>(RegistryProtocolTest.class, newRegistryUrl); Exporter<?> exporter = protocol.export(invoker); RegistryProtocol rprotocol = RegistryProtocol.getRegistryProtocol(); NotifyListener listener = getListener(rprotocol); List<URL> urls = new ArrayList<URL>(); urls.add(URL.valueOf("override://0.0.0.0/?timeout=1000")); urls.add(URL.valueOf("override://0.0.0.0/"+ service + "?timeout=100")); urls.add(URL.valueOf("override://0.0.0.0/"+ service + "?x=y")); listener.notify(urls); assertEquals(true, exporter.getInvoker().isAvailable()); assertEquals("100", exporter.getInvoker().getUrl().getParameter("timeout")); assertEquals("y", exporter.getInvoker().getUrl().getParameter("x")); exporter.unexport(); assertEquals(false, exporter.getInvoker().isAvailable()); destroyRegistryProtocol(); }
Example #12
Source File: RegistryProtocolTest.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
/** * The name of the service does not match and can't override invoker * Service name matching, service version number mismatch */ @Test public void testNotifyOverride_notmatch() throws Exception { URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); Invoker<RegistryProtocolTest> invoker = new MockInvoker<RegistryProtocolTest>(RegistryProtocolTest.class, newRegistryUrl); Exporter<?> exporter = protocol.export(invoker); RegistryProtocol rprotocol = RegistryProtocol.getRegistryProtocol(); NotifyListener listener = getListener(rprotocol); List<URL> urls = new ArrayList<URL>(); urls.add(URL.valueOf("override://0.0.0.0/com.alibaba.dubbo.registry.protocol.HackService?timeout=100")); listener.notify(urls); assertEquals(true, exporter.getInvoker().isAvailable()); assertEquals(null, exporter.getInvoker().getUrl().getParameter("timeout")); exporter.unexport(); destroyRegistryProtocol(); }
Example #13
Source File: RegistryProtocolTest.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
@Test public void testNotifyOverride() throws Exception { URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); Invoker<RegistryProtocolTest> invoker = new MockInvoker<RegistryProtocolTest>(RegistryProtocolTest.class, newRegistryUrl); Exporter<?> exporter = protocol.export(invoker); RegistryProtocol rprotocol = RegistryProtocol.getRegistryProtocol(); NotifyListener listener = getListener(rprotocol); List<URL> urls = new ArrayList<URL>(); urls.add(URL.valueOf("override://0.0.0.0/?timeout=1000")); urls.add(URL.valueOf("override://0.0.0.0/" + service + "?timeout=100")); urls.add(URL.valueOf("override://0.0.0.0/" + service + "?x=y")); listener.notify(urls); assertEquals(true, exporter.getInvoker().isAvailable()); assertEquals("100", exporter.getInvoker().getUrl().getParameter("timeout")); assertEquals("y", exporter.getInvoker().getUrl().getParameter("x")); exporter.unexport(); // int timeout = ConfigUtils.getServerShutdownTimeout(); // Thread.sleep(timeout + 1000); // assertEquals(false, exporter.getInvoker().isAvailable()); destroyRegistryProtocol(); }
Example #14
Source File: RegistryProtocolTest.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
@Test public void testExport() { RegistryProtocol registryProtocol = new RegistryProtocol(); registryProtocol.setCluster(new FailfastCluster()); registryProtocol.setRegistryFactory(ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension()); Protocol dubboProtocol = DubboProtocol.getDubboProtocol(); registryProtocol.setProtocol(dubboProtocol); URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); DubboInvoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class, newRegistryUrl, new ExchangeClient[]{new MockedClient("10.20.20.20", 2222, true)}); Exporter<DemoService> exporter = registryProtocol.export(invoker); Exporter<DemoService> exporter2 = registryProtocol.export(invoker); //The same invoker, exporter that multiple exported are different Assert.assertNotSame(exporter, exporter2); exporter.unexport(); exporter2.unexport(); }
Example #15
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 6 votes |
/** * 服务名称不匹配,不能override invoker * 服务名称匹配,服务版本号不匹配 */ @Test public void testNotifyOverride_notmatch() throws Exception{ URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); Invoker<RegistryProtocolTest> invoker = new MockInvoker<RegistryProtocolTest>(RegistryProtocolTest.class, newRegistryUrl); Exporter<?> exporter = protocol.export(invoker); RegistryProtocol rprotocol = RegistryProtocol.getRegistryProtocol(); NotifyListener listener = getListener(rprotocol); List<URL> urls = new ArrayList<URL>(); urls.add(URL.valueOf("override://0.0.0.0/com.alibaba.dubbo.registry.protocol.HackService?timeout=100")); listener.notify(urls); assertEquals(true, exporter.getInvoker().isAvailable()); assertEquals(null, exporter.getInvoker().getUrl().getParameter("timeout")); exporter.unexport(); destroyRegistryProtocol(); }
Example #16
Source File: RegistryProtocolTest.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void testExportUrlNull() { RegistryProtocol registryProtocol = new RegistryProtocol(); registryProtocol.setCluster(new FailfastCluster()); Protocol dubboProtocol = DubboProtocol.getDubboProtocol(); registryProtocol.setProtocol(dubboProtocol); Invoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class, registryUrl, new ExchangeClient[]{new MockedClient("10.20.20.20", 2222, true)}); registryProtocol.export(invoker); }
Example #17
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void testExportUrlNull() { RegistryProtocol registryProtocol = new RegistryProtocol(); registryProtocol.setCluster(new FailfastCluster()); Protocol dubboProtocol = DubboProtocol.getDubboProtocol(); registryProtocol.setProtocol(dubboProtocol); Invoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class, registryUrl, new ExchangeClient[] { new MockedClient("10.20.20.20", 2222, true) }); registryProtocol.export(invoker); }
Example #18
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void testExportUrlNull() { RegistryProtocol registryProtocol = new RegistryProtocol(); registryProtocol.setCluster(new FailfastCluster()); Protocol dubboProtocol = DubboProtocol.getDubboProtocol(); registryProtocol.setProtocol(dubboProtocol); Invoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class, registryUrl, new ExchangeClient[] { new MockedClient("10.20.20.20", 2222, true) }); registryProtocol.export(invoker); }
Example #19
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void testExportUrlNull() { RegistryProtocol registryProtocol = new RegistryProtocol(); registryProtocol.setCluster(new FailfastCluster()); Protocol dubboProtocol = DubboProtocol.getDubboProtocol(); registryProtocol.setProtocol(dubboProtocol); Invoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class, registryUrl, new ExchangeClient[] { new MockedClient("10.20.20.20", 2222, true) }); registryProtocol.export(invoker); }
Example #20
Source File: RegistryProtocolTest.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void testExportUrlNull() { RegistryProtocol registryProtocol = new RegistryProtocol(); registryProtocol.setCluster(new FailfastCluster()); Protocol dubboProtocol = DubboProtocol.getDubboProtocol(); registryProtocol.setProtocol(dubboProtocol); Invoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class, registryUrl, new ExchangeClient[] { new MockedClient("10.20.20.20", 2222, true) }); registryProtocol.export(invoker); }
Example #21
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 4 votes |
private void destroyRegistryProtocol(){ Protocol registry = RegistryProtocol.getRegistryProtocol(); registry.destroy(); }
Example #22
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 4 votes |
private NotifyListener getListener(RegistryProtocol protocol) throws Exception { return protocol.getOverrideListeners().values().iterator().next(); }
Example #23
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 4 votes |
private void destroyRegistryProtocol(){ Protocol registry = RegistryProtocol.getRegistryProtocol(); registry.destroy(); }
Example #24
Source File: RegistryProtocolTest.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
@Test public void testDefaultPort() { RegistryProtocol registryProtocol = new RegistryProtocol(); assertEquals(9090, registryProtocol.getDefaultPort()); }
Example #25
Source File: RegistryProtocolTest.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
private void destroyRegistryProtocol() { Protocol registry = RegistryProtocol.getRegistryProtocol(); registry.destroy(); }
Example #26
Source File: RegistryProtocolTest.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
private NotifyListener getListener(RegistryProtocol protocol) throws Exception { return protocol.getOverrideListeners().values().iterator().next(); }
Example #27
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testDefaultPort() { RegistryProtocol registryProtocol = new RegistryProtocol(); assertEquals(9090, registryProtocol.getDefaultPort()); }
Example #28
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testDefaultPort() { RegistryProtocol registryProtocol = new RegistryProtocol(); assertEquals(9090, registryProtocol.getDefaultPort()); }
Example #29
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 4 votes |
private NotifyListener getListener(RegistryProtocol protocol) throws Exception { return protocol.getOverrideListeners().values().iterator().next(); }
Example #30
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 4 votes |
private void destroyRegistryProtocol(){ Protocol registry = RegistryProtocol.getRegistryProtocol(); registry.destroy(); }