Java Code Examples for com.alibaba.dubbo.common.URL#toFullString()
The following examples show how to use
com.alibaba.dubbo.common.URL#toFullString() .
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: FileExchangeGroup.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
public ExchangePeer joinExchange(URL url, ExchangeHandler handler) throws RemotingException { ExchangePeer peer = super.join(url, handler); try { String full = url.toFullString(); String[] lines = IOUtils.readLines(file); for (String line : lines) { if (full.equals(line)) { return peer; } } IOUtils.appendLines(file, new String[]{full}); } catch (IOException e) { throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e); } return peer; }
Example 2
Source File: FileExchangeGroup.java From dubbox with Apache License 2.0 | 6 votes |
public ExchangePeer joinExchange(URL url, ExchangeHandler handler) throws RemotingException { ExchangePeer peer = super.join(url, handler); try { String full = url.toFullString(); String[] lines = IOUtils.readLines(file); for (String line : lines) { if (full.equals(line)) { return peer; } } IOUtils.appendLines(file, new String[] {full}); } catch (IOException e) { throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e); } return peer; }
Example 3
Source File: FileGroup.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
@Override public void leave(URL url) throws RemotingException { super.leave(url); try { String full = url.toFullString(); String[] lines = IOUtils.readLines(file); List<String> saves = new ArrayList<String>(); for (String line : lines) { if (full.equals(line)) { return; } saves.add(line); } IOUtils.appendLines(file, saves.toArray(new String[0])); } catch (IOException e) { throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e); } }
Example 4
Source File: FileGroup.java From dubbox with Apache License 2.0 | 6 votes |
public Peer join(URL url, ChannelHandler handler) throws RemotingException { Peer peer = super.join(url, handler); try { String full = url.toFullString(); String[] lines = IOUtils.readLines(file); for (String line : lines) { if (full.equals(line)) { return peer; } } IOUtils.appendLines(file, new String[] {full}); } catch (IOException e) { throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e); } return peer; }
Example 5
Source File: FileExchangeGroup.java From dubbox with Apache License 2.0 | 6 votes |
@Override public void leave(URL url) throws RemotingException { super.leave(url); try { String full = url.toFullString(); String[] lines = IOUtils.readLines(file); List<String> saves = new ArrayList<String>(); for (String line : lines) { if (full.equals(line)) { return; } saves.add(line); } IOUtils.appendLines(file, saves.toArray(new String[0])); } catch (IOException e) { throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e); } }
Example 6
Source File: FileExchangeGroup.java From dubbox with Apache License 2.0 | 6 votes |
public ExchangePeer joinExchange(URL url, ExchangeHandler handler) throws RemotingException { ExchangePeer peer = super.join(url, handler); try { String full = url.toFullString(); String[] lines = IOUtils.readLines(file); for (String line : lines) { if (full.equals(line)) { return peer; } } IOUtils.appendLines(file, new String[] {full}); } catch (IOException e) { throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e); } return peer; }
Example 7
Source File: FileExchangeGroup.java From dubbox with Apache License 2.0 | 6 votes |
@Override public void leave(URL url) throws RemotingException { super.leave(url); try { String full = url.toFullString(); String[] lines = IOUtils.readLines(file); List<String> saves = new ArrayList<String>(); for (String line : lines) { if (full.equals(line)) { return; } saves.add(line); } IOUtils.appendLines(file, saves.toArray(new String[0])); } catch (IOException e) { throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e); } }
Example 8
Source File: FileGroup.java From dubbox with Apache License 2.0 | 6 votes |
public Peer join(URL url, ChannelHandler handler) throws RemotingException { Peer peer = super.join(url, handler); try { String full = url.toFullString(); String[] lines = IOUtils.readLines(file); for (String line : lines) { if (full.equals(line)) { return peer; } } IOUtils.appendLines(file, new String[] {full}); } catch (IOException e) { throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e); } return peer; }
Example 9
Source File: FileExchangeGroup.java From dubbox with Apache License 2.0 | 6 votes |
@Override public void leave(URL url) throws RemotingException { super.leave(url); try { String full = url.toFullString(); String[] lines = IOUtils.readLines(file); List<String> saves = new ArrayList<String>(); for (String line : lines) { if (full.equals(line)) { return; } saves.add(line); } IOUtils.appendLines(file, saves.toArray(new String[0])); } catch (IOException e) { throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e); } }
Example 10
Source File: AbstractCacheFactory.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
public Cache getCache(URL url) { String key = url.toFullString(); Cache cache = caches.get(key); if (cache == null) { caches.put(key, createCache(url)); cache = caches.get(key); } return cache; }
Example 11
Source File: AbstractCacheFactory.java From dubbox with Apache License 2.0 | 5 votes |
public Cache getCache(URL url) { String key = url.toFullString(); Cache cache = caches.get(key); if (cache == null) { caches.put(key, createCache(url)); cache = caches.get(key); } return cache; }
Example 12
Source File: AbstractValidation.java From dubbox with Apache License 2.0 | 5 votes |
public Validator getValidator(URL url) { String key = url.toFullString(); Validator validator = validators.get(key); if (validator == null) { validators.put(key, createValidator(url)); validator = validators.get(key); } return validator; }
Example 13
Source File: AbstractCacheFactory.java From dubbox with Apache License 2.0 | 5 votes |
public Cache getCache(URL url) { String key = url.toFullString(); Cache cache = caches.get(key); if (cache == null) { caches.put(key, createCache(url)); cache = caches.get(key); } return cache; }
Example 14
Source File: AbstractValidation.java From dubbox with Apache License 2.0 | 5 votes |
public Validator getValidator(URL url) { String key = url.toFullString(); Validator validator = validators.get(key); if (validator == null) { validators.put(key, createValidator(url)); validator = validators.get(key); } return validator; }
Example 15
Source File: AbstractValidation.java From dubbox with Apache License 2.0 | 5 votes |
public Validator getValidator(URL url) { String key = url.toFullString(); Validator validator = validators.get(key); if (validator == null) { validators.put(key, createValidator(url)); validator = validators.get(key); } return validator; }
Example 16
Source File: AbstractCacheFactory.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Override public Cache getCache(URL url, Invocation invocation) { url = url.addParameter(Constants.METHOD_KEY, invocation.getMethodName()); String key = url.toFullString(); Cache cache = caches.get(key); if (cache == null) { caches.put(key, createCache(url)); cache = caches.get(key); } return cache; }
Example 17
Source File: AbstractValidation.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Override public Validator getValidator(URL url) { String key = url.toFullString(); Validator validator = validators.get(key); if (validator == null) { validators.put(key, createValidator(url)); validator = validators.get(key); } return validator; }
Example 18
Source File: AbstractCacheFactory.java From dubbox with Apache License 2.0 | 5 votes |
public Cache getCache(URL url) { String key = url.toFullString(); Cache cache = caches.get(key); if (cache == null) { caches.put(key, createCache(url)); cache = caches.get(key); } return cache; }
Example 19
Source File: RegistryDirectory.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
/** * 将urls转成invokers,如果url已经被refer过,不再重新引用。 * * @param urls * @param overrides * @param query * @return invokers */ private Map<String, Invoker<T>> toInvokers(List<URL> urls) { Map<String, Invoker<T>> newUrlInvokerMap = new HashMap<String, Invoker<T>>(); if(urls == null || urls.size() == 0){ return newUrlInvokerMap; } Set<String> keys = new HashSet<String>(); String queryProtocols = this.queryMap.get(Constants.PROTOCOL_KEY); for (URL providerUrl : urls) { //如果reference端配置了protocol,则只选择匹配的protocol if (queryProtocols != null && queryProtocols.length() >0) { boolean accept = false; String[] acceptProtocols = queryProtocols.split(","); for (String acceptProtocol : acceptProtocols) { if (providerUrl.getProtocol().equals(acceptProtocol)) { accept = true; break; } } if (!accept) { continue; } } if (Constants.EMPTY_PROTOCOL.equals(providerUrl.getProtocol())) { continue; } if (! ExtensionLoader.getExtensionLoader(Protocol.class).hasExtension(providerUrl.getProtocol())) { logger.error(new IllegalStateException("Unsupported protocol " + providerUrl.getProtocol() + " in notified url: " + providerUrl + " from registry " + getUrl().getAddress() + " to consumer " + NetUtils.getLocalHost() + ", supported protocol: "+ExtensionLoader.getExtensionLoader(Protocol.class).getSupportedExtensions())); continue; } URL url = mergeUrl(providerUrl); String key = url.toFullString(); // URL参数是排序的 if (keys.contains(key)) { // 重复URL continue; } keys.add(key); // 缓存key为没有合并消费端参数的URL,不管消费端如何合并参数,如果服务端URL发生变化,则重新refer Map<String, Invoker<T>> localUrlInvokerMap = this.urlInvokerMap; // local reference Invoker<T> invoker = localUrlInvokerMap == null ? null : localUrlInvokerMap.get(key); if (invoker == null) { // 缓存中没有,重新refer try { boolean enabled = true; if (url.hasParameter(Constants.DISABLED_KEY)) { enabled = ! url.getParameter(Constants.DISABLED_KEY, false); } else { enabled = url.getParameter(Constants.ENABLED_KEY, true); } if (enabled) { invoker = new InvokerDelegete<T>(protocol.refer(serviceType, url), url, providerUrl); } } catch (Throwable t) { logger.error("Failed to refer invoker for interface:"+serviceType+",url:("+url+")" + t.getMessage(), t); } if (invoker != null) { // 将新的引用放入缓存 newUrlInvokerMap.put(key, invoker); } }else { newUrlInvokerMap.put(key, invoker); } } keys.clear(); return newUrlInvokerMap; }
Example 20
Source File: RegistryDirectory.java From dubbox with Apache License 2.0 | 4 votes |
/** * 将urls转成invokers,如果url已经被refer过,不再重新引用。 * * @param urls * @param overrides * @param query * @return invokers */ private Map<String, Invoker<T>> toInvokers(List<URL> urls) { Map<String, Invoker<T>> newUrlInvokerMap = new HashMap<String, Invoker<T>>(); if(urls == null || urls.size() == 0){ return newUrlInvokerMap; } Set<String> keys = new HashSet<String>(); String queryProtocols = this.queryMap.get(Constants.PROTOCOL_KEY); for (URL providerUrl : urls) { //如果reference端配置了protocol,则只选择匹配的protocol if (queryProtocols != null && queryProtocols.length() >0) { boolean accept = false; String[] acceptProtocols = queryProtocols.split(","); for (String acceptProtocol : acceptProtocols) { if (providerUrl.getProtocol().equals(acceptProtocol)) { accept = true; break; } } if (!accept) { continue; } } if (Constants.EMPTY_PROTOCOL.equals(providerUrl.getProtocol())) { continue; } if (! ExtensionLoader.getExtensionLoader(Protocol.class).hasExtension(providerUrl.getProtocol())) { logger.error(new IllegalStateException("Unsupported protocol " + providerUrl.getProtocol() + " in notified url: " + providerUrl + " from registry " + getUrl().getAddress() + " to consumer " + NetUtils.getLocalHost() + ", supported protocol: "+ExtensionLoader.getExtensionLoader(Protocol.class).getSupportedExtensions())); continue; } URL url = mergeUrl(providerUrl); String key = url.toFullString(); // URL参数是排序的 if (keys.contains(key)) { // 重复URL continue; } keys.add(key); // 缓存key为没有合并消费端参数的URL,不管消费端如何合并参数,如果服务端URL发生变化,则重新refer Map<String, Invoker<T>> localUrlInvokerMap = this.urlInvokerMap; // local reference Invoker<T> invoker = localUrlInvokerMap == null ? null : localUrlInvokerMap.get(key); if (invoker == null) { // 缓存中没有,重新refer try { boolean enabled = true; if (url.hasParameter(Constants.DISABLED_KEY)) { enabled = ! url.getParameter(Constants.DISABLED_KEY, false); } else { enabled = url.getParameter(Constants.ENABLED_KEY, true); } if (enabled) { invoker = new InvokerDelegete<T>(protocol.refer(serviceType, url), url, providerUrl); } } catch (Throwable t) { logger.error("Failed to refer invoker for interface:"+serviceType+",url:("+url+")" + t.getMessage(), t); } if (invoker != null) { // 将新的引用放入缓存 newUrlInvokerMap.put(key, invoker); } }else { newUrlInvokerMap.put(key, invoker); } } keys.clear(); return newUrlInvokerMap; }