com.alibaba.dubbo.rpc.cluster.Configurator Java Examples
The following examples show how to use
com.alibaba.dubbo.rpc.cluster.Configurator.
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: RegistryDirectory.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
/** * Convert override urls to map for use when re-refer. * Send all rules every time, the urls will be reassembled and calculated 将重写url转换为映射,以便在重新引用时使用。每次发送所有规则,url将被重新组装和计算 * * @param urls Contract: * </br>1.override://0.0.0.0/...( or override://ip:port...?anyhost=true)¶1=value1... means global rules (all of the providers take effect) * </br>2.override://ip:port...?anyhost=false Special rules (only for a certain provider) * </br>3.override:// rule is not supported... ,needs to be calculated by registry itself. * </br>4.override://0.0.0.0/ without parameters means clearing the override * @return */ public static List<Configurator> toConfigurators(List<URL> urls) { if (urls == null || urls.isEmpty()) { return Collections.emptyList(); } List<Configurator> configurators = new ArrayList<Configurator>(urls.size()); for (URL url : urls) { if (Constants.EMPTY_PROTOCOL.equals(url.getProtocol())) { configurators.clear(); break; } Map<String, String> override = new HashMap<String, String>(url.getParameters()); //The anyhost parameter of override may be added automatically, it can't change the judgement of changing url 重写的anyhost参数可以自动添加,不能改变改变url的判断 override.remove(Constants.ANYHOST_KEY); if (override.size() == 0) { configurators.clear(); continue; } configurators.add(configuratorFactory.getConfigurator(url)); } Collections.sort(configurators); return configurators; }
Example #2
Source File: RegistryDirectory.java From dubbox with Apache License 2.0 | 6 votes |
/** * 将overrideURL转换为map,供重新refer时使用. * 每次下发全部规则,全部重新组装计算 * @param urls * 契约: * </br>1.override://0.0.0.0/...(或override://ip:port...?anyhost=true)¶1=value1...表示全局规则(对所有的提供者全部生效) * </br>2.override://ip:port...?anyhost=false 特例规则(只针对某个提供者生效) * </br>3.不支持override://规则... 需要注册中心自行计算. * </br>4.不带参数的override://0.0.0.0/ 表示清除override * @return */ public static List<Configurator> toConfigurators(List<URL> urls){ List<Configurator> configurators = new ArrayList<Configurator>(urls.size()); if (urls == null || urls.size() == 0){ return configurators; } for(URL url : urls){ if (Constants.EMPTY_PROTOCOL.equals(url.getProtocol())) { configurators.clear(); break; } Map<String,String> override = new HashMap<String, String>(url.getParameters()); //override 上的anyhost可能是自动添加的,不能影响改变url判断 override.remove(Constants.ANYHOST_KEY); if (override.size() == 0){ configurators.clear(); continue; } configurators.add(configuratorFactory.getConfigurator(url)); } Collections.sort(configurators); return configurators; }
Example #3
Source File: RegistryDirectory.java From dubbox with Apache License 2.0 | 6 votes |
/** * 将overrideURL转换为map,供重新refer时使用. * 每次下发全部规则,全部重新组装计算 * @param urls * 契约: * </br>1.override://0.0.0.0/...(或override://ip:port...?anyhost=true)¶1=value1...表示全局规则(对所有的提供者全部生效) * </br>2.override://ip:port...?anyhost=false 特例规则(只针对某个提供者生效) * </br>3.不支持override://规则... 需要注册中心自行计算. * </br>4.不带参数的override://0.0.0.0/ 表示清除override * @return */ public static List<Configurator> toConfigurators(List<URL> urls){ List<Configurator> configurators = new ArrayList<Configurator>(urls.size()); if (urls == null || urls.size() == 0){ return configurators; } for(URL url : urls){ if (Constants.EMPTY_PROTOCOL.equals(url.getProtocol())) { configurators.clear(); break; } Map<String,String> override = new HashMap<String, String>(url.getParameters()); //override 上的anyhost可能是自动添加的,不能影响改变url判断 override.remove(Constants.ANYHOST_KEY); if (override.size() == 0){ configurators.clear(); continue; } configurators.add(configuratorFactory.getConfigurator(url)); } Collections.sort(configurators); return configurators; }
Example #4
Source File: AbstractConfigurator.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
/** * Sort by host, priority * 1. the url with a specific host ip should have higher priority than 0.0.0.0 * 2. if two url has the same host, compare by priority value; * * @param o * @return */ @Override public int compareTo(Configurator o) { if (o == null) { return -1; } int ipCompare = getUrl().getHost().compareTo(o.getUrl().getHost()); if (ipCompare == 0) {//host is the same, sort by priority int i = getUrl().getParameter(Constants.PRIORITY_KEY, 0), j = o.getUrl().getParameter(Constants.PRIORITY_KEY, 0); return i < j ? -1 : (i == j ? 0 : 1); } else { return ipCompare; } }
Example #5
Source File: RegistryDirectory.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
/** * 将overrideURL转换为map,供重新refer时使用. * 每次下发全部规则,全部重新组装计算 * @param urls * 契约: * </br>1.override://0.0.0.0/...(或override://ip:port...?anyhost=true)¶1=value1...表示全局规则(对所有的提供者全部生效) * </br>2.override://ip:port...?anyhost=false 特例规则(只针对某个提供者生效) * </br>3.不支持override://规则... 需要注册中心自行计算. * </br>4.不带参数的override://0.0.0.0/ 表示清除override * @return */ public static List<Configurator> toConfigurators(List<URL> urls){ List<Configurator> configurators = new ArrayList<Configurator>(urls.size()); if (urls == null || urls.size() == 0){ return configurators; } for(URL url : urls){ if (Constants.EMPTY_PROTOCOL.equals(url.getProtocol())) { configurators.clear(); break; } Map<String,String> override = new HashMap<String, String>(url.getParameters()); //override 上的anyhost可能是自动添加的,不能影响改变url判断 override.remove(Constants.ANYHOST_KEY); if (override.size() == 0){ configurators.clear(); continue; } configurators.add(configuratorFactory.getConfigurator(url)); } Collections.sort(configurators); return configurators; }
Example #6
Source File: RegistryDirectory.java From dubbox with Apache License 2.0 | 6 votes |
/** * 将overrideURL转换为map,供重新refer时使用. * 每次下发全部规则,全部重新组装计算 * @param urls * 契约: * </br>1.override://0.0.0.0/...(或override://ip:port...?anyhost=true)¶1=value1...表示全局规则(对所有的提供者全部生效) * </br>2.override://ip:port...?anyhost=false 特例规则(只针对某个提供者生效) * </br>3.不支持override://规则... 需要注册中心自行计算. * </br>4.不带参数的override://0.0.0.0/ 表示清除override * @return */ public static List<Configurator> toConfigurators(List<URL> urls){ List<Configurator> configurators = new ArrayList<Configurator>(urls.size()); if (urls == null || urls.size() == 0){ return configurators; } for(URL url : urls){ if (Constants.EMPTY_PROTOCOL.equals(url.getProtocol())) { configurators.clear(); break; } Map<String,String> override = new HashMap<String, String>(url.getParameters()); //override 上的anyhost可能是自动添加的,不能影响改变url判断 override.remove(Constants.ANYHOST_KEY); if (override.size() == 0){ configurators.clear(); continue; } configurators.add(configuratorFactory.getConfigurator(url)); } Collections.sort(configurators); return configurators; }
Example #7
Source File: RegistryDirectory.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
/** * 合并url参数 顺序为override > -D >Consumer > Provider * @param providerUrl * @param overrides * @return */ private URL mergeUrl(URL providerUrl){ providerUrl = ClusterUtils.mergeUrl(providerUrl, queryMap); // 合并消费端参数 List<Configurator> localConfigurators = this.configurators; // local reference if (localConfigurators != null && localConfigurators.size() > 0) { for (Configurator configurator : localConfigurators) { providerUrl = configurator.configure(providerUrl); } } providerUrl = providerUrl.addParameter(Constants.CHECK_KEY, String.valueOf(false)); // 不检查连接是否成功,总是创建Invoker! //directoryUrl 与 override 合并是在notify的最后,这里不能够处理 this.overrideDirectoryUrl = this.overrideDirectoryUrl.addParametersIfAbsent(providerUrl.getParameters()); // 合并提供者参数 if ((providerUrl.getPath() == null || providerUrl.getPath().length() == 0) && "dubbo".equals(providerUrl.getProtocol())) { // 兼容1.0 //fix by tony.chenl DUBBO-44 String path = directoryUrl.getParameter(Constants.INTERFACE_KEY); if (path != null) { int i = path.indexOf('/'); if (i >= 0) { path = path.substring(i + 1); } i = path.lastIndexOf(':'); if (i >= 0) { path = path.substring(0, i); } providerUrl = providerUrl.setPath(path); } } return providerUrl; }
Example #8
Source File: RegistryProtocol.java From dubbox with Apache License 2.0 | 5 votes |
private URL getNewInvokerUrl(URL url, List<URL> urls){ List<Configurator> localConfigurators = this.configurators; // local reference // 合并override参数 if (localConfigurators != null && localConfigurators.size() > 0) { for (Configurator configurator : localConfigurators) { url = configurator.configure(url); } } return url; }
Example #9
Source File: RegistryDirectory.java From dubbox with Apache License 2.0 | 5 votes |
/** * 合并url参数 顺序为override > -D >Consumer > Provider * @param providerUrl * @param overrides * @return */ private URL mergeUrl(URL providerUrl){ providerUrl = ClusterUtils.mergeUrl(providerUrl, queryMap); // 合并消费端参数 List<Configurator> localConfigurators = this.configurators; // local reference if (localConfigurators != null && localConfigurators.size() > 0) { for (Configurator configurator : localConfigurators) { providerUrl = configurator.configure(providerUrl); } } providerUrl = providerUrl.addParameter(Constants.CHECK_KEY, String.valueOf(false)); // 不检查连接是否成功,总是创建Invoker! //directoryUrl 与 override 合并是在notify的最后,这里不能够处理 this.overrideDirectoryUrl = this.overrideDirectoryUrl.addParametersIfAbsent(providerUrl.getParameters()); // 合并提供者参数 if ((providerUrl.getPath() == null || providerUrl.getPath().length() == 0) && "dubbo".equals(providerUrl.getProtocol())) { // 兼容1.0 //fix by tony.chenl DUBBO-44 String path = directoryUrl.getParameter(Constants.INTERFACE_KEY); if (path != null) { int i = path.indexOf('/'); if (i >= 0) { path = path.substring(i + 1); } i = path.lastIndexOf(':'); if (i >= 0) { path = path.substring(0, i); } providerUrl = providerUrl.setPath(path); } } return providerUrl; }
Example #10
Source File: RegistryProtocol.java From dubbox with Apache License 2.0 | 5 votes |
private URL getNewInvokerUrl(URL url, List<URL> urls){ List<Configurator> localConfigurators = this.configurators; // local reference // 合并override参数 if (localConfigurators != null && localConfigurators.size() > 0) { for (Configurator configurator : localConfigurators) { url = configurator.configure(url); } } return url; }
Example #11
Source File: RegistryDirectory.java From dubbox with Apache License 2.0 | 5 votes |
/** * 合并url参数 顺序为override > -D >Consumer > Provider * @param providerUrl * @param overrides * @return */ private URL mergeUrl(URL providerUrl){ providerUrl = ClusterUtils.mergeUrl(providerUrl, queryMap); // 合并消费端参数 List<Configurator> localConfigurators = this.configurators; // local reference if (localConfigurators != null && localConfigurators.size() > 0) { for (Configurator configurator : localConfigurators) { providerUrl = configurator.configure(providerUrl); } } providerUrl = providerUrl.addParameter(Constants.CHECK_KEY, String.valueOf(false)); // 不检查连接是否成功,总是创建Invoker! //directoryUrl 与 override 合并是在notify的最后,这里不能够处理 this.overrideDirectoryUrl = this.overrideDirectoryUrl.addParametersIfAbsent(providerUrl.getParameters()); // 合并提供者参数 if ((providerUrl.getPath() == null || providerUrl.getPath().length() == 0) && "dubbo".equals(providerUrl.getProtocol())) { // 兼容1.0 //fix by tony.chenl DUBBO-44 String path = directoryUrl.getParameter(Constants.INTERFACE_KEY); if (path != null) { int i = path.indexOf('/'); if (i >= 0) { path = path.substring(i + 1); } i = path.lastIndexOf(':'); if (i >= 0) { path = path.substring(0, i); } providerUrl = providerUrl.setPath(path); } } return providerUrl; }
Example #12
Source File: RegistryProtocol.java From dubbo3 with Apache License 2.0 | 5 votes |
private URL getNewInvokerUrl(URL url, List<URL> urls){ List<Configurator> localConfigurators = this.configurators; // local reference // 合并override参数 if (localConfigurators != null && localConfigurators.size() > 0) { for (Configurator configurator : localConfigurators) { url = configurator.configure(url); } } return url; }
Example #13
Source File: RegistryProtocol.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
private URL getNewInvokerUrl(URL url, List<URL> urls){ List<Configurator> localConfigurators = this.configurators; // local reference // 合并override参数 if (localConfigurators != null && localConfigurators.size() > 0) { for (Configurator configurator : localConfigurators) { url = configurator.configure(url); } } return url; }
Example #14
Source File: RegistryProtocol.java From dubbox with Apache License 2.0 | 5 votes |
private URL getNewInvokerUrl(URL url, List<URL> urls){ List<Configurator> localConfigurators = this.configurators; // local reference // 合并override参数 if (localConfigurators != null && localConfigurators.size() > 0) { for (Configurator configurator : localConfigurators) { url = configurator.configure(url); } } return url; }
Example #15
Source File: RegistryDirectory.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
/** * Merge url parameters. the order is: override > -D >Consumer > Provider 合并url参数。顺序是:覆盖> -D >使用者>提供者 * * @param providerUrl * @return */ private URL mergeUrl(URL providerUrl) { providerUrl = ClusterUtils.mergeUrl(providerUrl, queryMap); // Merge the consumer side parameters List<Configurator> localConfigurators = this.configurators; // local reference if (localConfigurators != null && !localConfigurators.isEmpty()) { for (Configurator configurator : localConfigurators) { providerUrl = configurator.configure(providerUrl); } } providerUrl = providerUrl.addParameter(Constants.CHECK_KEY, String.valueOf(false)); // Do not check whether the connection is successful or not, always create Invoker! 不要检查连接是否成功,请始终创建调用程序! // The combination of directoryUrl and override is at the end of notify, which can't be handled here directoryUrl和override的组合在notify的末尾,这里无法处理 this.overrideDirectoryUrl = this.overrideDirectoryUrl.addParametersIfAbsent(providerUrl.getParameters()); // Merge the provider side parameters if ((providerUrl.getPath() == null || providerUrl.getPath().length() == 0) && "dubbo".equals(providerUrl.getProtocol())) { // Compatible version 1.0 //fix by tony.chenl DUBBO-44 String path = directoryUrl.getParameter(Constants.INTERFACE_KEY); if (path != null) { int i = path.indexOf('/'); if (i >= 0) { path = path.substring(i + 1); } i = path.lastIndexOf(':'); if (i >= 0) { path = path.substring(0, i); } providerUrl = providerUrl.setPath(path); } } return providerUrl; }
Example #16
Source File: RegistryDirectory.java From dubbox with Apache License 2.0 | 5 votes |
/** * 合并url参数 顺序为override > -D >Consumer > Provider * @param providerUrl * @param overrides * @return */ private URL mergeUrl(URL providerUrl){ providerUrl = ClusterUtils.mergeUrl(providerUrl, queryMap); // 合并消费端参数 List<Configurator> localConfigurators = this.configurators; // local reference if (localConfigurators != null && localConfigurators.size() > 0) { for (Configurator configurator : localConfigurators) { providerUrl = configurator.configure(providerUrl); } } providerUrl = providerUrl.addParameter(Constants.CHECK_KEY, String.valueOf(false)); // 不检查连接是否成功,总是创建Invoker! //directoryUrl 与 override 合并是在notify的最后,这里不能够处理 this.overrideDirectoryUrl = this.overrideDirectoryUrl.addParametersIfAbsent(providerUrl.getParameters()); // 合并提供者参数 if ((providerUrl.getPath() == null || providerUrl.getPath().length() == 0) && "dubbo".equals(providerUrl.getProtocol())) { // 兼容1.0 //fix by tony.chenl DUBBO-44 String path = directoryUrl.getParameter(Constants.INTERFACE_KEY); if (path != null) { int i = path.indexOf('/'); if (i >= 0) { path = path.substring(i + 1); } i = path.lastIndexOf(':'); if (i >= 0) { path = path.substring(0, i); } providerUrl = providerUrl.setPath(path); } } return providerUrl; }
Example #17
Source File: OverrideConfiguratorFactory.java From dubbox with Apache License 2.0 | 4 votes |
public Configurator getConfigurator(URL url) { return new OverrideConfigurator(url); }
Example #18
Source File: OverrideConfiguratorFactory.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
@Override public Configurator getConfigurator(URL url) { return new OverrideConfigurator(url); }
Example #19
Source File: AbsentConfiguratorFactory.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
@Override public Configurator getConfigurator(URL url) { return new AbsentConfigurator(url); }
Example #20
Source File: RegistryDirectory.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
@Override public synchronized void notify(List<URL> urls) { List<URL> invokerUrls = new ArrayList<URL>(); List<URL> routerUrls = new ArrayList<URL>(); List<URL> configuratorUrls = new ArrayList<URL>(); for (URL url : urls) { String protocol = url.getProtocol(); String category = url.getParameter(Constants.CATEGORY_KEY, Constants.DEFAULT_CATEGORY); if (Constants.ROUTERS_CATEGORY.equals(category) || Constants.ROUTE_PROTOCOL.equals(protocol)) { routerUrls.add(url); } else if (Constants.CONFIGURATORS_CATEGORY.equals(category) || Constants.OVERRIDE_PROTOCOL.equals(protocol)) { configuratorUrls.add(url); } else if (Constants.PROVIDERS_CATEGORY.equals(category)) { invokerUrls.add(url); } else { logger.warn("Unsupported category " + category + " in notified url: " + url + " from registry " + getUrl().getAddress() + " to consumer " + NetUtils.getLocalHost()); } } // configurators if (configuratorUrls != null && !configuratorUrls.isEmpty()) { this.configurators = toConfigurators(configuratorUrls); } // routers if (routerUrls != null && !routerUrls.isEmpty()) { List<Router> routers = toRouters(routerUrls); if (routers != null) { // null - do nothing setRouters(routers); } } List<Configurator> localConfigurators = this.configurators; // local reference // merge override parameters // zookeeper://localhost:2181/com.alibaba.dubbo.registry.RegistryService?application=demo-consumer&check=false&default.client=netty4&dubbo=2.0.2&interface=com.alibaba.dubbo.demo.DemoService&methods=sayHello&pid=98470&qos.port=33333®ister.ip=172.28.87.51&side=consumer&timeout=3000000×tamp=1574153201694 this.overrideDirectoryUrl = directoryUrl; if (localConfigurators != null && !localConfigurators.isEmpty()) { for (Configurator configurator : localConfigurators) { this.overrideDirectoryUrl = configurator.configure(overrideDirectoryUrl); } } // providers 服务发生改变重新订阅后刷新创建的代理的invoker refreshInvoker(invokerUrls); }
Example #21
Source File: RegistryDirectory.java From dubbox with Apache License 2.0 | 4 votes |
public synchronized void notify(List<URL> urls) { List<URL> invokerUrls = new ArrayList<URL>(); List<URL> routerUrls = new ArrayList<URL>(); List<URL> configuratorUrls = new ArrayList<URL>(); for (URL url : urls) { String protocol = url.getProtocol(); String category = url.getParameter(Constants.CATEGORY_KEY, Constants.DEFAULT_CATEGORY); if (Constants.ROUTERS_CATEGORY.equals(category) || Constants.ROUTE_PROTOCOL.equals(protocol)) { routerUrls.add(url); } else if (Constants.CONFIGURATORS_CATEGORY.equals(category) || Constants.OVERRIDE_PROTOCOL.equals(protocol)) { configuratorUrls.add(url); } else if (Constants.PROVIDERS_CATEGORY.equals(category)) { invokerUrls.add(url); } else { logger.warn("Unsupported category " + category + " in notified url: " + url + " from registry " + getUrl().getAddress() + " to consumer " + NetUtils.getLocalHost()); } } // configurators if (configuratorUrls != null && configuratorUrls.size() >0 ){ this.configurators = toConfigurators(configuratorUrls); } // routers if (routerUrls != null && routerUrls.size() >0 ){ List<Router> routers = toRouters(routerUrls); if(routers != null){ // null - do nothing setRouters(routers); } } List<Configurator> localConfigurators = this.configurators; // local reference // 合并override参数 this.overrideDirectoryUrl = directoryUrl; if (localConfigurators != null && localConfigurators.size() > 0) { for (Configurator configurator : localConfigurators) { this.overrideDirectoryUrl = configurator.configure(overrideDirectoryUrl); } } // providers refreshInvoker(invokerUrls); }
Example #22
Source File: AbsentConfiguratorFactory.java From dubbox with Apache License 2.0 | 4 votes |
public Configurator getConfigurator(URL url) { return new AbsentConfigurator(url); }
Example #23
Source File: OverrideConfiguratorFactory.java From dubbox with Apache License 2.0 | 4 votes |
public Configurator getConfigurator(URL url) { return new OverrideConfigurator(url); }
Example #24
Source File: AbstractConfigurator.java From dubbox with Apache License 2.0 | 4 votes |
public int compareTo(Configurator o) { if (o == null) { return -1; } return getUrl().getHost().compareTo(o.getUrl().getHost()); }
Example #25
Source File: RegistryProtocol.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
/** * @param urls The list of registered information , is always not empty, The meaning is the same as the return value of {@link com.alibaba.dubbo.registry.RegistryService#lookup(URL)}. * 当接收到服务更改通知时触发。 通知需要支持的合同:总是在服务接口和数据类型维度上进行通知。也就是说,不会通知属于某个服务的同一类型数据的一部分。用户不需要比较上一个通知的结果。2. 订阅的第一个通知必须是服务所有类型数据的完整通知。 3.在变更时,允许分别通知不同类型的数据,例如:提供者、使用者、路由器、覆盖。它只允许通知这些类型中的一种,但是这种类型的数据必须是完整的,而不是增量的。4. 如果数据类型为空,则需要用url数据的类别参数标识通知空协议。 5. 通知的顺序由通知保证(即注册中心的实现)。例如:单线程推送、队列序列化和版本比较。 */ @Override public synchronized void notify(List<URL> urls) { logger.debug("original override urls: " + urls); // 判断当前监听器订阅的url是否一致 // provider://172.28.87.51:20880/com.alibaba.dubbo.demo.DemoService?anyhost=true&application=demo-provider&bean.name=com.alibaba.dubbo.demo.DemoService&category=configurators&check=false&default.server=netty4&dubbo=2.0.2&generic=false&interface=com.alibaba.dubbo.demo.DemoService&methods=sayHello&pid=9611&side=provider×tamp=1574156237792 List<URL> matchedUrls = getMatchedUrls(urls, subscribeUrl); logger.debug("subscribe url: " + subscribeUrl + ", override urls: " + matchedUrls); // No matching results if (matchedUrls.isEmpty()) { return; } List<Configurator> configurators = RegistryDirectory.toConfigurators(matchedUrls); final Invoker<?> invoker; if (originInvoker instanceof InvokerDelegete) { invoker = ((InvokerDelegete<?>) originInvoker).getInvoker(); } else { invoker = originInvoker; } //The origin invoker 获取执行器的服务提供者url // dubbo://172.28.87.51:20880/com.alibaba.dubbo.demo.DemoService?anyhost=true&application=demo-provider&bean.name=com.alibaba.dubbo.demo.DemoService&bind.ip=172.28.87.51&bind.port=20880&default.server=netty4&dubbo=2.0.2&generic=false&interface=com.alibaba.dubbo.demo.DemoService&methods=sayHello&pid=9611&qos.port=22222&side=provider×tamp=1574156237792 URL originUrl = RegistryProtocol.this.getProviderUrl(invoker); // 根据invoker找到provider url // dubbo://172.28.87.51:20880/com.alibaba.dubbo.demo.DemoService?anyhost=true&application=demo-provider&bean.name=com.alibaba.dubbo.demo.DemoService&bind.ip=172.28.87.51&bind.port=20880&default.server=netty4&dubbo=2.0.2&generic=false&interface=com.alibaba.dubbo.demo.DemoService&methods=sayHello&pid=9611&qos.port=22222&side=provider×tamp=1574156237792 String key = getCacheKey(originInvoker); // 根据provider url找到本地的exporter ExporterChangeableWrapper<?> exporter = bounds.get(key); if (exporter == null) { logger.warn(new IllegalStateException("error state, exporter should not be null")); return; } //The current, may have been merged many times当前,可能已经合并了很多次 URL currentUrl = exporter.getInvoker().getUrl(); //Merged with this configuration URL newUrl = getConfigedInvokerUrl(configurators, originUrl); if (!currentUrl.equals(newUrl)) { // =》服务export的url发生改变了重新export服务 RegistryProtocol.this.doChangeLocalExport(originInvoker, newUrl); logger.info("exported provider url changed, origin url: " + originUrl + ", old export url: " + currentUrl + ", new export url: " + newUrl); } }
Example #26
Source File: RegistryProtocol.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
private URL getConfigedInvokerUrl(List<Configurator> configurators, URL url) { for (Configurator configurator : configurators) { url = configurator.configure(url); } return url; }
Example #27
Source File: RegistryDirectory.java From dubbox with Apache License 2.0 | 4 votes |
public synchronized void notify(List<URL> urls) { List<URL> invokerUrls = new ArrayList<URL>(); List<URL> routerUrls = new ArrayList<URL>(); List<URL> configuratorUrls = new ArrayList<URL>(); for (URL url : urls) { String protocol = url.getProtocol(); String category = url.getParameter(Constants.CATEGORY_KEY, Constants.DEFAULT_CATEGORY); if (Constants.ROUTERS_CATEGORY.equals(category) || Constants.ROUTE_PROTOCOL.equals(protocol)) { routerUrls.add(url); } else if (Constants.CONFIGURATORS_CATEGORY.equals(category) || Constants.OVERRIDE_PROTOCOL.equals(protocol)) { configuratorUrls.add(url); } else if (Constants.PROVIDERS_CATEGORY.equals(category)) { invokerUrls.add(url); } else { logger.warn("Unsupported category " + category + " in notified url: " + url + " from registry " + getUrl().getAddress() + " to consumer " + NetUtils.getLocalHost()); } } // configurators if (configuratorUrls != null && configuratorUrls.size() >0 ){ this.configurators = toConfigurators(configuratorUrls); } // routers if (routerUrls != null && routerUrls.size() >0 ){ List<Router> routers = toRouters(routerUrls); if(routers != null){ // null - do nothing setRouters(routers); } } List<Configurator> localConfigurators = this.configurators; // local reference // 合并override参数 this.overrideDirectoryUrl = directoryUrl; if (localConfigurators != null && localConfigurators.size() > 0) { for (Configurator configurator : localConfigurators) { this.overrideDirectoryUrl = configurator.configure(overrideDirectoryUrl); } } // providers refreshInvoker(invokerUrls); }
Example #28
Source File: AbsentConfiguratorFactory.java From dubbox with Apache License 2.0 | 4 votes |
public Configurator getConfigurator(URL url) { return new AbsentConfigurator(url); }
Example #29
Source File: AbstractConfigurator.java From dubbox with Apache License 2.0 | 4 votes |
public int compareTo(Configurator o) { if (o == null) { return -1; } return getUrl().getHost().compareTo(o.getUrl().getHost()); }
Example #30
Source File: AbstractConfigurator.java From dubbox with Apache License 2.0 | 4 votes |
public int compareTo(Configurator o) { if (o == null) { return -1; } return getUrl().getHost().compareTo(o.getUrl().getHost()); }