private static String[] getFilteredKeys(URL url) { Map<String, String> params = url.getParameters(); if (CollectionUtils.isNotEmptyMap(params)) { return params.keySet().stream() .filter(k -> k.startsWith(HIDE_KEY_PREFIX)) .toArray(String[]::new); } else { return new String[0]; } }
private static String[] getFilteredKeys(URL url) { Map<String, String> params = url.getParameters(); if (CollectionUtils.isNotEmptyMap(params)) { return params.keySet().stream() .filter(k -> k.startsWith(HIDE_KEY_PREFIX)) .toArray(String[]::new); } else { return new String[0]; } }
private boolean matchThen(URL url, URL param) { return CollectionUtils.isNotEmptyMap(thenCondition) && matchCondition(thenCondition, url, param, null); }
private boolean matchThen(URL url, URL param) { return CollectionUtils.isNotEmptyMap(thenCondition) && matchCondition(thenCondition, url, param, null); }
private void buildParameters(StringBuilder buf, boolean concat, String[] parameters) { if (CollectionUtils.isNotEmptyMap(getParameters())) { List<String> includes = (ArrayUtils.isEmpty(parameters) ? null : Arrays.asList(parameters)); boolean first = true; for (Map.Entry<String, String> entry : new TreeMap<String, String>(getParameters()).entrySet()) { if (entry.getKey() != null && entry.getKey().length() > 0 && (includes == null || includes.contains(entry.getKey()))) { if (first) { if (concat) { buf.append("?"); } first = false; } else { buf.append("&"); } buf.append(entry.getKey()); buf.append("="); buf.append(entry.getValue() == null ? "" : entry.getValue().trim()); } } } }
private void buildParameters(StringBuilder buf, boolean concat, String[] parameters) { if (CollectionUtils.isNotEmptyMap(getParameters())) { List<String> includes = (ArrayUtils.isEmpty(parameters) ? null : Arrays.asList(parameters)); boolean first = true; for (Map.Entry<String, String> entry : new TreeMap<String, String>(getParameters()).entrySet()) { if (entry.getKey() != null && entry.getKey().length() > 0 && (includes == null || includes.contains(entry.getKey()))) { if (first) { if (concat) { buf.append("?"); } first = false; } else { buf.append("&"); } buf.append(entry.getKey()); buf.append("="); buf.append(entry.getValue() == null ? "" : entry.getValue().trim()); } } } }
private void clean(Jedis jedis) { Set<String> keys = jedis.keys(root + Constants.ANY_VALUE); if (CollectionUtils.isNotEmpty(keys)) { for (String key : keys) { Map<String, String> values = jedis.hgetAll(key); if (CollectionUtils.isNotEmptyMap(values)) { boolean delete = false; long now = System.currentTimeMillis(); for (Map.Entry<String, String> entry : values.entrySet()) { URL url = URL.valueOf(entry.getKey()); if (url.getParameter(Constants.DYNAMIC_KEY, true)) { long expire = Long.parseLong(entry.getValue()); if (expire < now) { jedis.hdel(key, entry.getKey()); delete = true; if (logger.isWarnEnabled()) { logger.warn("Delete expired key: " + key + " -> value: " + entry.getKey() + ", expire: " + new Date(expire) + ", now: " + new Date(now)); } } } } if (delete) { jedis.publish(key, Constants.UNREGISTER); } } } } }
private void clean(Jedis jedis) { Set<String> keys = jedis.keys(root + Constants.ANY_VALUE); if (CollectionUtils.isNotEmpty(keys)) { for (String key : keys) { Map<String, String> values = jedis.hgetAll(key); if (CollectionUtils.isNotEmptyMap(values)) { boolean delete = false; long now = System.currentTimeMillis(); for (Map.Entry<String, String> entry : values.entrySet()) { URL url = URL.valueOf(entry.getKey()); if (url.getParameter(Constants.DYNAMIC_KEY, true)) { long expire = Long.parseLong(entry.getValue()); if (expire < now) { jedis.hdel(key, entry.getKey()); delete = true; if (logger.isWarnEnabled()) { logger.warn("Delete expired key: " + key + " -> value: " + entry.getKey() + ", expire: " + new Date(expire) + ", now: " + new Date(now)); } } } } if (delete) { jedis.publish(key, Constants.UNREGISTER); } } } } }
if (CollectionUtils.isNotEmptyMap(values)) { for (Map.Entry<String, String> entry : values.entrySet()) { URL u = URL.valueOf(entry.getKey());
if (CollectionUtils.isNotEmptyMap(values)) { for (Map.Entry<String, String> entry : values.entrySet()) { URL u = URL.valueOf(entry.getKey());
if (CollectionUtils.isNotEmptyMap(statuses)) { String[] ss = Constants.COMMA_SPLIT_PATTERN.split(status); for (String s : ss) {
if (CollectionUtils.isNotEmptyMap(statuses)) { String[] ss = Constants.COMMA_SPLIT_PATTERN.split(status); for (String s : ss) {
static Exporter<?> getExporter(Map<String, Exporter<?>> map, URL key) { Exporter<?> result = null; if (!key.getServiceKey().contains("*")) { result = map.get(key.getServiceKey()); } else { if (CollectionUtils.isNotEmptyMap(map)) { for (Exporter<?> exporter : map.values()) { if (UrlUtils.isServiceKeyMatch(key, exporter.getInvoker().getUrl())) { result = exporter; break; } } } } if (result == null) { return null; } else if (ProtocolUtils.isGeneric( result.getInvoker().getUrl().getParameter(Constants.GENERIC_KEY))) { return null; } else { return result; } }
static Exporter<?> getExporter(Map<String, Exporter<?>> map, URL key) { Exporter<?> result = null; if (!key.getServiceKey().contains("*")) { result = map.get(key.getServiceKey()); } else { if (CollectionUtils.isNotEmptyMap(map)) { for (Exporter<?> exporter : map.values()) { if (UrlUtils.isServiceKeyMatch(key, exporter.getInvoker().getUrl())) { result = exporter; break; } } } } if (result == null) { return null; } else if (ProtocolUtils.isGeneric( result.getInvoker().getUrl().getParameter(Constants.GENERIC_KEY))) { return null; } else { return result; } }
if (CollectionUtils.isNotEmptyMap(attachment)) { invocation.addAttachmentsIfAbsent(attachment); if (CollectionUtils.isNotEmptyMap(contextAttachments)) {
if (CollectionUtils.isNotEmptyMap(attachment)) { invocation.addAttachmentsIfAbsent(attachment); if (CollectionUtils.isNotEmptyMap(contextAttachments)) {
&& (getApplication() == null || CollectionUtils.isEmpty(getApplication().getRegistries()))) { Map<String, RegistryConfig> registryConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, RegistryConfig.class, false, false); if (CollectionUtils.isNotEmptyMap(registryConfigMap)) { List<RegistryConfig> registryConfigs = new ArrayList<>(); if (StringUtils.isNotEmpty(registryIds)) {
&& (getApplication() == null || CollectionUtils.isEmpty(getApplication().getRegistries()))) { Map<String, RegistryConfig> registryConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, RegistryConfig.class, false, false); if (CollectionUtils.isNotEmptyMap(registryConfigMap)) { List<RegistryConfig> registryConfigs = new ArrayList<>(); if (StringUtils.isNotEmpty(registryIds)) {