Java Code Examples for com.alibaba.dubbo.rpc.cluster.Configurator#configure()
The following examples show how to use
com.alibaba.dubbo.rpc.cluster.Configurator#configure() .
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 | 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 2
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 3
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 4
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 5
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 6
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 7
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 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 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 12
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 13
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 14
Source File: RegistryDirectory.java From dubbox-hystrix 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 15
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 16
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); }