From caf7213c2d5e18652ed47a28d20a2457c19e0ff3 Mon Sep 17 00:00:00 2001 From: nkorange Date: Sun, 27 Jan 2019 22:50:41 +0800 Subject: [PATCH] #502 Fix serialize problem and do some refactoring for health check --- .../nacos/api/naming/pojo/Service.java | 1 + .../META-INF/nacos-default.properties | 4 ++ distribution/conf/application.properties | 4 ++ .../ephemeral/partition/DataSyncer.java | 6 ++- .../ephemeral/partition/PartitionConfig.java | 8 ++-- .../persistent/raft/RaftStore.java | 42 ++++++++++++------- .../naming/controllers/CatalogController.java | 2 +- .../naming/controllers/HealthController.java | 4 +- .../controllers/OperatorController.java | 4 +- .../naming/controllers/ServiceController.java | 3 -- .../alibaba/nacos/naming/core/Service.java | 4 -- .../healthcheck/ClientBeatCheckTask.java | 5 +-- .../healthcheck/ClientBeatProcessor.java | 4 -- .../naming/healthcheck/HealthCheckCommon.java | 4 -- .../naming/healthcheck/HealthCheckMode.java | 36 ---------------- .../HealthCheckProcessorDelegate.java | 5 ++- .../naming/healthcheck/HealthCheckTask.java | 14 +++---- .../naming/healthcheck/HealthCheckType.java | 6 ++- .../healthcheck/HttpHealthCheckProcessor.java | 4 +- .../MysqlHealthCheckProcessor.java | 6 --- .../healthcheck/NoneHealthCheckProcessor.java | 23 ++++++++++ .../healthcheck/TcpSuperSenseProcessor.java | 4 -- .../nacos/naming/misc/SwitchDomain.java | 12 ------ .../nacos/naming/misc/SwitchManager.java | 11 ----- .../alibaba/nacos/naming/core/DomainTest.java | 4 -- 25 files changed, 93 insertions(+), 127 deletions(-) delete mode 100644 naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckMode.java create mode 100644 naming/src/main/java/com/alibaba/nacos/naming/healthcheck/NoneHealthCheckProcessor.java diff --git a/api/src/main/java/com/alibaba/nacos/api/naming/pojo/Service.java b/api/src/main/java/com/alibaba/nacos/api/naming/pojo/Service.java index 07a06c2b4..e9d4b7359 100644 --- a/api/src/main/java/com/alibaba/nacos/api/naming/pojo/Service.java +++ b/api/src/main/java/com/alibaba/nacos/api/naming/pojo/Service.java @@ -50,6 +50,7 @@ public class Service { /** * Health check mode. */ + @Deprecated private String healthCheckMode; /** diff --git a/console/src/main/resources/META-INF/nacos-default.properties b/console/src/main/resources/META-INF/nacos-default.properties index 10168e2a0..1a67d44a1 100644 --- a/console/src/main/resources/META-INF/nacos-default.properties +++ b/console/src/main/resources/META-INF/nacos-default.properties @@ -64,3 +64,7 @@ server.tomcat.accesslog.enabled=true server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D # default current work dir server.tomcat.basedir= + +nacos.naming.partition.taskDispatchThreadCount=10 +nacos.naming.partition.taskDispatchPeriod=200 +nacos.naming.partition.batchSyncKeyCount=1000 diff --git a/distribution/conf/application.properties b/distribution/conf/application.properties index e0624f8de..446f0c871 100644 --- a/distribution/conf/application.properties +++ b/distribution/conf/application.properties @@ -38,3 +38,7 @@ server.tomcat.basedir= #nacos.security.ignore.urls=/** nacos.security.ignore.urls=/,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/login,/v1/console/health,/v1/cs/**,/v1/ns/**,/v1/cmdb/**,/actuator/** + +nacos.naming.partition.taskDispatchThreadCount=10 +nacos.naming.partition.taskDispatchPeriod=200 +nacos.naming.partition.batchSyncKeyCount=1000 diff --git a/naming/src/main/java/com/alibaba/nacos/naming/consistency/ephemeral/partition/DataSyncer.java b/naming/src/main/java/com/alibaba/nacos/naming/consistency/ephemeral/partition/DataSyncer.java index 47c59e3a7..fd47be3be 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/consistency/ephemeral/partition/DataSyncer.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/consistency/ephemeral/partition/DataSyncer.java @@ -28,8 +28,10 @@ import com.alibaba.nacos.naming.misc.UtilsAndCommons; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.ObjectFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.DependsOn; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -43,6 +45,7 @@ import java.util.concurrent.ConcurrentHashMap; * @since 1.0.0 */ @Component +@DependsOn("serverListManager") public class DataSyncer implements MemberChangeListener { @Autowired @@ -61,7 +64,8 @@ public class DataSyncer implements MemberChangeListener { private List servers; - public DataSyncer() { + @PostConstruct + public void init() { serverListManager.listen(this); startTimedSync(); } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/consistency/ephemeral/partition/PartitionConfig.java b/naming/src/main/java/com/alibaba/nacos/naming/consistency/ephemeral/partition/PartitionConfig.java index 22f0b9f89..1bef51ee1 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/consistency/ephemeral/partition/PartitionConfig.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/consistency/ephemeral/partition/PartitionConfig.java @@ -16,6 +16,7 @@ package com.alibaba.nacos.naming.consistency.ephemeral.partition; import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; /** * Stores some configurations for Partition protocol @@ -23,15 +24,16 @@ import org.springframework.beans.factory.annotation.Value; * @author nkorange * @since 1.0.0 */ +@Component public class PartitionConfig { - @Value("taskDispatchThreadCount") + @Value("${nacos.naming.partition.taskDispatchThreadCount}") private int taskDispatchThreadCount = 10; - @Value("taskDispatchPeriod") + @Value("${nacos.naming.partition.taskDispatchPeriod}") private int taskDispatchPeriod = 2000; - @Value("batchSyncKeyCount") + @Value("${nacos.naming.partition.batchSyncKeyCount}") private int batchSyncKeyCount = 1000; public int getTaskDispatchThreadCount() { diff --git a/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/raft/RaftStore.java b/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/raft/RaftStore.java index 1478403e4..f08656cb9 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/raft/RaftStore.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/raft/RaftStore.java @@ -135,25 +135,37 @@ public class RaftStore { } if (KeyBuilder.matchServiceMetaKey(file.getName())) { - return JSON.parseObject(json.replace("\\", ""), new TypeReference>() { - }); + try { + return JSON.parseObject(json.replace("\\", ""), new TypeReference>() { + }); + } catch (Exception e) { + Datum datum = JSON.parseObject(json, new TypeReference>(){}); + Datum serviceDatum = new Datum<>(); + serviceDatum.timestamp.set(datum.timestamp.get()); + serviceDatum.key = datum.key; + serviceDatum.value = JSON.parseObject(datum.value, Service.class); + return serviceDatum; + } } if (KeyBuilder.matchInstanceListKey(file.getName())) { - Datum> datum = JSON.parseObject(json, new TypeReference>>() { - }); - Map instanceMap = new HashMap<>(64); - if (datum.value == null || datum.value.isEmpty()) { - return datum; + try { + return JSON.parseObject(json, new TypeReference>() { + }); + } catch (Exception e) { + Datum datum = JSON.parseObject(json, new TypeReference>(){}); + List instanceList = JSON.parseObject(datum.value, new TypeReference>(){}); + Datum instancesDatum = new Datum<>(); + instancesDatum.key = datum.key; + instancesDatum.timestamp.set(datum.timestamp.get()); + + Instances instances = new Instances(); + instances.setInstanceMap(new HashMap<>(16)); + for (Instance instance : instanceList) { + instances.getInstanceMap().put(instance.getDatumKey(), instance); + } + return instancesDatum; } - for (Instance instance : datum.value) { - instanceMap.put(instance.getDatumKey(), instance); - } - Datum> mapDatum = new Datum<>(); - mapDatum.value = instanceMap; - mapDatum.key = datum.key; - mapDatum.timestamp.set(datum.timestamp.get()); - return mapDatum; } return JSON.parseObject(json, Datum.class); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java index fb61b742a..6ba409695 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java @@ -46,7 +46,7 @@ import java.util.*; * @author nkorange */ @RestController -@RequestMapping(UtilsAndCommons.NACOS_NAMING_CONTEXT + UtilsAndCommons.NACOS_NAMING_CATALOG_CONTEXT) +@RequestMapping(UtilsAndCommons.NACOS_NAMING_CONTEXT + "/catalog") public class CatalogController { @Autowired diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/HealthController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/HealthController.java index 8fb51fdf7..796986b9f 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/HealthController.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/HealthController.java @@ -23,7 +23,7 @@ import com.alibaba.nacos.naming.core.DistroMapper; import com.alibaba.nacos.naming.core.Instance; import com.alibaba.nacos.naming.core.Service; import com.alibaba.nacos.naming.core.ServiceManager; -import com.alibaba.nacos.naming.healthcheck.HealthCheckMode; +import com.alibaba.nacos.naming.healthcheck.HealthCheckType; import com.alibaba.nacos.naming.misc.HttpClient; import com.alibaba.nacos.naming.misc.Loggers; import com.alibaba.nacos.naming.misc.UtilsAndCommons; @@ -102,7 +102,7 @@ public class HealthController { } else { Service service = serviceManager.getService(namespaceId, dom); // Only health check "none" need update health status with api - if (service.getHealthCheckMode().equals(HealthCheckMode.none.name())) { + if (HealthCheckType.NONE.name().equals(service.getClusterMap().get(clusterName).getHealthChecker().getType())) { for (Instance instance : service.allIPs(Lists.newArrayList(clusterName))) { if (instance.getIp().equals(ip) && instance.getPort() == port) { instance.setValid(valid); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/OperatorController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/OperatorController.java index 1f49b819f..14cd1cb3b 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/OperatorController.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/OperatorController.java @@ -33,6 +33,7 @@ import com.alibaba.nacos.naming.web.NeedAuth; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; @@ -45,6 +46,7 @@ import java.util.List; * @author nkorange */ @RestController +@RequestMapping(UtilsAndCommons.NACOS_NAMING_CONTEXT + "/operator") public class OperatorController { @Autowired @@ -120,7 +122,7 @@ public class OperatorController { } - @RequestMapping("/metrics") + @RequestMapping(value = "/metrics", method = RequestMethod.GET) public JSONObject metrics(HttpServletRequest request) { JSONObject result = new JSONObject(); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/ServiceController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/ServiceController.java index b07fccd97..869c24b61 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/ServiceController.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/ServiceController.java @@ -78,7 +78,6 @@ public class ServiceController { } float protectThreshold = NumberUtils.toFloat(WebUtils.optional(request, "protectThreshold", "0")); - String healthCheckMode = WebUtils.optional(request, "healthCheckMode", switchDomain.defaultHealthCheckMode); String metadata = WebUtils.optional(request, "metadata", StringUtils.EMPTY); String selector = WebUtils.optional(request, "selector", StringUtils.EMPTY); Map metadataMap = new HashMap<>(16); @@ -89,7 +88,6 @@ public class ServiceController { Service domObj = new Service(); domObj.setName(serviceName); domObj.setProtectThreshold(protectThreshold); - domObj.setHealthCheckMode(healthCheckMode.toLowerCase()); domObj.setEnabled(true); domObj.setMetadata(metadataMap); domObj.setSelector(parseSelector(selector)); @@ -142,7 +140,6 @@ public class ServiceController { res.put("name", serviceName); res.put("namespaceId", domain.getNamespaceId()); res.put("protectThreshold", domain.getProtectThreshold()); - res.put("healthCheckMode", domain.getHealthCheckMode()); res.put("metadata", domain.getMetadata()); res.put("selector", domain.getSelector()); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java index 21a4eeada..fb17c5a40 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java @@ -409,10 +409,6 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement resetWeight = vDom.getResetWeight(); } - if (getHealthCheckMode().equals(vDom.getHealthCheckMode())) { - Loggers.SRV_LOG.info("[DOM-UPDATE] dom: {}, healthCheckMode: {} -> {}", getName(), getHealthCheckMode(), vDom.getHealthCheckMode()); - } - if (enabled != vDom.getEnabled().booleanValue()) { Loggers.SRV_LOG.info("[DOM-UPDATE] dom: {}, enabled: {} -> {}", getName(), enabled, vDom.getEnabled()); enabled = vDom.getEnabled(); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatCheckTask.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatCheckTask.java index 4986cbf51..6787e8338 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatCheckTask.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatCheckTask.java @@ -60,12 +60,11 @@ public class ClientBeatCheckTask implements Runnable { @Override public void run() { try { - if (!domain.getHealthCheckMode().equals(HealthCheckMode.client.name()) || - !getDistroMapper().responsible(domain.getName())) { + if (!getDistroMapper().responsible(domain.getName())) { return; } - List instances = domain.allIPs(); + List instances = domain.allIPs(true); for (Instance instance : instances) { if (System.currentTimeMillis() - instance.getLastBeat() > ClientBeatProcessor.CLIENT_BEAT_TIMEOUT) { diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatProcessor.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatProcessor.java index eca855347..cefbf577a 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatProcessor.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatProcessor.java @@ -61,10 +61,6 @@ public class ClientBeatProcessor implements Runnable { public void process() { Service service = this.service; - if (!service.getHealthCheckMode().equals(HealthCheckMode.client.name())) { - return; - } - Loggers.EVT_LOG.debug("[CLIENT-BEAT] processing beat: {}", rsInfo.toString()); String ip = rsInfo.getIp(); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckCommon.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckCommon.java index 79081083d..d9cd2d142 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckCommon.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckCommon.java @@ -108,10 +108,6 @@ public class HealthCheckCommon { }, 500, TimeUnit.MILLISECONDS); } - public boolean isHealthCheckEnabled(Service service) { - return service.getHealthCheckMode().equals(HealthCheckMode.server.name()); - } - public void reEvaluateCheckRT(long checkRT, HealthCheckTask task, SwitchDomain.HealthParams params) { task.setCheckRTLast(checkRT); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckMode.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckMode.java deleted file mode 100644 index f7bead172..000000000 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckMode.java +++ /dev/null @@ -1,36 +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.naming.healthcheck; - -/** - * Health check mode - * - * @author nkorange - */ -public enum HealthCheckMode { - /** - * Health check sent from server. - */ - server, - /** - * Health check sent from client. - */ - client, - /** - * Health check disabled. - */ - none -} diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckProcessorDelegate.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckProcessorDelegate.java index 4ec69d485..c1508c50c 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckProcessorDelegate.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckProcessorDelegate.java @@ -33,6 +33,9 @@ public class HealthCheckProcessorDelegate implements HealthCheckProcessor { @Autowired private MysqlHealthCheckProcessor mysqlProcessor; + @Autowired + private NoneHealthCheckProcessor noneProcessor; + @Override public void process(HealthCheckTask task) { @@ -53,7 +56,7 @@ public class HealthCheckProcessorDelegate implements HealthCheckProcessor { return; } - throw new IllegalArgumentException("Unknown check type: " + type); + noneProcessor.process(task); } @Override diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckTask.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckTask.java index 6cd24e105..58e624996 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckTask.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckTask.java @@ -19,7 +19,6 @@ import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.nacos.naming.boot.SpringContext; import com.alibaba.nacos.naming.core.Cluster; import com.alibaba.nacos.naming.core.DistroMapper; -import com.alibaba.nacos.naming.core.Service; import com.alibaba.nacos.naming.misc.Loggers; import com.alibaba.nacos.naming.misc.SwitchDomain; import org.apache.commons.lang3.RandomUtils; @@ -70,7 +69,8 @@ public class HealthCheckTask implements Runnable { public void run() { try { - if (distroMapper.responsible(cluster.getDom().getName())) { + if (distroMapper.responsible(cluster.getDom().getName()) && + switchDomain.isHealthCheckEnabled(cluster.getDom().getName())) { healthCheckProcessor.process(this); Loggers.EVT_LOG.debug("[HEALTH-CHECK] schedule health check task: {}", cluster.getDom().getName()); } @@ -92,12 +92,10 @@ public class HealthCheckTask implements Runnable { this.setCheckRTLastLast(this.getCheckRTLast()); Cluster cluster = this.getCluster(); - if ((cluster.getDom()).getHealthCheckMode().equals(HealthCheckMode.server.name())) { - Loggers.CHECK_RT.info("{}:{}@{}->normalized: {}, worst: {}, best: {}, last: {}, diff: {}", - cluster.getDom().getName(), cluster.getName(), cluster.getHealthChecker().getType(), - this.getCheckRTNormalized(), this.getCheckRTWorst(), this.getCheckRTBest(), - this.getCheckRTLast(), diff); - } + Loggers.CHECK_RT.info("{}:{}@{}->normalized: {}, worst: {}, best: {}, last: {}, diff: {}", + cluster.getDom().getName(), cluster.getName(), cluster.getHealthChecker().getType(), + this.getCheckRTNormalized(), this.getCheckRTWorst(), this.getCheckRTBest(), + this.getCheckRTLast(), diff); } } } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckType.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckType.java index 0790bdedd..8cf030f5c 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckType.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckType.java @@ -30,5 +30,9 @@ public enum HealthCheckType { /** * MySQL type */ - MYSQL + MYSQL, + /** + * No check + */ + NONE } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HttpHealthCheckProcessor.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HttpHealthCheckProcessor.java index 993a06111..90ef29159 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HttpHealthCheckProcessor.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HttpHealthCheckProcessor.java @@ -90,9 +90,7 @@ public class HttpHealthCheckProcessor implements HealthCheckProcessor { return; } - Service service = task.getCluster().getDom(); - - if (!switchDomain.isHealthCheckEnabled() || !service.getHealthCheckMode().equals(HealthCheckMode.server.name())) { + if (!switchDomain.isHealthCheckEnabled()) { return; } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/MysqlHealthCheckProcessor.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/MysqlHealthCheckProcessor.java index 7b16ea053..824f12604 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/MysqlHealthCheckProcessor.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/MysqlHealthCheckProcessor.java @@ -96,12 +96,6 @@ public class MysqlHealthCheckProcessor implements HealthCheckProcessor { return; } - Service service = task.getCluster().getDom(); - - if (!healthCheckCommon.isHealthCheckEnabled(service)) { - return; - } - for (Instance ip : ips) { try { diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/NoneHealthCheckProcessor.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/NoneHealthCheckProcessor.java new file mode 100644 index 000000000..a9a665d0b --- /dev/null +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/NoneHealthCheckProcessor.java @@ -0,0 +1,23 @@ +package com.alibaba.nacos.naming.healthcheck; + +import org.springframework.stereotype.Component; + +/** + * Health checker that does nothing + * + * @author nkorange + * @since 1.0.0 + */ +@Component +public class NoneHealthCheckProcessor implements HealthCheckProcessor { + + @Override + public void process(HealthCheckTask task) { + return; + } + + @Override + public String getType() { + return "NONE"; + } +} diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/TcpSuperSenseProcessor.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/TcpSuperSenseProcessor.java index 0ae9eb998..e477c2d0f 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/TcpSuperSenseProcessor.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/TcpSuperSenseProcessor.java @@ -113,10 +113,6 @@ public class TcpSuperSenseProcessor implements HealthCheckProcessor, Runnable { } Service service = task.getCluster().getDom(); - if (!healthCheckCommon.isHealthCheckEnabled(service)) { - return; - } - for (Instance ip : ips) { if (ip.isMarked()) { diff --git a/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchDomain.java b/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchDomain.java index 62f9d237a..ff61bcebf 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchDomain.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchDomain.java @@ -17,8 +17,6 @@ package com.alibaba.nacos.naming.misc; import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.nacos.naming.consistency.DataListener; -import com.alibaba.nacos.naming.healthcheck.HealthCheckMode; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; import java.util.*; @@ -52,8 +50,6 @@ public class SwitchDomain implements DataListener { public boolean healthCheckEnabled = true; - public String defaultHealthCheckMode = HealthCheckMode.client.name(); - public boolean distroEnabled = true; public boolean enableStandalone = true; @@ -259,14 +255,6 @@ public class SwitchDomain implements DataListener { return healthCheckEnabled || getHealthCheckWhiteList().contains(dom); } - public String getDefaultHealthCheckMode() { - return defaultHealthCheckMode; - } - - public void setDefaultHealthCheckMode(String defaultHealthCheckMode) { - this.defaultHealthCheckMode = defaultHealthCheckMode; - } - public boolean isDistroEnabled() { return distroEnabled; } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java b/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java index d82f2e70d..7a7dbfc36 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java @@ -235,17 +235,6 @@ public class SwitchManager { return; } - if (entry.equals(SwitchEntry.DEFAULT_HEALTH_CHECK_MODE)) { - String defaultHealthCheckMode = value; - - switchDomain.setDefaultHealthCheckMode(defaultHealthCheckMode); - if (!debug) { - consistencyService.put(UtilsAndCommons.getSwitchDomainKey(), JSON.toJSONString(switchDomain)); - ; - } - return; - } - if (entry.equals(SwitchEntry.DOM_STATUS_SYNC_PERIOD)) { Long millis = Long.parseLong(value); diff --git a/naming/src/test/java/com/alibaba/nacos/naming/core/DomainTest.java b/naming/src/test/java/com/alibaba/nacos/naming/core/DomainTest.java index d3dcafc4f..8e2529584 100644 --- a/naming/src/test/java/com/alibaba/nacos/naming/core/DomainTest.java +++ b/naming/src/test/java/com/alibaba/nacos/naming/core/DomainTest.java @@ -15,8 +15,6 @@ */ package com.alibaba.nacos.naming.core; -import com.alibaba.fastjson.JSON; -import com.alibaba.nacos.naming.healthcheck.HealthCheckMode; import com.alibaba.nacos.naming.misc.UtilsAndCommons; import org.junit.Assert; import org.junit.Before; @@ -49,7 +47,6 @@ public class DomainTest { Service newDomain = new Service(); newDomain.setName("nacos.domain.1"); - newDomain.setHealthCheckMode(HealthCheckMode.client.name()); newDomain.setProtectThreshold(0.7f); Cluster cluster = new Cluster(); cluster.setName(UtilsAndCommons.DEFAULT_CLUSTER_NAME); @@ -58,7 +55,6 @@ public class DomainTest { domain.update(newDomain); - Assert.assertEquals(HealthCheckMode.client.name(), domain.getHealthCheckMode()); Assert.assertEquals(0.7f, domain.getProtectThreshold(), 0.0001f); }