Skip to content

Commit

Permalink
bugfix:
Browse files Browse the repository at this point in the history
redis作为注册中心 强制刷新后
h2DB lts_node为空
  • Loading branch information
赵禹光 committed May 19, 2017
1 parent 2b18df0 commit affec40
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ protected void doSubscribe(Node node, NotifyListener listener) {
try {
Jedis jedis = jedisPool.getResource();
try {
doNotify(jedis, Collections.singletonList(listenNodePath), Collections.singletonList(listener));
doNotify(jedis, Collections.singletonList(listenNodePath), Collections.singletonList(listener), true);
success = true;
break; // 只需读一个服务器的数据

Expand Down Expand Up @@ -289,7 +289,7 @@ public void destroy() {

private ConcurrentHashMap<String/*key*/, List<String>> cachedNodeMap = new ConcurrentHashMap<String, List<String>>();

private void doNotify(Jedis jedis, Collection<String> keys, Collection<NotifyListener> listeners) {
private void doNotify(Jedis jedis, Collection<String> keys, Collection<NotifyListener> listeners, boolean reload) {
if (CollectionUtils.isEmpty(keys)
&& CollectionUtils.isEmpty(listeners)) {
return;
Expand All @@ -299,7 +299,7 @@ private void doNotify(Jedis jedis, Collection<String> keys, Collection<NotifyLis

Map<String, String> values = jedis.hgetAll(key);
List<String> currentChildren = values == null ? new ArrayList<String>(0) : new ArrayList<String>(values.keySet());
List<String> oldChildren = cachedNodeMap.get(key);
List<String> oldChildren = reload ? null : cachedNodeMap.get(key);

// 1. 找出增加的 节点
List<String> addChildren = CollectionUtils.getLeftDiff(currentChildren, oldChildren);
Expand Down Expand Up @@ -332,7 +332,7 @@ private void doNotify(Jedis jedis, Collection<String> keys, Collection<NotifyLis

private void doNotify(Jedis jedis, String key) {
for (Map.Entry<Node, Set<NotifyListener>> entry : new HashMap<Node, Set<NotifyListener>>(getSubscribed()).entrySet()) {
doNotify(jedis, Collections.singletonList(key), new HashSet<NotifyListener>(entry.getValue()));
doNotify(jedis, Collections.singletonList(key), new HashSet<NotifyListener>(entry.getValue()), false);
}
}

Expand Down

0 comments on commit affec40

Please sign in to comment.