From 665d9d7aaf41c5653e6926a71c02e90f684b172e Mon Sep 17 00:00:00 2001 From: Hu Zongtang Date: Mon, 13 Jul 2020 13:59:25 +0800 Subject: [PATCH] [ISSUE#3179]Replace the NotifyCenter with new refactor in the core and test module. (#3309) * [ISSUE#3179]Replace the NotifyCenter with new refactor in the core and test module. * [ISSUE#3179]Replace package in the nacos-logback.xml. * [ISSUE#3179]code reformat. --- .../nacos/common/notify/NotifyCenter.java | 4 +--- .../nacos/core/cluster/MemberChangeListener.java | 11 ++++++----- .../nacos/core/cluster/MembersChangeEvent.java | 16 +++------------- .../nacos/core/cluster/ServerMemberManager.java | 8 ++++---- .../StartingSpringApplicationRunListener.java | 2 +- .../nacos/core/distributed/ProtocolManager.java | 6 +++--- .../core/distributed/raft/JRaftProtocol.java | 8 ++++---- .../core/distributed/raft/NacosStateMachine.java | 2 +- .../core/distributed/raft/RaftErrorEvent.java | 4 ++-- .../nacos/core/distributed/raft/RaftEvent.java | 4 ++-- .../com/alibaba/nacos/core/utils/InetUtils.java | 6 +++--- .../main/resources/META-INF/logback/nacos.xml | 2 +- distribution/conf/nacos-logback.xml | 2 +- .../nacos/naming/cluster/ServerListManager.java | 6 +++--- .../consistency/persistent/raft/RaftPeerSet.java | 6 +++--- .../alibaba/nacos/naming/core/DistroMapper.java | 6 +++--- .../nacos/test/core/InetUtils_ITCase.java | 10 +++++----- .../core/cluster/ServerMemberManager_ITCase.java | 10 +++++----- 18 files changed, 51 insertions(+), 62 deletions(-) diff --git a/common/src/main/java/com/alibaba/nacos/common/notify/NotifyCenter.java b/common/src/main/java/com/alibaba/nacos/common/notify/NotifyCenter.java index b3b58bc6a45..1798203cf40 100644 --- a/common/src/main/java/com/alibaba/nacos/common/notify/NotifyCenter.java +++ b/common/src/main/java/com/alibaba/nacos/common/notify/NotifyCenter.java @@ -16,7 +16,6 @@ package com.alibaba.nacos.common.notify; -import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.api.exception.runtime.NacosRuntimeException; import com.alibaba.nacos.common.JustForTest; import com.alibaba.nacos.common.notify.listener.Subscriber; @@ -310,8 +309,7 @@ public static EventPublisher registerToSharePublisher(final Class eventType, final int queueMaxSize) - throws NacosException { + public static EventPublisher registerToPublisher(final Class eventType, final int queueMaxSize) { if (ClassUtils.isAssignableFrom(SlowEvent.class, eventType)) { return INSTANCE.sharePublisher; } diff --git a/core/src/main/java/com/alibaba/nacos/core/cluster/MemberChangeListener.java b/core/src/main/java/com/alibaba/nacos/core/cluster/MemberChangeListener.java index 46b114d8216..25b7192ca71 100644 --- a/core/src/main/java/com/alibaba/nacos/core/cluster/MemberChangeListener.java +++ b/core/src/main/java/com/alibaba/nacos/core/cluster/MemberChangeListener.java @@ -16,15 +16,16 @@ package com.alibaba.nacos.core.cluster; -import com.alibaba.nacos.core.notify.Event; -import com.alibaba.nacos.core.notify.listener.Subscribe; +import com.alibaba.nacos.common.notify.Event; +import com.alibaba.nacos.common.notify.listener.Subscriber; /** * Node change listeners. * * @author liaochuntao */ -public interface MemberChangeListener extends Subscribe { +@SuppressWarnings("PMD.AbstractClassShouldStartWithAbstractNamingRule") +public abstract class MemberChangeListener extends Subscriber { /** * return NodeChangeEvent.class info. @@ -32,7 +33,7 @@ public interface MemberChangeListener extends Subscribe { * @return {@link MembersChangeEvent#getClass()} */ @Override - default Class subscribeType() { + public Class subscribeType() { return MembersChangeEvent.class; } @@ -42,7 +43,7 @@ default Class subscribeType() { * @return default value is {@link Boolean#TRUE} */ @Override - default boolean ignoreExpireEvent() { + public boolean ignoreExpireEvent() { return true; } } diff --git a/core/src/main/java/com/alibaba/nacos/core/cluster/MembersChangeEvent.java b/core/src/main/java/com/alibaba/nacos/core/cluster/MembersChangeEvent.java index ffc0d69e803..7d8ac4d474a 100644 --- a/core/src/main/java/com/alibaba/nacos/core/cluster/MembersChangeEvent.java +++ b/core/src/main/java/com/alibaba/nacos/core/cluster/MembersChangeEvent.java @@ -16,10 +16,9 @@ package com.alibaba.nacos.core.cluster; -import com.alibaba.nacos.core.notify.Event; +import com.alibaba.nacos.common.notify.Event; import java.util.Collection; -import java.util.concurrent.atomic.AtomicLong; /** * Publish this event when the node list changes,All interested in the node list change event can listen to this event. @@ -32,16 +31,12 @@ * * @author liaochuntao */ -public class MembersChangeEvent implements Event { - - private static final AtomicLong SEQUENCE = new AtomicLong(0); +public class MembersChangeEvent extends Event { private static final long serialVersionUID = 7308126651076668976L; private Collection members; - private long no = SEQUENCE.getAndIncrement(); - public static MemberChangeEventBuilder builder() { return new MemberChangeEventBuilder(); } @@ -54,14 +49,9 @@ public void setMembers(Collection members) { this.members = members; } - @Override - public long sequence() { - return no; - } - @Override public String toString() { - return "MembersChangeEvent{" + "members=" + members + ", no=" + no + '}'; + return "MembersChangeEvent{" + "members=" + members + ", no=" + sequence() + '}'; } public static final class MemberChangeEventBuilder { diff --git a/core/src/main/java/com/alibaba/nacos/core/cluster/ServerMemberManager.java b/core/src/main/java/com/alibaba/nacos/core/cluster/ServerMemberManager.java index de6d8e44381..f77c0a8b341 100644 --- a/core/src/main/java/com/alibaba/nacos/core/cluster/ServerMemberManager.java +++ b/core/src/main/java/com/alibaba/nacos/core/cluster/ServerMemberManager.java @@ -25,13 +25,13 @@ import com.alibaba.nacos.common.http.param.Header; import com.alibaba.nacos.common.http.param.Query; import com.alibaba.nacos.common.model.RestResult; +import com.alibaba.nacos.common.notify.Event; +import com.alibaba.nacos.common.notify.NotifyCenter; +import com.alibaba.nacos.common.notify.listener.Subscriber; import com.alibaba.nacos.common.utils.ConcurrentHashSet; import com.alibaba.nacos.common.utils.ExceptionUtil; import com.alibaba.nacos.common.utils.VersionUtils; import com.alibaba.nacos.core.cluster.lookup.LookupFactory; -import com.alibaba.nacos.core.notify.Event; -import com.alibaba.nacos.core.notify.NotifyCenter; -import com.alibaba.nacos.core.notify.listener.Subscribe; import com.alibaba.nacos.core.utils.ApplicationUtils; import com.alibaba.nacos.core.utils.Commons; import com.alibaba.nacos.core.utils.Constants; @@ -166,7 +166,7 @@ private void registerClusterEvent() { // The address information of this node needs to be dynamically modified // when registering the IP change of this node - NotifyCenter.registerSubscribe(new Subscribe() { + NotifyCenter.registerSubscriber(new Subscriber() { @Override public void onEvent(InetUtils.IPChangeEvent event) { String newAddress = event.getNewIp() + ":" + port; diff --git a/core/src/main/java/com/alibaba/nacos/core/code/StartingSpringApplicationRunListener.java b/core/src/main/java/com/alibaba/nacos/core/code/StartingSpringApplicationRunListener.java index 19a30dd73e8..0b8c69777fa 100644 --- a/core/src/main/java/com/alibaba/nacos/core/code/StartingSpringApplicationRunListener.java +++ b/core/src/main/java/com/alibaba/nacos/core/code/StartingSpringApplicationRunListener.java @@ -20,8 +20,8 @@ import com.alibaba.nacos.common.executor.NameThreadFactory; import com.alibaba.nacos.common.executor.ThreadPoolManager; import com.alibaba.nacos.common.http.HttpClientManager; +import com.alibaba.nacos.common.notify.NotifyCenter; import com.alibaba.nacos.core.file.WatchFileCenter; -import com.alibaba.nacos.core.notify.NotifyCenter; import com.alibaba.nacos.core.utils.ApplicationUtils; import com.alibaba.nacos.core.utils.DiskUtils; import com.alibaba.nacos.core.utils.InetUtils; diff --git a/core/src/main/java/com/alibaba/nacos/core/distributed/ProtocolManager.java b/core/src/main/java/com/alibaba/nacos/core/distributed/ProtocolManager.java index 0469abacf19..bf2729027e4 100644 --- a/core/src/main/java/com/alibaba/nacos/core/distributed/ProtocolManager.java +++ b/core/src/main/java/com/alibaba/nacos/core/distributed/ProtocolManager.java @@ -16,6 +16,7 @@ package com.alibaba.nacos.core.distributed; +import com.alibaba.nacos.common.notify.NotifyCenter; import com.alibaba.nacos.consistency.Config; import com.alibaba.nacos.consistency.ap.APProtocol; import com.alibaba.nacos.consistency.cp.CPProtocol; @@ -25,7 +26,6 @@ import com.alibaba.nacos.core.cluster.MemberMetaDataConstants; import com.alibaba.nacos.core.cluster.MemberUtils; import com.alibaba.nacos.core.cluster.ServerMemberManager; -import com.alibaba.nacos.core.notify.NotifyCenter; import com.alibaba.nacos.core.utils.ApplicationUtils; import com.alibaba.nacos.core.utils.ClassUtils; import org.springframework.beans.factory.DisposableBean; @@ -49,7 +49,7 @@ @SuppressWarnings("all") @Component(value = "ProtocolManager") @DependsOn("serverMemberManager") -public class ProtocolManager implements ApplicationListener, DisposableBean, MemberChangeListener { +public class ProtocolManager extends MemberChangeListener implements ApplicationListener, DisposableBean { private CPProtocol cpProtocol; @@ -85,7 +85,7 @@ private static Set toCPMembersInfo(Collection members) { @PostConstruct public void init() { this.memberManager = memberManager; - NotifyCenter.registerSubscribe(this); + NotifyCenter.registerSubscriber(this); } public CPProtocol getCpProtocol() { diff --git a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/JRaftProtocol.java b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/JRaftProtocol.java index bc02daa036e..b137b347395 100644 --- a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/JRaftProtocol.java +++ b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/JRaftProtocol.java @@ -17,6 +17,9 @@ package com.alibaba.nacos.core.distributed.raft; import com.alibaba.nacos.common.model.RestResult; +import com.alibaba.nacos.common.notify.NotifyCenter; +import com.alibaba.nacos.common.notify.listener.Subscriber; +import com.alibaba.nacos.common.notify.Event; import com.alibaba.nacos.common.utils.MapUtils; import com.alibaba.nacos.common.utils.ThreadUtils; import com.alibaba.nacos.consistency.ProtocolMetaData; @@ -32,9 +35,6 @@ import com.alibaba.nacos.core.cluster.ServerMemberManager; import com.alibaba.nacos.core.distributed.AbstractConsistencyProtocol; import com.alibaba.nacos.core.distributed.raft.exception.NoSuchRaftGroupException; -import com.alibaba.nacos.core.notify.Event; -import com.alibaba.nacos.core.notify.NotifyCenter; -import com.alibaba.nacos.core.notify.listener.Subscribe; import com.alibaba.nacos.core.utils.Loggers; import com.alipay.sofa.jraft.Node; @@ -123,7 +123,7 @@ public void init(RaftConfig config) { // There is only one consumer to ensure that the internal consumption // is sequential and there is no concurrent competition - NotifyCenter.registerSubscribe(new Subscribe() { + NotifyCenter.registerSubscriber(new Subscriber() { @Override public void onEvent(RaftEvent event) { Loggers.RAFT.info("This Raft event changes : {}", event); diff --git a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/NacosStateMachine.java b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/NacosStateMachine.java index 2651b759704..5ced1dbe8f0 100644 --- a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/NacosStateMachine.java +++ b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/NacosStateMachine.java @@ -16,6 +16,7 @@ package com.alibaba.nacos.core.distributed.raft; +import com.alibaba.nacos.common.notify.NotifyCenter; import com.alibaba.nacos.common.utils.ExceptionUtil; import com.alibaba.nacos.common.utils.JacksonUtils; import com.alibaba.nacos.common.utils.LoggerUtils; @@ -30,7 +31,6 @@ import com.alibaba.nacos.consistency.snapshot.SnapshotOperation; import com.alibaba.nacos.consistency.snapshot.Writer; import com.alibaba.nacos.core.distributed.raft.utils.JRaftUtils; -import com.alibaba.nacos.core.notify.NotifyCenter; import com.alibaba.nacos.core.utils.Loggers; import com.alipay.sofa.jraft.Closure; import com.alipay.sofa.jraft.Iterator; diff --git a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/RaftErrorEvent.java b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/RaftErrorEvent.java index 40cfbf94ad9..ba6bbc69342 100644 --- a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/RaftErrorEvent.java +++ b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/RaftErrorEvent.java @@ -16,7 +16,7 @@ package com.alibaba.nacos.core.distributed.raft; -import com.alibaba.nacos.core.notify.Event; +import com.alibaba.nacos.common.notify.Event; /** * The RAFT protocol runs an exception event. If this event is published, it means that the current raft Group cannot @@ -24,7 +24,7 @@ * * @author liaochuntao */ -public class RaftErrorEvent implements Event { +public class RaftErrorEvent extends Event { private static final long serialVersionUID = 3016514657754158167L; diff --git a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/RaftEvent.java b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/RaftEvent.java index b2fcc3b41b7..5281ef87b6c 100644 --- a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/RaftEvent.java +++ b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/RaftEvent.java @@ -16,7 +16,7 @@ package com.alibaba.nacos.core.distributed.raft; -import com.alibaba.nacos.core.notify.SlowEvent; +import com.alibaba.nacos.common.notify.SlowEvent; import java.util.Collections; import java.util.List; @@ -27,7 +27,7 @@ * @author liaochuntao */ @SuppressWarnings("all") -public class RaftEvent implements SlowEvent { +public class RaftEvent extends SlowEvent { private static final long serialVersionUID = -4304258594602886451L; diff --git a/core/src/main/java/com/alibaba/nacos/core/utils/InetUtils.java b/core/src/main/java/com/alibaba/nacos/core/utils/InetUtils.java index fa4bccd1cde..06574caaccb 100644 --- a/core/src/main/java/com/alibaba/nacos/core/utils/InetUtils.java +++ b/core/src/main/java/com/alibaba/nacos/core/utils/InetUtils.java @@ -16,8 +16,8 @@ package com.alibaba.nacos.core.utils; -import com.alibaba.nacos.core.notify.NotifyCenter; -import com.alibaba.nacos.core.notify.SlowEvent; +import com.alibaba.nacos.common.notify.NotifyCenter; +import com.alibaba.nacos.common.notify.SlowEvent; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -229,7 +229,7 @@ public static boolean isIP(String str) { * {@link com.alibaba.nacos.core.cluster.ServerMemberManager} is listener. */ @SuppressWarnings({"PMD.ClassNamingShouldBeCamelRule", "checkstyle:AbbreviationAsWordInName"}) - public static class IPChangeEvent implements SlowEvent { + public static class IPChangeEvent extends SlowEvent { private String oldIp; diff --git a/core/src/main/resources/META-INF/logback/nacos.xml b/core/src/main/resources/META-INF/logback/nacos.xml index 9ccd4b68d2b..9bbbf7aecf2 100644 --- a/core/src/main/resources/META-INF/logback/nacos.xml +++ b/core/src/main/resources/META-INF/logback/nacos.xml @@ -200,7 +200,7 @@ - + diff --git a/distribution/conf/nacos-logback.xml b/distribution/conf/nacos-logback.xml index b3b4fa772c3..3779fbc66a8 100644 --- a/distribution/conf/nacos-logback.xml +++ b/distribution/conf/nacos-logback.xml @@ -619,7 +619,7 @@ - + diff --git a/naming/src/main/java/com/alibaba/nacos/naming/cluster/ServerListManager.java b/naming/src/main/java/com/alibaba/nacos/naming/cluster/ServerListManager.java index 86731038c1f..5fe4fe38ccd 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/cluster/ServerListManager.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/cluster/ServerListManager.java @@ -16,6 +16,7 @@ package com.alibaba.nacos.naming.cluster; +import com.alibaba.nacos.common.notify.NotifyCenter; import com.alibaba.nacos.common.utils.JacksonUtils; import com.alibaba.nacos.core.cluster.Member; import com.alibaba.nacos.core.cluster.MembersChangeEvent; @@ -23,7 +24,6 @@ import com.alibaba.nacos.core.cluster.MemberMetaDataConstants; import com.alibaba.nacos.core.cluster.NodeState; import com.alibaba.nacos.core.cluster.ServerMemberManager; -import com.alibaba.nacos.core.notify.NotifyCenter; import com.alibaba.nacos.core.utils.ApplicationUtils; import com.alibaba.nacos.naming.consistency.persistent.raft.RaftPeer; import com.alibaba.nacos.naming.misc.GlobalExecutor; @@ -54,7 +54,7 @@ * @deprecated 1.3.0 This object will be deleted sometime after version 1.3.0 */ @Component("serverListManager") -public class ServerListManager implements MemberChangeListener { +public class ServerListManager extends MemberChangeListener { private static final String LOCALHOST_SITE = UtilsAndCommons.UNKNOWN_SITE; @@ -69,7 +69,7 @@ public class ServerListManager implements MemberChangeListener { public ServerListManager(final SwitchDomain switchDomain, final ServerMemberManager memberManager) { this.switchDomain = switchDomain; this.memberManager = memberManager; - NotifyCenter.registerSubscribe(this); + NotifyCenter.registerSubscriber(this); this.servers = new ArrayList<>(memberManager.allMembers()); } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/raft/RaftPeerSet.java b/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/raft/RaftPeerSet.java index b32eaee7e54..68c4b794537 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/raft/RaftPeerSet.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/raft/RaftPeerSet.java @@ -16,12 +16,12 @@ package com.alibaba.nacos.naming.consistency.persistent.raft; +import com.alibaba.nacos.common.notify.NotifyCenter; import com.alibaba.nacos.common.utils.JacksonUtils; import com.alibaba.nacos.core.cluster.Member; import com.alibaba.nacos.core.cluster.MemberChangeListener; import com.alibaba.nacos.core.cluster.MembersChangeEvent; import com.alibaba.nacos.core.cluster.ServerMemberManager; -import com.alibaba.nacos.core.notify.NotifyCenter; import com.alibaba.nacos.core.utils.ApplicationUtils; import com.alibaba.nacos.naming.misc.HttpClient; import com.alibaba.nacos.naming.misc.Loggers; @@ -53,7 +53,7 @@ */ @Component @DependsOn("ProtocolManager") -public class RaftPeerSet implements MemberChangeListener { +public class RaftPeerSet extends MemberChangeListener { private final ServerMemberManager memberManager; @@ -75,7 +75,7 @@ public RaftPeerSet(ServerMemberManager memberManager) { @PostConstruct public void init() { - NotifyCenter.registerSubscribe(this); + NotifyCenter.registerSubscriber(this); changePeers(memberManager.allMembers()); } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/DistroMapper.java b/naming/src/main/java/com/alibaba/nacos/naming/core/DistroMapper.java index 68cf7f05d46..b5ec07095ea 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/core/DistroMapper.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/core/DistroMapper.java @@ -16,12 +16,12 @@ package com.alibaba.nacos.naming.core; +import com.alibaba.nacos.common.notify.NotifyCenter; import com.alibaba.nacos.core.cluster.MemberChangeListener; import com.alibaba.nacos.core.cluster.MemberUtils; import com.alibaba.nacos.core.cluster.MembersChangeEvent; import com.alibaba.nacos.core.cluster.NodeState; import com.alibaba.nacos.core.cluster.ServerMemberManager; -import com.alibaba.nacos.core.notify.NotifyCenter; import com.alibaba.nacos.core.utils.ApplicationUtils; import com.alibaba.nacos.naming.misc.Loggers; import com.alibaba.nacos.naming.misc.SwitchDomain; @@ -40,7 +40,7 @@ * @author nkorange */ @Component("distroMapper") -public class DistroMapper implements MemberChangeListener { +public class DistroMapper extends MemberChangeListener { /** * List of service nodes, you must ensure that the order of healthyList is the same for all nodes. @@ -65,7 +65,7 @@ public List getHealthyList() { */ @PostConstruct public void init() { - NotifyCenter.registerSubscribe(this); + NotifyCenter.registerSubscriber(this); this.healthyList = MemberUtils.simpleMembers(memberManager.allMembers()); } diff --git a/test/src/test/java/com/alibaba/nacos/test/core/InetUtils_ITCase.java b/test/src/test/java/com/alibaba/nacos/test/core/InetUtils_ITCase.java index 48eeab2e6c7..1b219072b6b 100644 --- a/test/src/test/java/com/alibaba/nacos/test/core/InetUtils_ITCase.java +++ b/test/src/test/java/com/alibaba/nacos/test/core/InetUtils_ITCase.java @@ -16,9 +16,9 @@ package com.alibaba.nacos.test.core; -import com.alibaba.nacos.core.notify.Event; -import com.alibaba.nacos.core.notify.NotifyCenter; -import com.alibaba.nacos.core.notify.listener.Subscribe; +import com.alibaba.nacos.common.notify.Event; +import com.alibaba.nacos.common.notify.NotifyCenter; +import com.alibaba.nacos.common.notify.listener.Subscriber; import com.alibaba.nacos.core.utils.InetUtils; import org.junit.Assert; import org.junit.Test; @@ -49,7 +49,7 @@ public void test_InternetAddress_Change() throws Exception { AtomicReference reference = new AtomicReference<>(null); - Subscribe subscribe = new Subscribe() { + Subscriber subscribe = new Subscriber() { @Override public void onEvent(InetUtils.IPChangeEvent event) { if (Objects.nonNull(event.getOldIp())) { @@ -69,7 +69,7 @@ public Class subscribeType() { } }; - NotifyCenter.registerSubscribe(subscribe); + NotifyCenter.registerSubscriber(subscribe); latch.await(10_000L, TimeUnit.MILLISECONDS); Assert.assertEquals(testIp, reference.get()); diff --git a/test/src/test/java/com/alibaba/nacos/test/core/cluster/ServerMemberManager_ITCase.java b/test/src/test/java/com/alibaba/nacos/test/core/cluster/ServerMemberManager_ITCase.java index b84fd6ce5ca..9579c742ef1 100644 --- a/test/src/test/java/com/alibaba/nacos/test/core/cluster/ServerMemberManager_ITCase.java +++ b/test/src/test/java/com/alibaba/nacos/test/core/cluster/ServerMemberManager_ITCase.java @@ -16,14 +16,14 @@ package com.alibaba.nacos.test.core.cluster; +import com.alibaba.nacos.common.notify.Event; +import com.alibaba.nacos.common.notify.NotifyCenter; +import com.alibaba.nacos.common.notify.listener.Subscriber; import com.alibaba.nacos.core.cluster.Member; import com.alibaba.nacos.core.cluster.MembersChangeEvent; import com.alibaba.nacos.core.cluster.MemberUtils; import com.alibaba.nacos.core.cluster.NodeState; import com.alibaba.nacos.core.cluster.ServerMemberManager; -import com.alibaba.nacos.core.notify.Event; -import com.alibaba.nacos.core.notify.NotifyCenter; -import com.alibaba.nacos.core.notify.listener.Subscribe; import com.alibaba.nacos.core.utils.ApplicationUtils; import com.alibaba.nacos.core.utils.Constants; import org.junit.After; @@ -108,7 +108,7 @@ public void testMemberChange() throws Exception { AtomicInteger integer = new AtomicInteger(0); CountDownLatch latch = new CountDownLatch(1); - NotifyCenter.registerSubscribe(new Subscribe() { + NotifyCenter.registerSubscriber(new Subscriber() { @Override public void onEvent(MembersChangeEvent event) { integer.incrementAndGet(); @@ -141,7 +141,7 @@ public void testMemberHealthCheck() throws Exception { AtomicReference> healthMembers = new AtomicReference<>(); CountDownLatch first = new CountDownLatch(1); CountDownLatch second = new CountDownLatch(1); - NotifyCenter.registerSubscribe(new Subscribe() { + NotifyCenter.registerSubscriber(new Subscriber() { @Override public void onEvent(MembersChangeEvent event) { System.out.println(event);