提交 e9a83190 编写于 作者: W william.liangf

修改注册中心磁盘缓存

git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@1502 1a56cb94-b969-4eaa-88fa-be21384802f2
上级 2e663810
......@@ -374,26 +374,6 @@ public abstract class AbstractRegistry implements Registry {
}
protected void notify(URL url, NotifyListener listener, List<URL> urls) {
List<URL> result = new ArrayList<URL>();
StringBuilder buf = new StringBuilder();
if (urls != null && urls.size() > 0) {
for (URL u: urls) {
if (UrlUtils.isMatch(url, u)) {
result.add(u);
if (buf.length() > 0) {
buf.append(URL_SEPARATOR);
}
buf.append(u.toFullString());
}
}
}
properties.setProperty(url.getServiceKey(), buf.toString());
long version = lastCacheChanged.incrementAndGet();
if (syncSaveFile) {
doSaveProperties(version);
} else {
registryCacheExecutor.execute(new SaveProperties(version));
}
Map<String, List<URL>> categoryNotified = notified.get(url);
if (categoryNotified == null) {
notified.putIfAbsent(url, new ConcurrentHashMap<String, List<URL>>());
......@@ -401,9 +381,36 @@ public abstract class AbstractRegistry implements Registry {
}
String category = url.getParameter(Constants.CATEGORY_KEY, Constants.DEFAULT_CATEGORY);
categoryNotified.put(category, urls);
saveProperties(url);
listener.notify(urls);
}
private void saveProperties(URL url) {
try {
StringBuilder buf = new StringBuilder();
Map<String, List<URL>> categoryNotified = notified.get(url);
if (categoryNotified != null) {
for (List<URL> us : categoryNotified.values()) {
for (URL u : us) {
if (buf.length() > 0) {
buf.append(URL_SEPARATOR);
}
buf.append(u.toFullString());
}
}
}
properties.setProperty(url.getServiceKey(), buf.toString());
long version = lastCacheChanged.incrementAndGet();
if (syncSaveFile) {
doSaveProperties(version);
} else {
registryCacheExecutor.execute(new SaveProperties(version));
}
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
}
}
public void destroy() {
if (logger.isInfoEnabled()){
logger.info("Destroy registry:" + getUrl());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册