use of com.alibaba.dubbo.common.URL in project dubbo by alibaba.
the class ConsumerServiceImpl method findServicesByAddress.
public List<String> findServicesByAddress(String address) {
List<String> ret = new ArrayList<String>();
ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
if (consumerUrls == null || address == null || address.length() == 0)
return ret;
for (Map.Entry<String, Map<Long, URL>> e1 : consumerUrls.entrySet()) {
Map<Long, URL> value = e1.getValue();
for (Map.Entry<Long, URL> e2 : value.entrySet()) {
URL u = e2.getValue();
if (address.equals(u.getAddress())) {
ret.add(e1.getKey());
break;
}
}
}
return ret;
}
use of com.alibaba.dubbo.common.URL in project dubbo by alibaba.
the class ConsumerServiceImpl method findAddressesByService.
public List<String> findAddressesByService(String service) {
List<String> ret = new ArrayList<String>();
ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
if (null == consumerUrls)
return ret;
for (Map.Entry<Long, URL> e2 : consumerUrls.get(service).entrySet()) {
URL u = e2.getValue();
String app = u.getAddress();
if (app != null)
ret.add(app);
}
return ret;
}
use of com.alibaba.dubbo.common.URL in project dubbo by alibaba.
the class ConsumerServiceImpl method findAddresses.
public List<String> findAddresses() {
List<String> ret = new ArrayList<String>();
ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
if (null == consumerUrls)
return ret;
for (Map.Entry<String, Map<Long, URL>> e1 : consumerUrls.entrySet()) {
Map<Long, URL> value = e1.getValue();
for (Map.Entry<Long, URL> e2 : value.entrySet()) {
URL u = e2.getValue();
String app = u.getAddress();
if (app != null)
ret.add(app);
}
}
return ret;
}
use of com.alibaba.dubbo.common.URL in project dubbo by alibaba.
the class OverrideServiceImpl method deleteOverride.
public void deleteOverride(Long id) {
URL oldOverride = findOverrideUrl(id);
if (oldOverride == null) {
throw new IllegalStateException("Route was changed!");
}
registryService.unregister(oldOverride);
}
use of com.alibaba.dubbo.common.URL in project dubbo by alibaba.
the class Provider method toUrl.
public URL toUrl() {
Map<String, String> serviceName2Map = ConvertUtil.serviceName2Map(getService());
/*if(!serviceName2Map.containsKey(Constants.INTERFACE_KEY)) {
throw new IllegalArgumentException("No interface info");
}
if(!serviceName2Map.containsKey(Constants.VERSION_KEY)) {
throw new IllegalArgumentException("No version info");
}*/
String u = getUrl();
URL url = URL.valueOf(u + "?" + getParameters());
url = url.addParameters(serviceName2Map);
boolean dynamic = isDynamic();
if (!dynamic) {
url = url.addParameter(Constants.DYNAMIC_KEY, false);
}
boolean enabled = isEnabled();
if (enabled != url.getParameter("enabled", true)) {
if (enabled) {
url = url.removeParameter("enabled");
} else {
url = url.addParameter("enabled", false);
}
}
return url;
}
Aggregations