- *
- * @author liaochuntao
- */
-public class MembersChangeEvent extends Event {
-
- private static final long serialVersionUID = 7308126651076668976L;
-
- private final Collection members;
-
- private final Collection triggers;
-
- private MembersChangeEvent(Collection members, Collection triggers) {
- this.members = members;
- this.triggers = new HashSet<>();
- if (triggers != null) {
- this.triggers.addAll(triggers);
- }
- }
-
- public static MemberChangeEventBuilder builder() {
- return new MemberChangeEventBuilder();
- }
-
- public Collection getMembers() {
- return members;
- }
-
- public boolean hasTriggers() {
- return !triggers.isEmpty();
- }
-
- public Collection getTriggers() {
- return triggers;
- }
-
- @Override
- public String toString() {
- return "MembersChangeEvent{" + "members=" + members + ", triggers=" + triggers + ", no=" + sequence() + '}';
- }
-
- public static final class MemberChangeEventBuilder {
-
- private Collection allMembers;
-
- private Collection triggers;
-
- private MemberChangeEventBuilder() {
- }
-
- public MemberChangeEventBuilder members(Collection allMembers) {
- this.allMembers = allMembers;
- return this;
- }
-
- public MemberChangeEventBuilder triggers(Collection triggers) {
- this.triggers = triggers;
- return this;
- }
-
- public MemberChangeEventBuilder trigger(Member trigger) {
- this.triggers = Collections.singleton(trigger);
- return this;
- }
-
- /**
- * build MemberChangeEvent.
- *
- * @return {@link MembersChangeEvent}
- */
- public MembersChangeEvent build() {
- return new MembersChangeEvent(allMembers, triggers);
- }
- }
-}
diff --git a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/NodeState.java b/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/NodeState.java
deleted file mode 100644
index 93f6adca..00000000
--- a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/NodeState.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 1999-2018 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.alibaba.nacos.core.cluster;
-
-/**
- * The life cycle state of a node plays an important role.
- *
- *
1.3.0 The unified sinking operation should be done first, and the node state
- * should be radiated out later, mainly for whether the request can be processed and so on
- *
- * @author liaochuntao
- */
-public enum NodeState {
-
- /**
- * Node is starting.
- */
- STARTING,
-
- /**
- * Node is up and ready for request.
- */
- UP,
-
- /**
- * Node may Crash.
- */
- SUSPICIOUS,
-
- /**
- * Node is out of service, something abnormal happened.
- */
- DOWN,
-
- /**
- * The Node is isolated.
- */
- ISOLATION,
-
-}
diff --git a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/ServerMemberManager.java b/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/ServerMemberManager.java
deleted file mode 100644
index 16c6824a..00000000
--- a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/ServerMemberManager.java
+++ /dev/null
@@ -1,602 +0,0 @@
-/*
- * Copyright 1999-2018 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.alibaba.nacos.core.cluster;
-
-import com.alibaba.nacos.api.ability.ServerAbilities;
-import com.alibaba.nacos.api.exception.NacosException;
-import com.alibaba.nacos.auth.util.AuthHeaderUtil;
-import com.alibaba.nacos.common.JustForTest;
-import com.alibaba.nacos.common.http.Callback;
-import com.alibaba.nacos.common.http.HttpClientBeanHolder;
-import com.alibaba.nacos.common.http.HttpUtils;
-import com.alibaba.nacos.common.http.client.NacosAsyncRestTemplate;
-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.StringUtils;
-import com.alibaba.nacos.common.utils.VersionUtils;
-import com.alibaba.nacos.core.ability.ServerAbilityInitializer;
-import com.alibaba.nacos.core.ability.ServerAbilityInitializerHolder;
-import com.alibaba.nacos.core.cluster.lookup.LookupFactory;
-import com.alibaba.nacos.core.utils.Commons;
-import com.alibaba.nacos.core.utils.GenericType;
-import com.alibaba.nacos.core.utils.GlobalExecutor;
-import com.alibaba.nacos.core.utils.Loggers;
-import com.alibaba.nacos.sys.env.Constants;
-import com.alibaba.nacos.sys.env.EnvUtil;
-import com.alibaba.nacos.sys.utils.InetUtils;
-import org.springframework.boot.web.context.WebServerInitializedEvent;
-import org.springframework.context.ApplicationListener;
-import org.springframework.http.HttpStatus;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.PreDestroy;
-import javax.servlet.ServletContext;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.ConcurrentSkipListMap;
-
-/**
- * Cluster node management in Nacos.
- *
- *
{@link ServerMemberManager#init()} Cluster node manager initialization {@link ServerMemberManager#shutdown()} The
- * cluster node manager is down {@link ServerMemberManager#getSelf()} Gets local node information {@link
- * ServerMemberManager#getServerList()} Gets the cluster node dictionary {@link ServerMemberManager#getMemberAddressInfos()}
- * Gets the address information of the healthy member node {@link ServerMemberManager#allMembers()} Gets a list of
- * member information objects {@link ServerMemberManager#allMembersWithoutSelf()} Gets a list of cluster member nodes
- * with the exception of this node {@link ServerMemberManager#hasMember(String)} Is there a node {@link
- * ServerMemberManager#memberChange(Collection)} The final node list changes the method, making the full size more
- * {@link ServerMemberManager#memberJoin(Collection)} Node join, can automatically trigger {@link
- * ServerMemberManager#memberLeave(Collection)} When the node leaves, only the interface call can be manually triggered
- * {@link ServerMemberManager#update(Member)} Update the target node information {@link
- * ServerMemberManager#isUnHealth(String)} Whether the target node is healthy {@link
- * ServerMemberManager#initAndStartLookup()} Initializes the addressing mode
- *
- * @author liaochuntao
- */
-@Component(value = "serverMemberManager")
-public class ServerMemberManager implements ApplicationListener {
-
- private final NacosAsyncRestTemplate asyncRestTemplate = HttpClientBeanHolder
- .getNacosAsyncRestTemplate(Loggers.CORE);
-
- private static final int DEFAULT_SERVER_PORT = 8848;
-
- private static final String SERVER_PORT_PROPERTY = "server.port";
-
- private static final String SPRING_MANAGEMENT_CONTEXT_NAMESPACE = "management";
-
- private static final String MEMBER_CHANGE_EVENT_QUEUE_SIZE_PROPERTY = "nacos.member-change-event.queue.size";
-
- private static final int DEFAULT_MEMBER_CHANGE_EVENT_QUEUE_SIZE = 128;
-
- private static boolean isUseAddressServer = false;
-
- private static final long DEFAULT_TASK_DELAY_TIME = 5_000L;
-
- /**
- * Cluster node list.
- */
- private volatile ConcurrentSkipListMap serverList;
-
- /**
- * Is this node in the cluster list.
- */
- private static volatile boolean isInIpList = true;
-
- /**
- * port.
- */
- private int port;
-
- /**
- * Address information for the local node.
- */
- private String localAddress;
-
- /**
- * Addressing pattern instances.
- */
- private MemberLookup lookup;
-
- /**
- * self member obj.
- */
- private volatile Member self;
-
- /**
- * here is always the node information of the "UP" state.
- */
- private volatile Set memberAddressInfos = new ConcurrentHashSet<>();
-
- /**
- * Broadcast this node element information task.
- */
- private final MemberInfoReportTask infoReportTask = new MemberInfoReportTask();
-
- public ServerMemberManager(ServletContext servletContext) throws Exception {
- this.serverList = new ConcurrentSkipListMap<>();
- EnvUtil.setContextPath(servletContext.getContextPath());
-
- init();
- }
-
- protected void init() throws NacosException {
- Loggers.CORE.info("Nacos-related cluster resource initialization");
- this.port = EnvUtil.getProperty(SERVER_PORT_PROPERTY, Integer.class, DEFAULT_SERVER_PORT);
- this.localAddress = InetUtils.getSelfIP() + ":" + port;
- this.self = MemberUtil.singleParse(this.localAddress);
- this.self.setExtendVal(MemberMetaDataConstants.VERSION, VersionUtils.version);
-
- // init abilities.
- this.self.setAbilities(initMemberAbilities());
-
- serverList.put(self.getAddress(), self);
-
- // register NodeChangeEvent publisher to NotifyManager
- registerClusterEvent();
-
- // Initializes the lookup mode
- initAndStartLookup();
-
- if (serverList.isEmpty()) {
- throw new NacosException(NacosException.SERVER_ERROR, "cannot get serverlist, so exit.");
- }
-
- Loggers.CORE.info("The cluster resource is initialized");
- }
-
- private ServerAbilities initMemberAbilities() {
- ServerAbilities serverAbilities = new ServerAbilities();
- for (ServerAbilityInitializer each : ServerAbilityInitializerHolder.getInstance().getInitializers()) {
- each.initialize(serverAbilities);
- }
- return serverAbilities;
- }
-
- private void initAndStartLookup() throws NacosException {
- this.lookup = LookupFactory.createLookUp(this);
- isUseAddressServer = this.lookup.useAddressServer();
- this.lookup.start();
- }
-
- /**
- * switch look up.
- *
- * @param name look up name.
- * @throws NacosException exception.
- */
- public void switchLookup(String name) throws NacosException {
- this.lookup = LookupFactory.switchLookup(name, this);
- isUseAddressServer = this.lookup.useAddressServer();
- this.lookup.start();
- }
-
- private void registerClusterEvent() {
- // Register node change events
- NotifyCenter.registerToPublisher(MembersChangeEvent.class,
- EnvUtil.getProperty(MEMBER_CHANGE_EVENT_QUEUE_SIZE_PROPERTY, Integer.class,
- DEFAULT_MEMBER_CHANGE_EVENT_QUEUE_SIZE));
-
- // The address information of this node needs to be dynamically modified
- // when registering the IP change of this node
- NotifyCenter.registerSubscriber(new Subscriber() {
- @Override
- public void onEvent(InetUtils.IPChangeEvent event) {
- String newAddress = event.getNewIP() + ":" + port;
- ServerMemberManager.this.localAddress = newAddress;
- EnvUtil.setLocalAddress(localAddress);
-
- Member self = ServerMemberManager.this.self;
- self.setIp(event.getNewIP());
-
- String oldAddress = event.getOldIP() + ":" + port;
- ServerMemberManager.this.serverList.remove(oldAddress);
- ServerMemberManager.this.serverList.put(newAddress, self);
-
- ServerMemberManager.this.memberAddressInfos.remove(oldAddress);
- ServerMemberManager.this.memberAddressInfos.add(newAddress);
- }
-
- @Override
- public Class extends Event> subscribeType() {
- return InetUtils.IPChangeEvent.class;
- }
- });
- }
-
- public static boolean isUseAddressServer() {
- return isUseAddressServer;
- }
-
- /**
- * member information update.
- *
- * @param newMember {@link Member}
- * @return update is success
- */
- public boolean update(Member newMember) {
- Loggers.CLUSTER.debug("member information update : {}", newMember);
-
- String address = newMember.getAddress();
- if (!serverList.containsKey(address)) {
- return false;
- }
-
- serverList.computeIfPresent(address, (s, member) -> {
- if (NodeState.DOWN.equals(newMember.getState())) {
- memberAddressInfos.remove(newMember.getAddress());
- }
- boolean isPublishChangeEvent = MemberUtil.isBasicInfoChanged(newMember, member);
- newMember.setExtendVal(MemberMetaDataConstants.LAST_REFRESH_TIME, System.currentTimeMillis());
- MemberUtil.copy(newMember, member);
- if (isPublishChangeEvent) {
- // member basic data changes and all listeners need to be notified
- notifyMemberChange(member);
- }
- return member;
- });
-
- return true;
- }
-
- void notifyMemberChange(Member member) {
- NotifyCenter.publishEvent(MembersChangeEvent.builder().trigger(member).members(allMembers()).build());
- }
-
- /**
- * Whether the node exists within the cluster.
- *
- * @param address ip:port
- * @return is exists
- */
- public boolean hasMember(String address) {
- boolean result = serverList.containsKey(address);
- if (result) {
- return true;
- }
-
- // If only IP information is passed in, a fuzzy match is required
- for (Map.Entry entry : serverList.entrySet()) {
- if (StringUtils.contains(entry.getKey(), address)) {
- result = true;
- break;
- }
- }
- return result;
- }
-
- public List getServerListUnhealth() {
- List unhealthyMembers = new ArrayList<>();
- for (Member member : this.allMembers()) {
- NodeState state = member.getState();
- if (state.equals(NodeState.DOWN)) {
- unhealthyMembers.add(member.getAddress());
- }
-
- }
- return unhealthyMembers;
- }
-
- public MemberLookup getLookup() {
- return lookup;
- }
-
- public Member getSelf() {
- return this.self;
- }
-
- public Member find(String address) {
- return serverList.get(address);
- }
-
- /**
- * return this cluster all members.
- *
- * @return {@link Collection} all member
- */
- public Collection allMembers() {
- // We need to do a copy to avoid affecting the real data
- HashSet set = new HashSet<>(serverList.values());
- set.add(self);
- return set;
- }
-
- /**
- * return this cluster all members without self.
- *
- * @return {@link Collection} all member without self
- */
- public List allMembersWithoutSelf() {
- List members = new ArrayList<>(serverList.values());
- members.remove(self);
- return members;
- }
-
- synchronized boolean memberChange(Collection members) {
-
- if (members == null || members.isEmpty()) {
- return false;
- }
-
- boolean isContainSelfIp = members.stream()
- .anyMatch(ipPortTmp -> Objects.equals(localAddress, ipPortTmp.getAddress()));
-
- if (isContainSelfIp) {
- isInIpList = true;
- } else {
- isInIpList = false;
- members.add(this.self);
- Loggers.CLUSTER.warn("[serverlist] self ip {} not in serverlist {}", self, members);
- }
-
- // If the number of old and new clusters is different, the cluster information
- // must have changed; if the number of clusters is the same, then compare whether
- // there is a difference; if there is a difference, then the cluster node changes
- // are involved and all recipients need to be notified of the node change event
-
- boolean hasChange = members.size() != serverList.size();
- ConcurrentSkipListMap tmpMap = new ConcurrentSkipListMap<>();
- Set tmpAddressInfo = new ConcurrentHashSet<>();
- for (Member member : members) {
- final String address = member.getAddress();
-
- Member existMember = serverList.get(address);
- if (existMember == null) {
- hasChange = true;
- tmpMap.put(address, member);
- } else {
- //to keep extendInfo and abilities that report dynamically.
- tmpMap.put(address, existMember);
- }
-
- if (NodeState.UP.equals(member.getState())) {
- tmpAddressInfo.add(address);
- }
- }
-
- serverList = tmpMap;
- memberAddressInfos = tmpAddressInfo;
-
- Collection finalMembers = allMembers();
-
- // Persist the current cluster node information to cluster.conf
- // need to put the event publication into a synchronized block to ensure
- // that the event publication is sequential
- if (hasChange) {
- Loggers.CLUSTER.warn("[serverlist] updated to : {}", finalMembers);
- MemberUtil.syncToFile(finalMembers);
- Event event = MembersChangeEvent.builder().members(finalMembers).build();
- NotifyCenter.publishEvent(event);
- } else {
- if (Loggers.CLUSTER.isDebugEnabled()) {
- Loggers.CLUSTER.debug("[serverlist] not updated, is still : {}", finalMembers);
- }
- }
-
- return hasChange;
- }
-
- /**
- * members join this cluster.
- *
- * @param members {@link Collection} new members
- * @return is success
- */
- public synchronized boolean memberJoin(Collection members) {
- Set set = new HashSet<>(members);
- set.addAll(allMembers());
- return memberChange(set);
- }
-
- /**
- * members leave this cluster.
- *
- * @param members {@link Collection} wait leave members
- * @return is success
- */
- public synchronized boolean memberLeave(Collection members) {
- Set set = new HashSet<>(allMembers());
- set.removeAll(members);
- return memberChange(set);
- }
-
- /**
- * this member {@link Member#getState()} is health.
- *
- * @param address ip:port
- * @return is health
- */
- public boolean isUnHealth(String address) {
- Member member = serverList.get(address);
- if (member == null) {
- return false;
- }
- return !NodeState.UP.equals(member.getState());
- }
-
- public boolean isFirstIp() {
- return Objects.equals(serverList.firstKey(), this.localAddress);
- }
-
- @Override
- public void onApplicationEvent(WebServerInitializedEvent event) {
- String serverNamespace = event.getApplicationContext().getServerNamespace();
- if (SPRING_MANAGEMENT_CONTEXT_NAMESPACE.equals(serverNamespace)) {
- // ignore
- // fix#issue https://github.com/alibaba/nacos/issues/7230
- return;
- }
- getSelf().setState(NodeState.UP);
- if (!EnvUtil.getStandaloneMode()) {
- GlobalExecutor.scheduleByCommon(this.infoReportTask, DEFAULT_TASK_DELAY_TIME);
- }
- EnvUtil.setPort(event.getWebServer().getPort());
- EnvUtil.setLocalAddress(this.localAddress);
- Loggers.CLUSTER.info("This node is ready to provide external services");
- }
-
- /**
- * ServerMemberManager shutdown.
- *
- * @throws NacosException NacosException
- */
- @PreDestroy
- public void shutdown() throws NacosException {
- serverList.clear();
- memberAddressInfos.clear();
- infoReportTask.shutdown();
- LookupFactory.destroy();
- }
-
- public Set getMemberAddressInfos() {
- return memberAddressInfos;
- }
-
- @JustForTest
- public void updateMember(Member member) {
- serverList.put(member.getAddress(), member);
- }
-
- @JustForTest
- public void setMemberAddressInfos(Set memberAddressInfos) {
- this.memberAddressInfos = memberAddressInfos;
- }
-
- @JustForTest
- public MemberInfoReportTask getInfoReportTask() {
- return infoReportTask;
- }
-
- public Map getServerList() {
- return Collections.unmodifiableMap(serverList);
- }
-
- public static boolean isInIpList() {
- return isInIpList;
- }
-
- // Synchronize the metadata information of a node
- // A health check of the target node is also attached
-
- class MemberInfoReportTask extends Task {
-
- private final GenericType> reference = new GenericType>() {
- };
-
- private int cursor = 0;
-
- @Override
- protected void executeBody() {
- List members = ServerMemberManager.this.allMembersWithoutSelf();
-
- if (members.isEmpty()) {
- return;
- }
-
- this.cursor = (this.cursor + 1) % members.size();
- Member target = members.get(cursor);
-
- Loggers.CLUSTER.debug("report the metadata to the node : {}", target.getAddress());
-
- final String url = HttpUtils
- .buildUrl(false, target.getAddress(), EnvUtil.getContextPath(), Commons.NACOS_CORE_CONTEXT,
- "/cluster/report");
-
- try {
- Header header = Header.newInstance().addParam(Constants.NACOS_SERVER_HEADER, VersionUtils.version);
- AuthHeaderUtil.addIdentityToHeader(header);
- asyncRestTemplate
- .post(url, header, Query.EMPTY, getSelf(), reference.getType(), new Callback() {
- @Override
- public void onReceive(RestResult result) {
- if (result.getCode() == HttpStatus.NOT_IMPLEMENTED.value()
- || result.getCode() == HttpStatus.NOT_FOUND.value()) {
- Loggers.CLUSTER
- .warn("{} version is too low, it is recommended to upgrade the version : {}",
- target, VersionUtils.version);
- Member memberNew = null;
- if (target.getExtendVal(MemberMetaDataConstants.VERSION) != null) {
- memberNew = target.copy();
- // Clean up remote version info.
- // This value may still stay in extend info when remote server has been downgraded to old version.
- memberNew.delExtendVal(MemberMetaDataConstants.VERSION);
- memberNew.delExtendVal(MemberMetaDataConstants.READY_TO_UPGRADE);
- Loggers.CLUSTER.warn("{} : Clean up version info,"
- + " target has been downgrade to old version.", memberNew);
- }
- if (target.getAbilities() != null
- && target.getAbilities().getRemoteAbility() != null && target.getAbilities()
- .getRemoteAbility().isSupportRemoteConnection()) {
- if (memberNew == null) {
- memberNew = target.copy();
- }
- memberNew.getAbilities().getRemoteAbility().setSupportRemoteConnection(false);
- Loggers.CLUSTER
- .warn("{} : Clear support remote connection flag,target may rollback version ",
- memberNew);
- }
- if (memberNew != null) {
- update(memberNew);
- }
- return;
- }
- if (result.ok()) {
- MemberUtil.onSuccess(ServerMemberManager.this, target);
- } else {
- Loggers.CLUSTER.warn("failed to report new info to target node : {}, result : {}",
- target.getAddress(), result);
- MemberUtil.onFail(ServerMemberManager.this, target);
- }
- }
-
- @Override
- public void onError(Throwable throwable) {
- Loggers.CLUSTER.error("failed to report new info to target node : {}, error : {}",
- target.getAddress(), ExceptionUtil.getAllExceptionMsg(throwable));
- MemberUtil.onFail(ServerMemberManager.this, target, throwable);
- }
-
- @Override
- public void onCancel() {
-
- }
- });
- } catch (Throwable ex) {
- Loggers.CLUSTER.error("failed to report new info to target node : {}, error : {}", target.getAddress(),
- ExceptionUtil.getAllExceptionMsg(ex));
- }
- }
-
- @Override
- protected void after() {
- GlobalExecutor.scheduleByCommon(this, 2_000L);
- }
- }
-
-}
diff --git a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/Task.java b/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/Task.java
deleted file mode 100644
index 9b7ee8f3..00000000
--- a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/Task.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 1999-2018 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.alibaba.nacos.core.cluster;
-
-import com.alibaba.nacos.common.utils.ExceptionUtil;
-import com.alibaba.nacos.core.utils.Loggers;
-
-/**
- * task.
- *
- * @author liaochuntao
- */
-@SuppressWarnings("PMD.AbstractClassShouldStartWithAbstractNamingRule")
-public abstract class Task implements Runnable {
-
- protected volatile boolean shutdown = false;
-
- @Override
- public void run() {
- if (shutdown) {
- return;
- }
- try {
- executeBody();
- } catch (Throwable t) {
- Loggers.CORE.error("this task execute has error : {}", ExceptionUtil.getStackTrace(t));
- } finally {
- if (!shutdown) {
- after();
- }
- }
- }
-
- /**
- * Task executive.
- */
- protected abstract void executeBody();
-
- /**
- * after executeBody should do.
- */
- protected void after() {
-
- }
-
- public void shutdown() {
- shutdown = true;
- }
-
-}
diff --git a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/lookup/AddressServerMemberLookup.java b/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/lookup/AddressServerMemberLookup.java
deleted file mode 100644
index 76e747a8..00000000
--- a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/lookup/AddressServerMemberLookup.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright 1999-2018 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.alibaba.nacos.core.cluster.lookup;
-
-import com.alibaba.nacos.api.exception.NacosException;
-import com.alibaba.nacos.common.http.HttpClientBeanHolder;
-import com.alibaba.nacos.common.http.client.NacosRestTemplate;
-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.utils.ExceptionUtil;
-import com.alibaba.nacos.core.cluster.AbstractMemberLookup;
-import com.alibaba.nacos.core.cluster.MemberUtil;
-import com.alibaba.nacos.core.utils.GenericType;
-import com.alibaba.nacos.core.utils.GlobalExecutor;
-import com.alibaba.nacos.core.utils.Loggers;
-import com.alibaba.nacos.sys.env.EnvUtil;
-import com.alibaba.nacos.common.utils.StringUtils;
-
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.HashMap;
-import java.util.Map;
-
-import static com.alibaba.nacos.common.constant.RequestUrlConstants.HTTP_PREFIX;
-
-/**
- * Cluster member addressing mode for the address server.
- *
- * @author liaochuntao
- */
-public class AddressServerMemberLookup extends AbstractMemberLookup {
-
- private final GenericType genericType = new GenericType() { };
-
- public String domainName;
-
- public String addressPort;
-
- public String addressUrl;
-
- public String envIdUrl;
-
- public String addressServerUrl;
-
- private volatile boolean isAddressServerHealth = true;
-
- private int addressServerFailCount = 0;
-
- private int maxFailCount = 12;
-
- private final NacosRestTemplate restTemplate = HttpClientBeanHolder.getNacosRestTemplate(Loggers.CORE);
-
- private volatile boolean shutdown = false;
-
- private static final String HEALTH_CHECK_FAIL_COUNT_PROPERTY = "maxHealthCheckFailCount";
-
- private static final String DEFAULT_HEALTH_CHECK_FAIL_COUNT = "12";
-
- private static final String DEFAULT_SERVER_DOMAIN = "jmenv.tbsite.net";
-
- private static final String DEFAULT_SERVER_POINT = "8080";
-
- private static final int DEFAULT_SERVER_RETRY_TIME = 5;
-
- private static final long DEFAULT_SYNC_TASK_DELAY_MS = 5_000L;
-
- private static final String ADDRESS_SERVER_DOMAIN_ENV = "address_server_domain";
-
- private static final String ADDRESS_SERVER_DOMAIN_PROPERTY = "address.server.domain";
-
- private static final String ADDRESS_SERVER_PORT_ENV = "address_server_port";
-
- private static final String ADDRESS_SERVER_PORT_PROPERTY = "address.server.port";
-
- private static final String ADDRESS_SERVER_URL_ENV = "address_server_url";
-
- private static final String ADDRESS_SERVER_URL_PROPERTY = "address.server.url";
-
- private static final String ADDRESS_SERVER_RETRY_PROPERTY = "nacos.core.address-server.retry";
-
- @Override
- public void doStart() throws NacosException {
- this.maxFailCount = Integer.parseInt(EnvUtil.getProperty(HEALTH_CHECK_FAIL_COUNT_PROPERTY, DEFAULT_HEALTH_CHECK_FAIL_COUNT));
- initAddressSys();
- run();
- }
-
- @Override
- public boolean useAddressServer() {
- return true;
- }
-
- private void initAddressSys() {
- String envDomainName = System.getenv(ADDRESS_SERVER_DOMAIN_ENV);
- if (StringUtils.isBlank(envDomainName)) {
- domainName = EnvUtil.getProperty(ADDRESS_SERVER_DOMAIN_PROPERTY, DEFAULT_SERVER_DOMAIN);
- } else {
- domainName = envDomainName;
- }
- String envAddressPort = System.getenv(ADDRESS_SERVER_PORT_ENV);
- if (StringUtils.isBlank(envAddressPort)) {
- addressPort = EnvUtil.getProperty(ADDRESS_SERVER_PORT_PROPERTY, DEFAULT_SERVER_POINT);
- } else {
- addressPort = envAddressPort;
- }
- String envAddressUrl = System.getenv(ADDRESS_SERVER_URL_ENV);
- if (StringUtils.isBlank(envAddressUrl)) {
- addressUrl = EnvUtil.getProperty(ADDRESS_SERVER_URL_PROPERTY, EnvUtil.getContextPath() + "/" + "serverlist");
- } else {
- addressUrl = envAddressUrl;
- }
- addressServerUrl = HTTP_PREFIX + domainName + ":" + addressPort + addressUrl;
- envIdUrl = HTTP_PREFIX + domainName + ":" + addressPort + "/env";
-
- Loggers.CORE.info("ServerListService address-server port:" + addressPort);
- Loggers.CORE.info("ADDRESS_SERVER_URL:" + addressServerUrl);
- }
-
- @SuppressWarnings("PMD.UndefineMagicConstantRule")
- private void run() throws NacosException {
- // With the address server, you need to perform a synchronous member node pull at startup
- // Repeat three times, successfully jump out
- boolean success = false;
- Throwable ex = null;
- int maxRetry = EnvUtil.getProperty(ADDRESS_SERVER_RETRY_PROPERTY, Integer.class, DEFAULT_SERVER_RETRY_TIME);
- for (int i = 0; i < maxRetry; i++) {
- try {
- syncFromAddressUrl();
- success = true;
- break;
- } catch (Throwable e) {
- ex = e;
- Loggers.CLUSTER.error("[serverlist] exception, error : {}", ExceptionUtil.getAllExceptionMsg(ex));
- }
- }
- if (!success) {
- throw new NacosException(NacosException.SERVER_ERROR, ex);
- }
-
- GlobalExecutor.scheduleByCommon(new AddressServerSyncTask(), DEFAULT_SYNC_TASK_DELAY_MS);
- }
-
- @Override
- protected void doDestroy() throws NacosException {
- shutdown = true;
- }
-
- @Override
- public Map info() {
- Map info = new HashMap<>(4);
- info.put("addressServerHealth", isAddressServerHealth);
- info.put("addressServerUrl", addressServerUrl);
- info.put("envIdUrl", envIdUrl);
- info.put("addressServerFailCount", addressServerFailCount);
- return info;
- }
-
- private void syncFromAddressUrl() throws Exception {
- RestResult result = restTemplate
- .get(addressServerUrl, Header.EMPTY, Query.EMPTY, genericType.getType());
- if (result.ok()) {
- isAddressServerHealth = true;
- Reader reader = new StringReader(result.getData());
- try {
- afterLookup(MemberUtil.readServerConf(EnvUtil.analyzeClusterConf(reader)));
- } catch (Throwable e) {
- Loggers.CLUSTER.error("[serverlist] exception for analyzeClusterConf, error : {}",
- ExceptionUtil.getAllExceptionMsg(e));
- }
- addressServerFailCount = 0;
- } else {
- addressServerFailCount++;
- if (addressServerFailCount >= maxFailCount) {
- isAddressServerHealth = false;
- }
- Loggers.CLUSTER.error("[serverlist] failed to get serverlist, error code {}", result.getCode());
- }
- }
-
- class AddressServerSyncTask implements Runnable {
-
- @Override
- public void run() {
- if (shutdown) {
- return;
- }
- try {
- syncFromAddressUrl();
- } catch (Throwable ex) {
- addressServerFailCount++;
- if (addressServerFailCount >= maxFailCount) {
- isAddressServerHealth = false;
- }
- Loggers.CLUSTER.error("[serverlist] exception, error : {}", ExceptionUtil.getAllExceptionMsg(ex));
- } finally {
- GlobalExecutor.scheduleByCommon(this, DEFAULT_SYNC_TASK_DELAY_MS);
- }
- }
- }
-}
diff --git a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/lookup/FileConfigMemberLookup.java b/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/lookup/FileConfigMemberLookup.java
deleted file mode 100644
index d50ffbb4..00000000
--- a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/lookup/FileConfigMemberLookup.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 1999-2018 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.alibaba.nacos.core.cluster.lookup;
-
-import com.alibaba.nacos.api.exception.NacosException;
-import com.alibaba.nacos.core.cluster.AbstractMemberLookup;
-import com.alibaba.nacos.core.cluster.Member;
-import com.alibaba.nacos.core.cluster.MemberUtil;
-import com.alibaba.nacos.sys.env.EnvUtil;
-import com.alibaba.nacos.sys.file.FileChangeEvent;
-import com.alibaba.nacos.sys.file.FileWatcher;
-import com.alibaba.nacos.sys.file.WatchFileCenter;
-import com.alibaba.nacos.core.utils.Loggers;
-import com.alibaba.nacos.common.utils.StringUtils;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Cluster.conf file managed cluster member node addressing pattern.
- *
- * @author liaochuntao
- */
-public class FileConfigMemberLookup extends AbstractMemberLookup {
-
- private static final String DEFAULT_SEARCH_SEQ = "cluster.conf";
-
- private FileWatcher watcher = new FileWatcher() {
- @Override
- public void onChange(FileChangeEvent event) {
- readClusterConfFromDisk();
- }
-
- @Override
- public boolean interest(String context) {
- return StringUtils.contains(context, DEFAULT_SEARCH_SEQ);
- }
- };
-
- @Override
- public void doStart() throws NacosException {
- readClusterConfFromDisk();
-
- // Use the inotify mechanism to monitor file changes and automatically
- // trigger the reading of cluster.conf
- try {
- WatchFileCenter.registerWatcher(EnvUtil.getConfPath(), watcher);
- } catch (Throwable e) {
- Loggers.CLUSTER.error("An exception occurred in the launch file monitor : {}", e.getMessage());
- }
- }
-
- @Override
- public boolean useAddressServer() {
- return false;
- }
-
- @Override
- protected void doDestroy() throws NacosException {
- WatchFileCenter.deregisterWatcher(EnvUtil.getConfPath(), watcher);
- }
-
- private void readClusterConfFromDisk() {
- Collection tmpMembers = new ArrayList<>();
- try {
- List tmp = EnvUtil.readClusterConf();
- tmpMembers = MemberUtil.readServerConf(tmp);
- } catch (Throwable e) {
- Loggers.CLUSTER
- .error("nacos-XXXX [serverlist] failed to get serverlist from disk!, error : {}", e.getMessage());
- }
-
- afterLookup(tmpMembers);
- }
-}
diff --git a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/lookup/LookupFactory.java b/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/lookup/LookupFactory.java
deleted file mode 100644
index 437247cb..00000000
--- a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/lookup/LookupFactory.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright 1999-2018 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.alibaba.nacos.core.cluster.lookup;
-
-import com.alibaba.nacos.api.exception.NacosException;
-import com.alibaba.nacos.common.utils.StringUtils;
-import com.alibaba.nacos.core.cluster.MemberLookup;
-import com.alibaba.nacos.core.cluster.ServerMemberManager;
-import com.alibaba.nacos.sys.env.EnvUtil;
-import com.alibaba.nacos.core.utils.Loggers;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Objects;
-
-/**
- * An addressing pattern factory, responsible for the creation of all addressing patterns.
- *
- * @author liaochuntao
- */
-public final class LookupFactory {
-
- private static final String LOOKUP_MODE_TYPE = "nacos.core.member.lookup.type";
-
- @SuppressWarnings("checkstyle:StaticVariableName")
- private static MemberLookup LOOK_UP = null;
-
- private static LookupType currentLookupType = null;
-
- /**
- * Create the target addressing pattern.
- *
- * @param memberManager {@link ServerMemberManager}
- * @return {@link MemberLookup}
- * @throws NacosException NacosException
- */
- public static MemberLookup createLookUp(ServerMemberManager memberManager) throws NacosException {
- if (!EnvUtil.getStandaloneMode()) {
- String lookupType = EnvUtil.getProperty(LOOKUP_MODE_TYPE);
- LookupType type = chooseLookup(lookupType);
- LOOK_UP = find(type);
- currentLookupType = type;
- } else {
- LOOK_UP = new StandaloneMemberLookup();
- }
- LOOK_UP.injectMemberManager(memberManager);
- Loggers.CLUSTER.info("Current addressing mode selection : {}", LOOK_UP.getClass().getSimpleName());
- return LOOK_UP;
- }
-
- /**
- * Switch to target addressing mode.
- *
- * @param name target member-lookup name
- * @param memberManager {@link ServerMemberManager}
- * @return {@link MemberLookup}
- * @throws NacosException {@link NacosException}
- */
- public static MemberLookup switchLookup(String name, ServerMemberManager memberManager) throws NacosException {
- LookupType lookupType = LookupType.sourceOf(name);
-
- if (Objects.isNull(lookupType)) {
- throw new IllegalArgumentException(
- "The addressing mode exists : " + name + ", just support : [" + Arrays.toString(LookupType.values())
- + "]");
- }
-
- if (Objects.equals(currentLookupType, lookupType)) {
- return LOOK_UP;
- }
- MemberLookup newLookup = find(lookupType);
- currentLookupType = lookupType;
- if (Objects.nonNull(LOOK_UP)) {
- LOOK_UP.destroy();
- }
- LOOK_UP = newLookup;
- LOOK_UP.injectMemberManager(memberManager);
- Loggers.CLUSTER.info("Current addressing mode selection : {}", LOOK_UP.getClass().getSimpleName());
- return LOOK_UP;
- }
-
- private static MemberLookup find(LookupType type) {
- if (LookupType.FILE_CONFIG.equals(type)) {
- LOOK_UP = new FileConfigMemberLookup();
- return LOOK_UP;
- }
- if (LookupType.ADDRESS_SERVER.equals(type)) {
- LOOK_UP = new AddressServerMemberLookup();
- return LOOK_UP;
- }
- // unpossible to run here
- throw new IllegalArgumentException();
- }
-
- private static LookupType chooseLookup(String lookupType) {
- if (StringUtils.isNotBlank(lookupType)) {
- LookupType type = LookupType.sourceOf(lookupType);
- if (Objects.nonNull(type)) {
- return type;
- }
- }
- File file = new File(EnvUtil.getClusterConfFilePath());
- if (file.exists() || StringUtils.isNotBlank(EnvUtil.getMemberList())) {
- return LookupType.FILE_CONFIG;
- }
- return LookupType.ADDRESS_SERVER;
- }
-
- public static MemberLookup getLookUp() {
- return LOOK_UP;
- }
-
- public static void destroy() throws NacosException {
- Objects.requireNonNull(LOOK_UP).destroy();
- }
-
- public enum LookupType {
-
- /**
- * File addressing mode.
- */
- FILE_CONFIG(1, "file"),
-
- /**
- * Address server addressing mode.
- */
- ADDRESS_SERVER(2, "address-server");
-
- private final int code;
-
- private final String name;
-
- LookupType(int code, String name) {
- this.code = code;
- this.name = name;
- }
-
- /**
- * find one {@link LookupType} by name, if not found, return null.
- *
- * @param name name
- * @return {@link LookupType}
- */
- public static LookupType sourceOf(String name) {
- for (LookupType type : values()) {
- if (Objects.equals(type.name, name)) {
- return type;
- }
- }
- return null;
- }
-
- public int getCode() {
- return code;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public String toString() {
- return name;
- }
- }
-
-}
diff --git a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/lookup/StandaloneMemberLookup.java b/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/lookup/StandaloneMemberLookup.java
deleted file mode 100644
index 70deb5b2..00000000
--- a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/lookup/StandaloneMemberLookup.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 1999-2018 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.alibaba.nacos.core.cluster.lookup;
-
-import com.alibaba.nacos.api.exception.NacosException;
-import com.alibaba.nacos.core.cluster.AbstractMemberLookup;
-import com.alibaba.nacos.core.cluster.MemberUtil;
-import com.alibaba.nacos.sys.env.EnvUtil;
-
-import java.util.Collections;
-
-/**
- * Member node addressing mode in stand-alone mode.
- *
- * @author liaochuntao
- */
-public class StandaloneMemberLookup extends AbstractMemberLookup {
-
- @Override
- public void doStart() {
- String url = EnvUtil.getLocalAddress();
- afterLookup(MemberUtil.readServerConf(Collections.singletonList(url)));
- }
-
- @Override
- protected void doDestroy() throws NacosException {
-
- }
-
- @Override
- public boolean useAddressServer() {
- return false;
- }
-}
diff --git a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/remote/ClusterRpcClientProxy.java b/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/remote/ClusterRpcClientProxy.java
deleted file mode 100644
index b0febd7a..00000000
--- a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/cluster/remote/ClusterRpcClientProxy.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Copyright 1999-2020 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.alibaba.nacos.core.cluster.remote;
-
-import com.alibaba.nacos.api.exception.NacosException;
-import com.alibaba.nacos.api.remote.RemoteConstants;
-import com.alibaba.nacos.api.remote.RequestCallBack;
-import com.alibaba.nacos.api.remote.request.Request;
-import com.alibaba.nacos.api.remote.response.Response;
-import com.alibaba.nacos.common.notify.NotifyCenter;
-import com.alibaba.nacos.common.remote.ConnectionType;
-import com.alibaba.nacos.common.remote.client.RpcClient;
-import com.alibaba.nacos.common.remote.client.RpcClientFactory;
-import com.alibaba.nacos.common.remote.client.ServerListFactory;
-import com.alibaba.nacos.common.utils.CollectionUtils;
-import com.alibaba.nacos.core.cluster.Member;
-import com.alibaba.nacos.core.cluster.MemberChangeListener;
-import com.alibaba.nacos.core.cluster.MemberUtil;
-import com.alibaba.nacos.core.cluster.MembersChangeEvent;
-import com.alibaba.nacos.core.cluster.ServerMemberManager;
-import com.alibaba.nacos.core.utils.Loggers;
-import com.alibaba.nacos.sys.env.EnvUtil;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.PostConstruct;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import static com.alibaba.nacos.api.exception.NacosException.CLIENT_INVALID_PARAM;
-
-/**
- * cluster rpc client proxy.
- *
- * @author liuzunfei
- * @version $Id: ClusterRpcClientProxy.java, v 0.1 2020年08月11日 2:11 PM liuzunfei Exp $
- */
-@Service
-public class ClusterRpcClientProxy extends MemberChangeListener {
-
- private static final long DEFAULT_REQUEST_TIME_OUT = 3000L;
-
- @Autowired
- ServerMemberManager serverMemberManager;
-
- /**
- * init after constructor.
- */
- @PostConstruct
- public void init() {
- try {
- NotifyCenter.registerSubscriber(this);
- List members = serverMemberManager.allMembersWithoutSelf();
- refresh(members);
- Loggers.CLUSTER
- .warn("[ClusterRpcClientProxy] success to refresh cluster rpc client on start up,members ={} ",
- members);
- } catch (NacosException e) {
- Loggers.CLUSTER.warn("[ClusterRpcClientProxy] fail to refresh cluster rpc client,{} ", e.getMessage());
- }
-
- }
-
- /**
- * init cluster rpc clients.
- *
- * @param members cluster server list member list.
- */
- private void refresh(List members) throws NacosException {
-
- //ensure to create client of new members
- for (Member member : members) {
-
- if (MemberUtil.isSupportedLongCon(member)) {
- createRpcClientAndStart(member, ConnectionType.GRPC);
- }
- }
-
- //shutdown and remove old members.
- Set> allClientEntrys = RpcClientFactory.getAllClientEntries();
- Iterator> iterator = allClientEntrys.iterator();
- List newMemberKeys = members.stream().filter(MemberUtil::isSupportedLongCon)
- .map(this::memberClientKey).collect(Collectors.toList());
- while (iterator.hasNext()) {
- Map.Entry next1 = iterator.next();
- if (next1.getKey().startsWith("Cluster-") && !newMemberKeys.contains(next1.getKey())) {
- Loggers.CLUSTER.info("member leave,destroy client of member - > : {}", next1.getKey());
- RpcClientFactory.getClient(next1.getKey()).shutdown();
- iterator.remove();
- }
- }
-
- }
-
- private String memberClientKey(Member member) {
- return "Cluster-" + member.getAddress();
- }
-
- private void createRpcClientAndStart(Member member, ConnectionType type) throws NacosException {
- Map labels = new HashMap<>(2);
- labels.put(RemoteConstants.LABEL_SOURCE, RemoteConstants.LABEL_SOURCE_CLUSTER);
- String memberClientKey = memberClientKey(member);
- RpcClient client = buildRpcClient(type, labels, memberClientKey);
- if (!client.getConnectionType().equals(type)) {
- Loggers.CLUSTER.info(",connection type changed,destroy client of member - > : {}", member);
- RpcClientFactory.destroyClient(memberClientKey);
- client = buildRpcClient(type, labels, memberClientKey);
- }
-
- if (client.isWaitInitiated()) {
- Loggers.CLUSTER.info("start a new rpc client to member - > : {}", member);
-
- //one fixed server
- client.serverListFactory(new ServerListFactory() {
- @Override
- public String genNextServer() {
- return member.getAddress();
- }
-
- @Override
- public String getCurrentServer() {
- return member.getAddress();
- }
-
- @Override
- public List getServerList() {
- return CollectionUtils.list(member.getAddress());
- }
- });
-
- client.start();
- }
- }
-
- /**
- * Using {@link EnvUtil#getAvailableProcessors(int)} to build cluster clients' grpc thread pool.
- */
- private RpcClient buildRpcClient(ConnectionType type, Map labels, String memberClientKey) {
- return RpcClientFactory.createClusterClient(memberClientKey, type,
- EnvUtil.getAvailableProcessors(2), EnvUtil.getAvailableProcessors(8), labels);
- }
-
- /**
- * send request to member.
- *
- * @param member member of server.
- * @param request request.
- * @return Response response.
- * @throws NacosException exception may throws.
- */
- public Response sendRequest(Member member, Request request) throws NacosException {
- return sendRequest(member, request, DEFAULT_REQUEST_TIME_OUT);
- }
-
- /**
- * send request to member.
- *
- * @param member member of server.
- * @param request request.
- * @return Response response.
- * @throws NacosException exception may throws.
- */
- public Response sendRequest(Member member, Request request, long timeoutMills) throws NacosException {
- RpcClient client = RpcClientFactory.getClient(memberClientKey(member));
- if (client != null) {
- return client.request(request, timeoutMills);
- } else {
- throw new NacosException(CLIENT_INVALID_PARAM, "No rpc client related to member: " + member);
- }
- }
-
- /**
- * aync send request to member with callback.
- *
- * @param member member of server.
- * @param request request.
- * @param callBack RequestCallBack.
- * @throws NacosException exception may throws.
- */
- public void asyncRequest(Member member, Request request, RequestCallBack callBack) throws NacosException {
- RpcClient client = RpcClientFactory.getClient(memberClientKey(member));
- if (client != null) {
- client.asyncRequest(request, callBack);
- } else {
- throw new NacosException(CLIENT_INVALID_PARAM, "No rpc client related to member: " + member);
- }
- }
-
- /**
- * send request to member.
- *
- * @param request request.
- * @throws NacosException exception may throw.
- */
- public void sendRequestToAllMembers(Request request) throws NacosException {
- List members = serverMemberManager.allMembersWithoutSelf();
- for (Member member1 : members) {
- sendRequest(member1, request);
- }
- }
-
- @Override
- public void onEvent(MembersChangeEvent event) {
- try {
- List members = serverMemberManager.allMembersWithoutSelf();
- refresh(members);
- } catch (NacosException e) {
- Loggers.CLUSTER.warn("[serverlist] fail to refresh cluster rpc client, event:{}, msg: {} ", event, e.getMessage());
- }
- }
-
- /**
- * Check whether client for member is running.
- *
- * @param member member
- * @return {@code true} if target client is connected, otherwise {@code false}
- */
- public boolean isRunning(Member member) {
- RpcClient client = RpcClientFactory.getClient(memberClientKey(member));
- if (null == client) {
- return false;
- }
- return client.isRunning();
- }
-}
diff --git a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/ControllerMethodsCache.java b/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/ControllerMethodsCache.java
deleted file mode 100644
index af105446..00000000
--- a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/ControllerMethodsCache.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright 1999-2018 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.alibaba.nacos.core.code;
-
-import com.alibaba.nacos.api.exception.NacosException;
-import com.alibaba.nacos.api.exception.runtime.NacosRuntimeException;
-import com.alibaba.nacos.common.packagescan.DefaultPackageScan;
-import com.alibaba.nacos.common.utils.ArrayUtils;
-import com.alibaba.nacos.common.utils.CollectionUtils;
-import com.alibaba.nacos.core.code.RequestMappingInfo.RequestMappingInfoComparator;
-import com.alibaba.nacos.core.code.condition.ParamRequestCondition;
-import com.alibaba.nacos.core.code.condition.PathRequestCondition;
-import com.alibaba.nacos.sys.env.EnvUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PatchMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-import javax.servlet.http.HttpServletRequest;
-import java.lang.reflect.Method;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import static com.alibaba.nacos.sys.env.Constants.REQUEST_PATH_SEPARATOR;
-
-
-/**
- * Method cache.
- *
- * @author nkorange
- * @since 1.2.0
- */
-@Component
-public class ControllerMethodsCache {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ControllerMethodsCache.class);
-
- private ConcurrentMap methods = new ConcurrentHashMap<>();
-
- private final ConcurrentMap> urlLookup = new ConcurrentHashMap<>();
-
- public Method getMethod(HttpServletRequest request) {
- String path = getPath(request);
- String httpMethod = request.getMethod();
- String urlKey = httpMethod + REQUEST_PATH_SEPARATOR + path.replaceFirst(EnvUtil.getContextPath(), "");
- List requestMappingInfos = urlLookup.get(urlKey);
- if (CollectionUtils.isEmpty(requestMappingInfos)) {
- return null;
- }
- List matchedInfo = findMatchedInfo(requestMappingInfos, request);
- if (CollectionUtils.isEmpty(matchedInfo)) {
- return null;
- }
- RequestMappingInfo bestMatch = matchedInfo.get(0);
- if (matchedInfo.size() > 1) {
- RequestMappingInfoComparator comparator = new RequestMappingInfoComparator();
- matchedInfo.sort(comparator);
- bestMatch = matchedInfo.get(0);
- RequestMappingInfo secondBestMatch = matchedInfo.get(1);
- if (comparator.compare(bestMatch, secondBestMatch) == 0) {
- throw new IllegalStateException(
- "Ambiguous methods mapped for '" + request.getRequestURI() + "': {" + bestMatch + ", "
- + secondBestMatch + "}");
- }
- }
- return methods.get(bestMatch);
- }
-
- private String getPath(HttpServletRequest request) {
- try {
- return new URI(request.getRequestURI()).getPath();
- } catch (URISyntaxException e) {
- LOGGER.error("parse request to path error", e);
- throw new NacosRuntimeException(NacosException.NOT_FOUND, "Invalid URI");
- }
- }
-
- private List findMatchedInfo(List requestMappingInfos,
- HttpServletRequest request) {
- List matchedInfo = new ArrayList<>();
- for (RequestMappingInfo requestMappingInfo : requestMappingInfos) {
- ParamRequestCondition matchingCondition = requestMappingInfo.getParamRequestCondition()
- .getMatchingCondition(request);
- if (matchingCondition != null) {
- matchedInfo.add(requestMappingInfo);
- }
- }
- return matchedInfo;
- }
-
- /**
- * find target method from this package.
- *
- * @param packageName package name
- */
- public void initClassMethod(String packageName) {
- DefaultPackageScan packageScan = new DefaultPackageScan();
- Set> classesList = packageScan.getTypesAnnotatedWith(packageName, RequestMapping.class);
- for (Class clazz : classesList) {
- initClassMethod(clazz);
- }
- }
-
- /**
- * find target method from class list.
- *
- * @param classesList class list
- */
- public void initClassMethod(Set> classesList) {
- for (Class clazz : classesList) {
- initClassMethod(clazz);
- }
- }
-
- /**
- * find target method from target class.
- *
- * @param clazz {@link Class}
- */
- private void initClassMethod(Class> clazz) {
- RequestMapping requestMapping = clazz.getAnnotation(RequestMapping.class);
- for (String classPath : requestMapping.value()) {
- for (Method method : clazz.getMethods()) {
- if (!method.isAnnotationPresent(RequestMapping.class)) {
- parseSubAnnotations(method, classPath);
- continue;
- }
- requestMapping = method.getAnnotation(RequestMapping.class);
- RequestMethod[] requestMethods = requestMapping.method();
- if (requestMethods.length == 0) {
- requestMethods = new RequestMethod[1];
- requestMethods[0] = RequestMethod.GET;
- }
- for (String methodPath : requestMapping.value()) {
- String urlKey = requestMethods[0].name() + REQUEST_PATH_SEPARATOR + classPath + methodPath;
- addUrlAndMethodRelation(urlKey, requestMapping.params(), method);
- }
- }
- }
- }
-
- private void parseSubAnnotations(Method method, String classPath) {
-
- final GetMapping getMapping = method.getAnnotation(GetMapping.class);
- final PostMapping postMapping = method.getAnnotation(PostMapping.class);
- final PutMapping putMapping = method.getAnnotation(PutMapping.class);
- final DeleteMapping deleteMapping = method.getAnnotation(DeleteMapping.class);
- final PatchMapping patchMapping = method.getAnnotation(PatchMapping.class);
-
- if (getMapping != null) {
- put(RequestMethod.GET, classPath, getMapping.value(), getMapping.params(), method);
- }
-
- if (postMapping != null) {
- put(RequestMethod.POST, classPath, postMapping.value(), postMapping.params(), method);
- }
-
- if (putMapping != null) {
- put(RequestMethod.PUT, classPath, putMapping.value(), putMapping.params(), method);
- }
-
- if (deleteMapping != null) {
- put(RequestMethod.DELETE, classPath, deleteMapping.value(), deleteMapping.params(), method);
- }
-
- if (patchMapping != null) {
- put(RequestMethod.PATCH, classPath, patchMapping.value(), patchMapping.params(), method);
- }
-
- }
-
- private void put(RequestMethod requestMethod, String classPath, String[] requestPaths, String[] requestParams,
- Method method) {
- if (ArrayUtils.isEmpty(requestPaths)) {
- String urlKey = requestMethod.name() + REQUEST_PATH_SEPARATOR + classPath;
- addUrlAndMethodRelation(urlKey, requestParams, method);
- return;
- }
- for (String requestPath : requestPaths) {
- String urlKey = requestMethod.name() + REQUEST_PATH_SEPARATOR + classPath + requestPath;
- addUrlAndMethodRelation(urlKey, requestParams, method);
- }
- }
-
- private void addUrlAndMethodRelation(String urlKey, String[] requestParam, Method method) {
- RequestMappingInfo requestMappingInfo = new RequestMappingInfo();
- requestMappingInfo.setPathRequestCondition(new PathRequestCondition(urlKey));
- requestMappingInfo.setParamRequestCondition(new ParamRequestCondition(requestParam));
- List requestMappingInfos = urlLookup.get(urlKey);
- if (requestMappingInfos == null) {
- urlLookup.putIfAbsent(urlKey, new ArrayList<>());
- requestMappingInfos = urlLookup.get(urlKey);
- // For issue #4701.
- String urlKeyBackup = urlKey + "/";
- urlLookup.putIfAbsent(urlKeyBackup, requestMappingInfos);
- }
- requestMappingInfos.add(requestMappingInfo);
- methods.put(requestMappingInfo, method);
- }
-}
diff --git a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/RequestMappingInfo.java b/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/RequestMappingInfo.java
deleted file mode 100644
index 78dcc954..00000000
--- a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/RequestMappingInfo.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 1999-2021 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.alibaba.nacos.core.code;
-
-import com.alibaba.nacos.core.code.condition.ParamRequestCondition;
-import com.alibaba.nacos.core.code.condition.PathRequestCondition;
-
-import java.util.Comparator;
-
-/**
- * Request mapping information. to find the matched method by request
- *
- * @author horizonzy
- * @since 1.3.2
- */
-public class RequestMappingInfo {
-
- private PathRequestCondition pathRequestCondition;
-
- private ParamRequestCondition paramRequestCondition;
-
- public ParamRequestCondition getParamRequestCondition() {
- return paramRequestCondition;
- }
-
- public void setParamRequestCondition(ParamRequestCondition paramRequestCondition) {
- this.paramRequestCondition = paramRequestCondition;
- }
-
- public void setPathRequestCondition(PathRequestCondition pathRequestCondition) {
- this.pathRequestCondition = pathRequestCondition;
- }
-
- @Override
- public String toString() {
- return "RequestMappingInfo{" + "pathRequestCondition=" + pathRequestCondition + ", paramRequestCondition="
- + paramRequestCondition + '}';
- }
-
- public static class RequestMappingInfoComparator implements Comparator {
-
- @Override
- public int compare(RequestMappingInfo o1, RequestMappingInfo o2) {
- return Integer.compare(o2.getParamRequestCondition().getExpressions().size(),
- o1.getParamRequestCondition().getExpressions().size());
- }
- }
-}
diff --git a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/SpringApplicationRunListener.java b/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/SpringApplicationRunListener.java
deleted file mode 100644
index 8e207187..00000000
--- a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/SpringApplicationRunListener.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 1999-2018 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.alibaba.nacos.core.code;
-
-import com.alibaba.nacos.common.spi.NacosServiceLoader;
-import com.alibaba.nacos.core.listener.NacosApplicationListener;
-import org.springframework.boot.ConfigurableBootstrapContext;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.context.event.EventPublishingRunListener;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.core.Ordered;
-import org.springframework.core.env.ConfigurableEnvironment;
-
-import java.util.Collection;
-
-/**
- * {@link org.springframework.boot.SpringApplicationRunListener} before {@link EventPublishingRunListener} execution.
- *
- * @author Mercy
- * @since 0.2.2
- */
-public class SpringApplicationRunListener implements org.springframework.boot.SpringApplicationRunListener, Ordered {
-
- private final SpringApplication application;
-
- private final String[] args;
-
- Collection nacosApplicationListeners = NacosServiceLoader.load(NacosApplicationListener.class);
-
- public SpringApplicationRunListener(SpringApplication application, String[] args) {
- this.application = application;
- this.args = args;
- }
-
- @Override
- public void starting(ConfigurableBootstrapContext bootstrapContext) {
- for (NacosApplicationListener nacosApplicationListener : nacosApplicationListeners) {
- nacosApplicationListener.starting();
- }
- }
-
- @Override
- public void environmentPrepared(ConfigurableBootstrapContext bootstrapContext,
- ConfigurableEnvironment environment) {
- for (NacosApplicationListener nacosApplicationListener : nacosApplicationListeners) {
- nacosApplicationListener.environmentPrepared(environment);
- }
- }
-
- @Override
- public void contextPrepared(ConfigurableApplicationContext context) {
- for (NacosApplicationListener nacosApplicationListener : nacosApplicationListeners) {
- nacosApplicationListener.contextPrepared(context);
- }
- }
-
- @Override
- public void contextLoaded(ConfigurableApplicationContext context) {
- for (NacosApplicationListener nacosApplicationListener : nacosApplicationListeners) {
- nacosApplicationListener.contextLoaded(context);
- }
- }
-
- @Override
- public void started(ConfigurableApplicationContext context) {
- for (NacosApplicationListener nacosApplicationListener : nacosApplicationListeners) {
- nacosApplicationListener.started(context);
- }
- }
-
- @Override
- public void running(ConfigurableApplicationContext context) {
- for (NacosApplicationListener nacosApplicationListener : nacosApplicationListeners) {
- nacosApplicationListener.running(context);
- }
- }
-
- @Override
- public void failed(ConfigurableApplicationContext context, Throwable exception) {
- for (NacosApplicationListener nacosApplicationListener : nacosApplicationListeners) {
- nacosApplicationListener.failed(context, exception);
- }
- }
-
- /**
- * Before {@link EventPublishingRunListener}.
- *
- * @return HIGHEST_PRECEDENCE
- */
- @Override
- public int getOrder() {
- return HIGHEST_PRECEDENCE;
- }
-}
diff --git a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/StandaloneProfileApplicationListener.java b/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/StandaloneProfileApplicationListener.java
deleted file mode 100644
index 43ab8f36..00000000
--- a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/StandaloneProfileApplicationListener.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 1999-2018 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.alibaba.nacos.core.code;
-
-import com.alibaba.nacos.sys.env.EnvUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
-import org.springframework.context.ApplicationListener;
-import org.springframework.context.annotation.Profile;
-import org.springframework.core.PriorityOrdered;
-import org.springframework.core.env.ConfigurableEnvironment;
-
-import java.util.Arrays;
-
-import static com.alibaba.nacos.sys.env.Constants.STANDALONE_MODE_PROPERTY_NAME;
-import static com.alibaba.nacos.sys.env.Constants.STANDALONE_SPRING_PROFILE;
-
-/**
- * Standalone {@link Profile} {@link ApplicationListener} for {@link ApplicationEnvironmentPreparedEvent}.
- *
- * @author Mercy
- * @see ConfigurableEnvironment#addActiveProfile(String)
- * @since 0.2.2
- */
-public class StandaloneProfileApplicationListener
- implements ApplicationListener, PriorityOrdered {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(StandaloneProfileApplicationListener.class);
-
- @Override
- public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
-
- ConfigurableEnvironment environment = event.getEnvironment();
-
- if (environment.getProperty(STANDALONE_MODE_PROPERTY_NAME, boolean.class, false)) {
- environment.addActiveProfile(STANDALONE_SPRING_PROFILE);
- }
-
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("Spring Environment's active profiles : {} in standalone mode : {}",
- Arrays.asList(environment.getActiveProfiles()), EnvUtil.getStandaloneMode());
- }
-
- }
-
- @Override
- public int getOrder() {
- return HIGHEST_PRECEDENCE;
- }
-}
diff --git a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/condition/ParamRequestCondition.java b/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/condition/ParamRequestCondition.java
deleted file mode 100644
index 0431242f..00000000
--- a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/condition/ParamRequestCondition.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 1999-2018 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.alibaba.nacos.core.code.condition;
-
-import org.springframework.util.ObjectUtils;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-/**
- * request param info. {@link org.springframework.web.bind.annotation.RequestMapping#params()}
- *
- * @author horizonzy
- * @since 1.3.2
- */
-public class ParamRequestCondition {
-
- private final Set expressions;
-
- public ParamRequestCondition(String... expressions) {
- this.expressions = parseExpressions(expressions);
- }
-
- private Set parseExpressions(String... params) {
- if (ObjectUtils.isEmpty(params)) {
- return Collections.emptySet();
- }
- Set expressions = new LinkedHashSet<>(params.length);
- for (String param : params) {
- expressions.add(new ParamExpression(param));
- }
- return expressions;
- }
-
- public Set getExpressions() {
- return expressions;
- }
-
- public ParamRequestCondition getMatchingCondition(HttpServletRequest request) {
- for (ParamExpression expression : this.expressions) {
- if (!expression.match(request)) {
- return null;
- }
- }
- return this;
- }
-
- @Override
- public String toString() {
- return "ParamRequestCondition{" + "expressions=" + expressions + '}';
- }
-
- static class ParamExpression {
-
- private final String name;
-
- private final String value;
-
- private final boolean isNegated;
-
- ParamExpression(String expression) {
- int separator = expression.indexOf('=');
- if (separator == -1) {
- this.isNegated = expression.startsWith("!");
- this.name = isNegated ? expression.substring(1) : expression;
- this.value = null;
- } else {
- this.isNegated = (separator > 0) && (expression.charAt(separator - 1) == '!');
- this.name = isNegated ? expression.substring(0, separator - 1) : expression.substring(0, separator);
- this.value = expression.substring(separator + 1);
- }
- }
-
- public final boolean match(HttpServletRequest request) {
- boolean isMatch;
- if (this.value != null) {
- isMatch = matchValue(request);
- } else {
- isMatch = matchName(request);
- }
- return this.isNegated != isMatch;
- }
-
- private boolean matchName(HttpServletRequest request) {
- return request.getParameterMap().containsKey(this.name);
- }
-
- private boolean matchValue(HttpServletRequest request) {
- return ObjectUtils.nullSafeEquals(this.value, request.getParameter(this.name));
- }
-
- @Override
- public String toString() {
- return "ParamExpression{" + "name='" + name + '\'' + ", value='" + value + '\'' + ", isNegated=" + isNegated
- + '}';
- }
- }
-}
diff --git a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/condition/PathRequestCondition.java b/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/condition/PathRequestCondition.java
deleted file mode 100644
index 33bd9deb..00000000
--- a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/code/condition/PathRequestCondition.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 1999-2018 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.alibaba.nacos.core.code.condition;
-
-import static com.alibaba.nacos.sys.env.Constants.REQUEST_PATH_SEPARATOR;
-
-/**
- * request path info. method:{@link org.springframework.web.bind.annotation.RequestMapping#method()} path: {@link
- * org.springframework.web.bind.annotation.RequestMapping#value()} or {@link org.springframework.web.bind.annotation.RequestMapping#value()}
- *
- * @author horizonzy
- * @since 1.3.2
- */
-public class PathRequestCondition {
-
- private final PathExpression pathExpression;
-
- public PathRequestCondition(String pathExpression) {
- this.pathExpression = parseExpressions(pathExpression);
- }
-
- private PathExpression parseExpressions(String pathExpression) {
- String[] split = pathExpression.split(REQUEST_PATH_SEPARATOR);
- String method = split[0];
- String path = split[1];
- return new PathExpression(method, path);
- }
-
- @Override
- public String toString() {
- return "PathRequestCondition{" + "pathExpression=" + pathExpression + '}';
- }
-
- static class PathExpression {
-
- private final String method;
-
- private final String path;
-
- PathExpression(String method, String path) {
- this.method = method;
- this.path = path;
- }
-
- @Override
- public String toString() {
- return "PathExpression{" + "method='" + method + '\'' + ", path='" + path + '\'' + '}';
- }
- }
-}
diff --git a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/config/AbstractDynamicConfig.java b/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/config/AbstractDynamicConfig.java
deleted file mode 100644
index 26499556..00000000
--- a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/config/AbstractDynamicConfig.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 1999-2020 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.alibaba.nacos.core.config;
-
-import com.alibaba.nacos.common.event.ServerConfigChangeEvent;
-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.Loggers;
-
-/**
- * Nacos abstract dynamic config.
- *
- * @author xiweng.yy
- */
-public abstract class AbstractDynamicConfig extends Subscriber {
-
- private final String configName;
-
- protected AbstractDynamicConfig(String configName) {
- this.configName = configName;
- NotifyCenter.registerSubscriber(this);
- }
-
- @Override
- public void onEvent(ServerConfigChangeEvent event) {
- resetConfig();
- }
-
- @Override
- public Class extends Event> subscribeType() {
- return ServerConfigChangeEvent.class;
- }
-
- protected void resetConfig() {
- try {
- getConfigFromEnv();
- Loggers.CORE.info("Get {} config from env, {}", configName, printConfig());
- } catch (Exception e) {
- Loggers.CORE.warn("Upgrade {} config from env failed, will use old value", configName, e);
- }
- }
-
- /**
- * Execute get config from env actually.
- */
- protected abstract void getConfigFromEnv();
-
- /**
- * Print config content.
- *
- * @return config content
- */
- protected abstract String printConfig();
-}
diff --git a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/controller/CoreOpsController.java b/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/controller/CoreOpsController.java
deleted file mode 100644
index 1c9efb1a..00000000
--- a/ruoyi-visual/ruoyi-nacos/src/main/java/com/alibaba/nacos/core/controller/CoreOpsController.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 1999-2018 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.alibaba.nacos.core.controller;
-
-import com.alibaba.nacos.auth.annotation.Secured;
-import com.alibaba.nacos.plugin.auth.constant.ActionTypes;
-import com.alibaba.nacos.common.model.RestResult;
-import com.alibaba.nacos.common.model.RestResultUtils;
-import com.alibaba.nacos.core.distributed.ProtocolManager;
-import com.alibaba.nacos.core.distributed.id.IdGeneratorManager;
-import com.alibaba.nacos.core.utils.Commons;
-import com.alibaba.nacos.core.utils.Loggers;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.servlet.http.HttpServletResponse;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Kernel modules operate and maintain HTTP interfaces.
- *
- * @author liaochuntao
- */
-@RestController
-@RequestMapping(Commons.NACOS_CORE_CONTEXT + "/ops")
-public class CoreOpsController {
-
- private final ProtocolManager protocolManager;
-
- private final IdGeneratorManager idGeneratorManager;
-
- public CoreOpsController(ProtocolManager protocolManager, IdGeneratorManager idGeneratorManager) {
- this.protocolManager = protocolManager;
- this.idGeneratorManager = idGeneratorManager;
- }
-
- // Temporarily overpassed the raft operations interface
- // {
- // "groupId": "xxx",
- // "command": "transferLeader or doSnapshot or resetRaftCluster or removePeer"
- // "value": "ip:{raft_port}"
- // }
-
- @PostMapping(value = "/raft")
- @Secured(action = ActionTypes.WRITE, resource = "nacos/admin")
- public RestResult raftOps(@RequestBody Map commands) {
- return protocolManager.getCpProtocol().execute(commands);
- }
-
- /**
- * Gets the current health of the ID generator.
- *
- * @return {@link RestResult}
- */
- @GetMapping(value = "/idInfo")
- public RestResult