修改zookeeper存储

git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@166 1a56cb94-b969-4eaa-88fa-be21384802f2
This commit is contained in:
william.liangf 2011-11-01 13:13:17 +00:00
parent dd28016d1f
commit bd6c7988c3
2 changed files with 26 additions and 18 deletions

View File

@ -295,22 +295,6 @@ public final class URL implements Serializable {
return new URL(protocol, username, password, host, port, path, getParameters());
}
public String getServiceKey() {
String inf = getParameter(Constants.INTERFACE_KEY, path);
if (inf == null) return null;
StringBuilder buf = new StringBuilder();
String group = getParameter(Constants.GROUP_KEY);
if (group != null && group.length() > 0) {
buf.append(group).append("/");
}
buf.append(inf);
String version = getParameter(Constants.VERSION_KEY);
if (version != null && version.length() > 0) {
buf.append(":").append(version);
}
return buf.toString();
}
public Map<String, String> getParameters() {
return parameters;
}
@ -961,6 +945,30 @@ public final class URL implements Serializable {
return new InetSocketAddress(host, port);
}
public String getServiceKey() {
String inf = getServiceName();
if (inf == null) return null;
StringBuilder buf = new StringBuilder();
String group = getParameter(Constants.GROUP_KEY);
if (group != null && group.length() > 0) {
buf.append(group).append("/");
}
buf.append(inf);
String version = getParameter(Constants.VERSION_KEY);
if (version != null && version.length() > 0) {
buf.append(":").append(version);
}
return buf.toString();
}
public String getServiceName() {
return getParameter(Constants.INTERFACE_KEY, path);
}
public String getServiceUrl() {
return toFullString(Constants.GROUP_KEY, Constants.VERSION_KEY);
}
public int hashCode() {
final int prime = 31;
int result = 1;

View File

@ -202,11 +202,11 @@ public class ZookeeperRegistry implements Registry {
}
private String toServicePath(URL url) {
return root + SEPARATOR + URL.encode(url.getParameter(Constants.INTERFACE_KEY, url.getPath()));
return root + SEPARATOR + URL.encode(url.getServiceName());
}
private String toProviderPath(URL url) {
return SEPARATOR + URL.encode(url.toIdentityString(Constants.GROUP_KEY, Constants.VERSION_KEY));
return SEPARATOR + URL.encode(url.getServiceUrl());
}
private List<URL> toUrls(URL consumer, List<String> providers) throws KeeperException, InterruptedException {