com.alibaba.dubbo.registry.RegistryFactory Java Examples
The following examples show how to use
com.alibaba.dubbo.registry.RegistryFactory.
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 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 #2
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 #3
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 #4
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 #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: RegistryStatusCheckerTest.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Test public void testCheckOK() { ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension().getRegistry(registryUrl); ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension().getRegistry(registryUrl2); assertEquals(Status.Level.OK, new RegistryStatusChecker().check().getLevel()); String message = new RegistryStatusChecker().check().getMessage(); Assert.assertTrue(message.contains(registryUrl.getAddress() + "(connected)")); Assert.assertTrue(message.contains(registryUrl2.getAddress() + "(connected)")); }
Example #7
Source File: RegistryStatusCheckerTest.java From dubbox with Apache License 2.0 | 5 votes |
@Test public void testCheckOK() { ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension().getRegistry(registryUrl); ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension().getRegistry(registryUrl2); assertEquals(Status.Level.OK, new RegistryStatusChecker().check().getLevel()); String message = new RegistryStatusChecker().check().getMessage(); Assert.assertTrue(message.contains(registryUrl.getAddress() + "(connected)")); Assert.assertTrue(message.contains(registryUrl2.getAddress() + "(connected)")); }
Example #8
Source File: RegistryStatusCheckerTest.java From dubbox with Apache License 2.0 | 5 votes |
@Test public void testCheckOK() { ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension().getRegistry(registryUrl); ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension().getRegistry(registryUrl2); assertEquals(Status.Level.OK, new RegistryStatusChecker().check().getLevel()); String message = new RegistryStatusChecker().check().getMessage(); Assert.assertTrue(message.contains(registryUrl.getAddress() + "(connected)")); Assert.assertTrue(message.contains(registryUrl2.getAddress() + "(connected)")); }
Example #9
Source File: RegistryStatusCheckerTest.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
@Test public void testCheckOK() { ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension().getRegistry(registryUrl); ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension().getRegistry(registryUrl2); assertEquals(Status.Level.OK, new RegistryStatusChecker().check().getLevel()); String message = new RegistryStatusChecker().check().getMessage(); Assert.assertTrue(message.contains(registryUrl.getAddress() + "(connected)")); Assert.assertTrue(message.contains(registryUrl2.getAddress() + "(connected)")); }
Example #10
Source File: RegistryStatusCheckerTest.java From dubbox with Apache License 2.0 | 5 votes |
@Test public void testCheckOK() { ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension().getRegistry(registryUrl); ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension().getRegistry(registryUrl2); assertEquals(Status.Level.OK, new RegistryStatusChecker().check().getLevel()); String message = new RegistryStatusChecker().check().getMessage(); Assert.assertTrue(message.contains(registryUrl.getAddress() + "(connected)")); Assert.assertTrue(message.contains(registryUrl2.getAddress() + "(connected)")); }
Example #11
Source File: RegistryProtocol.java From dubbox with Apache License 2.0 | 4 votes |
public void setRegistryFactory(RegistryFactory registryFactory) { this.registryFactory = registryFactory; }
Example #12
Source File: AbstractInterfaceConfig.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
protected List<URL> loadRegistries(boolean provider) { // 检查注册中心=》 checkRegistry(); List<URL> registryList = new ArrayList<URL>(); if (registries != null && !registries.isEmpty()) { for (RegistryConfig config : registries) { String address = config.getAddress(); // 如果注册地址为空,赋值为0.0.0.0 if (address == null || address.length() == 0) { address = Constants.ANYHOST_VALUE; } // 从系统属性中获取dubbo.registry.address属性值 String sysaddress = System.getProperty("dubbo.registry.address"); if (sysaddress != null && sysaddress.length() > 0) { address = sysaddress; } if (address.length() > 0 && !RegistryConfig.NO_AVAILABLE.equalsIgnoreCase(address)) { Map<String, String> map = new HashMap<String, String>(); // application配置追加到map appendParameters(map, application); // 注册中心配置添加到map appendParameters(map, config); map.put("path", RegistryService.class.getName()); map.put("dubbo", Version.getProtocolVersion()); map.put(Constants.TIMESTAMP_KEY, String.valueOf(System.currentTimeMillis())); if (ConfigUtils.getPid() > 0) { map.put(Constants.PID_KEY, String.valueOf(ConfigUtils.getPid())); } if (!map.containsKey("protocol")) { if (ExtensionLoader.getExtensionLoader(RegistryFactory.class).hasExtension("remote")) { map.put("protocol", "remote"); } else { map.put("protocol", "dubbo"); } } // 解析address 是url类型=》zookeeper://192.168.50.251:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-provider&dubbo=2.0.2&pid=2528×tamp=1573207113172 List<URL> urls = UrlUtils.parseURLs(address, map); for (URL url : urls) { // url追加注册协议 url = url.addParameter(Constants.REGISTRY_KEY, url.getProtocol()); url = url.setProtocol(Constants.REGISTRY_PROTOCOL); // zookeeper://192.168.50.251:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-provider&dubbo=2.0.2&pid=2528×tamp=1573207113172 // 可以注册不订阅 if ((provider && url.getParameter(Constants.REGISTER_KEY, true)) || (!provider && url.getParameter(Constants.SUBSCRIBE_KEY, true))) { registryList.add(url); } } } } } return registryList; }
Example #13
Source File: AbstractInterfaceConfig.java From dubbox with Apache License 2.0 | 4 votes |
protected List<URL> loadRegistries(boolean provider) { checkRegistry(); List<URL> registryList = new ArrayList<URL>(); if (registries != null && registries.size() > 0) { for (RegistryConfig config : registries) { String address = config.getAddress(); if (address == null || address.length() == 0) { address = Constants.ANYHOST_VALUE; } String sysaddress = System.getProperty("dubbo.registry.address"); if (sysaddress != null && sysaddress.length() > 0) { address = sysaddress; } if (address != null && address.length() > 0 && ! RegistryConfig.NO_AVAILABLE.equalsIgnoreCase(address)) { Map<String, String> map = new HashMap<String, String>(); appendParameters(map, application); appendParameters(map, config); map.put("path", RegistryService.class.getName()); map.put("dubbo", Version.getVersion()); map.put(Constants.TIMESTAMP_KEY, String.valueOf(System.currentTimeMillis())); if (ConfigUtils.getPid() > 0) { map.put(Constants.PID_KEY, String.valueOf(ConfigUtils.getPid())); } if (! map.containsKey("protocol")) { if (ExtensionLoader.getExtensionLoader(RegistryFactory.class).hasExtension("remote")) { map.put("protocol", "remote"); } else { map.put("protocol", "dubbo"); } } List<URL> urls = UrlUtils.parseURLs(address, map); for (URL url : urls) { url = url.addParameter(Constants.REGISTRY_KEY, url.getProtocol()); url = url.setProtocol(Constants.REGISTRY_PROTOCOL); if ((provider && url.getParameter(Constants.REGISTER_KEY, true)) || (! provider && url.getParameter(Constants.SUBSCRIBE_KEY, true))) { registryList.add(url); } } } } } return registryList; }
Example #14
Source File: RegistryFactoryNetty4Wrapper.java From dubbo-plus with Apache License 2.0 | 4 votes |
public RegistryFactoryNetty4Wrapper(RegistryFactory registryFactory) { this.registryFactory = registryFactory; }
Example #15
Source File: CatRegistryFactoryWrapper.java From dubbo-plus with Apache License 2.0 | 4 votes |
public CatRegistryFactoryWrapper(RegistryFactory registryFactory) { this.registryFactory = registryFactory; }
Example #16
Source File: RegistryProtocol.java From dubbox with Apache License 2.0 | 4 votes |
public void setRegistryFactory(RegistryFactory registryFactory) { this.registryFactory = registryFactory; }
Example #17
Source File: AbstractInterfaceConfig.java From dubbox with Apache License 2.0 | 4 votes |
protected List<URL> loadRegistries(boolean provider) { checkRegistry(); List<URL> registryList = new ArrayList<URL>(); if (registries != null && registries.size() > 0) { for (RegistryConfig config : registries) { String address = config.getAddress(); if (address == null || address.length() == 0) { address = Constants.ANYHOST_VALUE; } String sysaddress = System.getProperty("dubbo.registry.address"); if (sysaddress != null && sysaddress.length() > 0) { address = sysaddress; } if (address != null && address.length() > 0 && ! RegistryConfig.NO_AVAILABLE.equalsIgnoreCase(address)) { Map<String, String> map = new HashMap<String, String>(); appendParameters(map, application); appendParameters(map, config); map.put("path", RegistryService.class.getName()); map.put("dubbo", Version.getVersion()); map.put(Constants.TIMESTAMP_KEY, String.valueOf(System.currentTimeMillis())); if (ConfigUtils.getPid() > 0) { map.put(Constants.PID_KEY, String.valueOf(ConfigUtils.getPid())); } if (! map.containsKey("protocol")) { if (ExtensionLoader.getExtensionLoader(RegistryFactory.class).hasExtension("remote")) { map.put("protocol", "remote"); } else { map.put("protocol", "dubbo"); } } List<URL> urls = UrlUtils.parseURLs(address, map); for (URL url : urls) { url = url.addParameter(Constants.REGISTRY_KEY, url.getProtocol()); url = url.setProtocol(Constants.REGISTRY_PROTOCOL); if ((provider && url.getParameter(Constants.REGISTER_KEY, true)) || (! provider && url.getParameter(Constants.SUBSCRIBE_KEY, true))) { registryList.add(url); } } } } } return registryList; }
Example #18
Source File: RegistryProtocol.java From dubbo3 with Apache License 2.0 | 4 votes |
public void setRegistryFactory(RegistryFactory registryFactory) { this.registryFactory = registryFactory; }
Example #19
Source File: AbstractInterfaceConfig.java From dubbo3 with Apache License 2.0 | 4 votes |
protected List<URL> loadRegistries(boolean provider) { checkRegistry(); List<URL> registryList = new ArrayList<>(); if (registries != null && registries.size() > 0) { for (RegistryConfig config : registries) { String address = config.getAddress(); if (address == null || address.length() == 0) { address = Constants.ANYHOST_VALUE; } String sysaddress = System.getProperty("dubbo.registry.address"); if (sysaddress != null && sysaddress.length() > 0) { address = sysaddress; } if (address.length() > 0 && !RegistryConfig.NO_AVAILABLE.equalsIgnoreCase(address)) { Map<String, String> map = new HashMap<>(); appendParameters(map, application); appendParameters(map, config); map.put("path", RegistryService.class.getName()); map.put("dubbo", Version.getVersion()); map.put(Constants.TIMESTAMP_KEY, String.valueOf(System.currentTimeMillis())); if (ConfigUtils.getPid() > 0) { map.put(Constants.PID_KEY, String.valueOf(ConfigUtils.getPid())); } if (! map.containsKey("protocol")) { if (ExtensionLoader.getExtensionLoader(RegistryFactory.class).hasExtension("remote")) { map.put("protocol", "remote"); } else { map.put("protocol", "dubbo"); } } List<URL> urls = UrlUtils.parseURLs(address, map); for (URL url : urls) { url = url.addParameter(Constants.REGISTRY_KEY, url.getProtocol()); url = url.setProtocol(Constants.REGISTRY_PROTOCOL); if ((provider && url.getParameter(Constants.REGISTER_KEY, true)) || (! provider && url.getParameter(Constants.SUBSCRIBE_KEY, true))) { registryList.add(url); } } } } } return registryList; }
Example #20
Source File: RegistryProtocol.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
public void setRegistryFactory(RegistryFactory registryFactory) { this.registryFactory = registryFactory; }
Example #21
Source File: AbstractInterfaceConfig.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
protected List<URL> loadRegistries(boolean provider) { checkRegistry(); List<URL> registryList = new ArrayList<URL>(); if (registries != null && registries.size() > 0) { for (RegistryConfig config : registries) { String address = config.getAddress(); if (address == null || address.length() == 0) { address = Constants.ANYHOST_VALUE; } String sysaddress = System.getProperty("dubbo.registry.address"); if (sysaddress != null && sysaddress.length() > 0) { address = sysaddress; } if (address != null && address.length() > 0 && ! RegistryConfig.NO_AVAILABLE.equalsIgnoreCase(address)) { Map<String, String> map = new HashMap<String, String>(); appendParameters(map, application); appendParameters(map, config); map.put("path", RegistryService.class.getName()); map.put("dubbo", Version.getVersion()); map.put(Constants.TIMESTAMP_KEY, String.valueOf(System.currentTimeMillis())); if (ConfigUtils.getPid() > 0) { map.put(Constants.PID_KEY, String.valueOf(ConfigUtils.getPid())); } if (! map.containsKey("protocol")) { if (ExtensionLoader.getExtensionLoader(RegistryFactory.class).hasExtension("remote")) { map.put("protocol", "remote"); } else { map.put("protocol", "dubbo"); } } List<URL> urls = UrlUtils.parseURLs(address, map); for (URL url : urls) { url = url.addParameter(Constants.REGISTRY_KEY, url.getProtocol()); url = url.setProtocol(Constants.REGISTRY_PROTOCOL); if ((provider && url.getParameter(Constants.REGISTER_KEY, true)) || (! provider && url.getParameter(Constants.SUBSCRIBE_KEY, true))) { registryList.add(url); } } } } } return registryList; }
Example #22
Source File: RegistryProtocol.java From dubbox with Apache License 2.0 | 4 votes |
public void setRegistryFactory(RegistryFactory registryFactory) { this.registryFactory = registryFactory; }
Example #23
Source File: AbstractInterfaceConfig.java From dubbox with Apache License 2.0 | 4 votes |
protected List<URL> loadRegistries(boolean provider) { checkRegistry(); List<URL> registryList = new ArrayList<URL>(); if (registries != null && registries.size() > 0) { for (RegistryConfig config : registries) { String address = config.getAddress(); if (address == null || address.length() == 0) { address = Constants.ANYHOST_VALUE; } String sysaddress = System.getProperty("dubbo.registry.address"); if (sysaddress != null && sysaddress.length() > 0) { address = sysaddress; } if (address != null && address.length() > 0 && ! RegistryConfig.NO_AVAILABLE.equalsIgnoreCase(address)) { Map<String, String> map = new HashMap<String, String>(); appendParameters(map, application); appendParameters(map, config); map.put("path", RegistryService.class.getName()); map.put("dubbo", Version.getVersion()); map.put(Constants.TIMESTAMP_KEY, String.valueOf(System.currentTimeMillis())); if (ConfigUtils.getPid() > 0) { map.put(Constants.PID_KEY, String.valueOf(ConfigUtils.getPid())); } if (! map.containsKey("protocol")) { if (ExtensionLoader.getExtensionLoader(RegistryFactory.class).hasExtension("remote")) { map.put("protocol", "remote"); } else { map.put("protocol", "dubbo"); } } List<URL> urls = UrlUtils.parseURLs(address, map); for (URL url : urls) { url = url.addParameter(Constants.REGISTRY_KEY, url.getProtocol()); url = url.setProtocol(Constants.REGISTRY_PROTOCOL); if ((provider && url.getParameter(Constants.REGISTER_KEY, true)) || (! provider && url.getParameter(Constants.SUBSCRIBE_KEY, true))) { registryList.add(url); } } } } } return registryList; }
Example #24
Source File: RegistryProtocol.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
public void setRegistryFactory(RegistryFactory registryFactory) { this.registryFactory = registryFactory; }