From b3b6c30ef0aab56c8e01b4ba4e8227e3c4529fc3 Mon Sep 17 00:00:00 2001 From: KomachiSion <263976490@qq.com> Date: Mon, 12 Oct 2020 16:00:50 +0800 Subject: [PATCH] Move remove listener logic to ServiceManager --- .../persistent/raft/RaftConsistencyServiceImpl.java | 9 +++------ .../com/alibaba/nacos/naming/core/ServiceManager.java | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/raft/RaftConsistencyServiceImpl.java b/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/raft/RaftConsistencyServiceImpl.java index a64e0c161..e7dc1d54e 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/raft/RaftConsistencyServiceImpl.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/raft/RaftConsistencyServiceImpl.java @@ -95,13 +95,10 @@ public class RaftConsistencyServiceImpl implements PersistentConsistencyService checkIsStopWork(); try { if (KeyBuilder.matchInstanceListKey(key) && !raftCore.isLeader()) { - Datum datum = new Datum(); - datum.key = key; - raftCore.onDelete(datum.key, peers.getLeader()); - raftCore.unlistenAll(key); - return; + raftCore.onDelete(key, peers.getLeader()); + } else { + raftCore.signalDelete(key); } - raftCore.signalDelete(key); raftCore.unlistenAll(key); } catch (Exception e) { Loggers.RAFT.error("Raft remove failed.", e); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java b/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java index 2160e3a28..ec4bb7522 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java @@ -26,7 +26,6 @@ import com.alibaba.nacos.naming.consistency.ConsistencyService; import com.alibaba.nacos.naming.consistency.Datum; import com.alibaba.nacos.naming.consistency.KeyBuilder; import com.alibaba.nacos.naming.consistency.RecordListener; -import com.alibaba.nacos.naming.consistency.persistent.impl.PersistentServiceProcessor; import com.alibaba.nacos.naming.consistency.persistent.raft.RaftPeer; import com.alibaba.nacos.naming.consistency.persistent.raft.RaftPeerSet; import com.alibaba.nacos.naming.misc.GlobalExecutor;