You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/07/16 10:33:24 UTC

[shardingsphere-elasticjob] branch master updated: Shard is not working when instance node removes (#1085) (#1087)

This is an automated email from the ASF dual-hosted git repository.

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob.git


The following commit(s) were added to refs/heads/master by this push:
     new 2afa17e  Shard is not working when instance node removes (#1085) (#1087)
2afa17e is described below

commit 2afa17e65f7242fb6d588b9674f88195ac57298b
Author: Tboy <gu...@immomo.com>
AuthorDate: Thu Jul 16 18:33:15 2020 +0800

    Shard is not working when instance node removes (#1085) (#1087)
---
 .../elasticjob/lite/internal/listener/AbstractJobListener.java   | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/AbstractJobListener.java b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/AbstractJobListener.java
index 1d0379d..2cab9b2 100644
--- a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/AbstractJobListener.java
+++ b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/AbstractJobListener.java
@@ -27,15 +27,16 @@ import org.apache.curator.framework.recipes.cache.CuratorCacheListener;
 public abstract class AbstractJobListener implements CuratorCacheListener {
     
     @Override
-    public final void event(final Type type, final ChildData oldData, final ChildData data) {
-        if (null == data) {
+    public final void event(final Type type, final ChildData oldData, final ChildData newData) {
+        if (null == newData && null == oldData) {
             return;
         }
-        String path = data.getPath();
+        String path = Type.NODE_DELETED == type ? oldData.getPath() : newData.getPath();
+        byte[] data = Type.NODE_DELETED == type ? oldData.getData() : newData.getData();
         if (path.isEmpty()) {
             return;
         }
-        dataChanged(path, type, null == data.getData() ? "" : new String(data.getData(), Charsets.UTF_8));
+        dataChanged(path, type, null == data ? "" : new String(data, Charsets.UTF_8));
     }
     
     protected abstract void dataChanged(String path, Type eventType, String data);