From 0856b009fca6694fb570e7e48a0ddab5035ba42a Mon Sep 17 00:00:00 2001 From: yuluo-yx Date: Sun, 15 Sep 2024 14:35:54 +0800 Subject: [PATCH 1/4] [imporve]: plit discovery center related monitoring into a separate module Signed-off-by: yuluo-yx --- collector/colletcor-discovery/pom.xml | 21 +++++++++++++++++++ .../colletcor/collect/DiscoveryImpl.java} | 11 ++++++---- .../collect}/discovery/DiscoveryClient.java | 3 ++- .../discovery/DiscoveryClientManagement.java | 3 ++- .../constant/DiscoveryClientHealthStatus.java | 2 +- .../constant/DiscoveryClientInstance.java | 2 +- .../discovery/entity/ConnectConfig.java | 2 +- .../collect}/discovery/entity/ServerInfo.java | 2 +- .../discovery/entity/ServiceInstance.java | 3 ++- .../discovery/impl/ConsulDiscoveryClient.java | 17 ++++++++------- .../discovery/impl/NacosDiscoveryClient.java | 9 ++++---- .../discovery/test/DiscoveryImplTest.java} | 0 ...sdProtocol.java => DiscoveryProtocol.java} | 5 +++-- 13 files changed, 55 insertions(+), 25 deletions(-) create mode 100644 collector/colletcor-discovery/pom.xml rename collector/{collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/HttpsdImpl.java => colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/DiscoveryImpl.java} (96%) rename collector/{collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd => colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect}/discovery/DiscoveryClient.java (96%) rename collector/{collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd => colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect}/discovery/DiscoveryClientManagement.java (97%) rename collector/{collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd => colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery}/constant/DiscoveryClientHealthStatus.java (94%) rename collector/{collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd => colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery}/constant/DiscoveryClientInstance.java (96%) rename collector/{collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd => colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect}/discovery/entity/ConnectConfig.java (93%) rename collector/{collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd => colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect}/discovery/entity/ServerInfo.java (93%) rename collector/{collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd => colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect}/discovery/entity/ServiceInstance.java (94%) rename collector/{collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd => colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect}/discovery/impl/ConsulDiscoveryClient.java (90%) rename collector/{collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd => colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect}/discovery/impl/NacosDiscoveryClient.java (98%) rename collector/{collector-basic/src/test/java/org/apache/hertzbeat/collector/collect/httpsd/HttpsdImplTest.java => colletcor-discovery/src/test/java/org/apache/hertzbeat/collector/collect/discovery/test/DiscoveryImplTest.java} (100%) rename common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/{HttpsdProtocol.java => DiscoveryProtocol.java} (95%) diff --git a/collector/colletcor-discovery/pom.xml b/collector/colletcor-discovery/pom.xml new file mode 100644 index 00000000000..17a54d20f7d --- /dev/null +++ b/collector/colletcor-discovery/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + org.apache.hertzbeat + hertzbeat-collector + 2.0-SNAPSHOT + + + org.apache + hertzbeat-colletcor-discovery + + + 17 + 17 + UTF-8 + + + \ No newline at end of file diff --git a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/HttpsdImpl.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/DiscoveryImpl.java similarity index 96% rename from collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/HttpsdImpl.java rename to collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/DiscoveryImpl.java index 92d494ca7d8..41b05b3fc3e 100644 --- a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/HttpsdImpl.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/DiscoveryImpl.java @@ -17,14 +17,17 @@ * under the License. */ -package org.apache.hertzbeat.collector.collect.httpsd; +package org.apache.colletcor.collect; -import com.ecwid.consul.transport.TransportException; -import com.google.common.annotations.VisibleForTesting; import java.lang.reflect.Field; import java.util.Objects; + +import com.ecwid.consul.transport.TransportException; +import com.google.common.annotations.VisibleForTesting; import lombok.Setter; import lombok.extern.slf4j.Slf4j; +import org.apache.colletcor.collect.discovery.DiscoveryClient; +import org.apache.colletcor.collect.discovery.DiscoveryClientManagement; import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.collector.collect.AbstractCollect; import org.apache.hertzbeat.collector.collect.httpsd.discovery.DiscoveryClient; @@ -42,7 +45,7 @@ * http_sd protocol collection implementation */ @Slf4j -public class HttpsdImpl extends AbstractCollect { +public class DiscoveryImpl extends AbstractCollect { private static final String SERVER = "server"; @Setter diff --git a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/DiscoveryClient.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClient.java similarity index 96% rename from collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/DiscoveryClient.java rename to collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClient.java index b6329996766..074bc3a9475 100644 --- a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/DiscoveryClient.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClient.java @@ -17,9 +17,10 @@ * under the License. */ -package org.apache.hertzbeat.collector.collect.httpsd.discovery; +package org.apache.colletcor.collect.discovery; import java.util.List; + import org.apache.hertzbeat.collector.collect.httpsd.discovery.entity.ConnectConfig; import org.apache.hertzbeat.collector.collect.httpsd.discovery.entity.ServerInfo; import org.apache.hertzbeat.collector.collect.httpsd.discovery.entity.ServiceInstance; diff --git a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/DiscoveryClientManagement.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClientManagement.java similarity index 97% rename from collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/DiscoveryClientManagement.java rename to collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClientManagement.java index 493658d5316..32f243049b6 100644 --- a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/DiscoveryClientManagement.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClientManagement.java @@ -17,9 +17,10 @@ * under the License. */ -package org.apache.hertzbeat.collector.collect.httpsd.discovery; +package org.apache.colletcor.collect.discovery; import java.util.Objects; + import org.apache.hertzbeat.collector.collect.httpsd.constant.DiscoveryClientInstance; import org.apache.hertzbeat.collector.collect.httpsd.discovery.impl.ConsulDiscoveryClient; import org.apache.hertzbeat.collector.collect.httpsd.discovery.impl.NacosDiscoveryClient; diff --git a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/constant/DiscoveryClientHealthStatus.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientHealthStatus.java similarity index 94% rename from collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/constant/DiscoveryClientHealthStatus.java rename to collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientHealthStatus.java index 4f113bfd20e..cc962da8e2d 100644 --- a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/constant/DiscoveryClientHealthStatus.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientHealthStatus.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.hertzbeat.collector.collect.httpsd.constant; +package org.apache.colletcor.collect.discovery.constant; /** * Discovery client instance status. diff --git a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/constant/DiscoveryClientInstance.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientInstance.java similarity index 96% rename from collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/constant/DiscoveryClientInstance.java rename to collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientInstance.java index 3d34fe11306..144f9bbc34d 100644 --- a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/constant/DiscoveryClientInstance.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientInstance.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.hertzbeat.collector.collect.httpsd.constant; +package org.apache.colletcor.collect.discovery.constant; import java.util.Arrays; import org.apache.commons.lang3.StringUtils; diff --git a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/entity/ConnectConfig.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ConnectConfig.java similarity index 93% rename from collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/entity/ConnectConfig.java rename to collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ConnectConfig.java index 68bb93f067f..6f0168aede2 100644 --- a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/entity/ConnectConfig.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ConnectConfig.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.hertzbeat.collector.collect.httpsd.discovery.entity; +package org.apache.colletcor.collect.discovery.entity; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/entity/ServerInfo.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServerInfo.java similarity index 93% rename from collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/entity/ServerInfo.java rename to collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServerInfo.java index 52e23621bca..7f450a0d873 100644 --- a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/entity/ServerInfo.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServerInfo.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.hertzbeat.collector.collect.httpsd.discovery.entity; +package org.apache.colletcor.collect.discovery.entity; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/entity/ServiceInstance.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServiceInstance.java similarity index 94% rename from collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/entity/ServiceInstance.java rename to collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServiceInstance.java index b0d26fb571c..7d34bba20d0 100644 --- a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/entity/ServiceInstance.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServiceInstance.java @@ -17,9 +17,10 @@ * under the License. */ -package org.apache.hertzbeat.collector.collect.httpsd.discovery.entity; +package org.apache.colletcor.collect.discovery.entity; import java.util.Map; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/impl/ConsulDiscoveryClient.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/ConsulDiscoveryClient.java similarity index 90% rename from collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/impl/ConsulDiscoveryClient.java rename to collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/ConsulDiscoveryClient.java index 67ba993f555..ffe09723621 100644 --- a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/impl/ConsulDiscoveryClient.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/ConsulDiscoveryClient.java @@ -17,21 +17,22 @@ * under the License. */ -package org.apache.hertzbeat.collector.collect.httpsd.discovery.impl; +package org.apache.colletcor.collect.discovery.impl; + +import java.util.Collection; +import java.util.List; +import java.util.Map; import com.ecwid.consul.v1.ConsulClient; import com.ecwid.consul.v1.agent.model.Check; import com.ecwid.consul.v1.agent.model.Self; import com.ecwid.consul.v1.agent.model.Service; import com.google.common.collect.Lists; -import java.util.Collection; -import java.util.List; -import java.util.Map; import org.apache.commons.lang3.StringUtils; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.DiscoveryClient; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.entity.ConnectConfig; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.entity.ServerInfo; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.entity.ServiceInstance; +import org.apache.hertzbeat.collector.collect.discovery.DiscoveryClient; +import org.apache.hertzbeat.collector.collect.discovery.entity.ConnectConfig; +import org.apache.hertzbeat.collector.collect.discovery.entity.ServerInfo; +import org.apache.hertzbeat.collector.collect.discovery.entity.ServiceInstance; import org.apache.hertzbeat.common.entity.job.protocol.HttpsdProtocol; /** diff --git a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/impl/NacosDiscoveryClient.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/NacosDiscoveryClient.java similarity index 98% rename from collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/impl/NacosDiscoveryClient.java rename to collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/NacosDiscoveryClient.java index 15838312485..bbc5a5e6c27 100644 --- a/collector/collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/httpsd/discovery/impl/NacosDiscoveryClient.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/NacosDiscoveryClient.java @@ -17,15 +17,16 @@ * under the License. */ -package org.apache.hertzbeat.collector.collect.httpsd.discovery.impl; +package org.apache.colletcor.collect.discovery.impl; + +import java.util.Collections; +import java.util.List; +import java.util.Objects; import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.api.naming.NamingFactory; import com.alibaba.nacos.api.naming.NamingService; import com.google.common.collect.Lists; -import java.util.Collections; -import java.util.List; -import java.util.Objects; import lombok.extern.slf4j.Slf4j; import org.apache.hertzbeat.collector.collect.httpsd.constant.DiscoveryClientHealthStatus; import org.apache.hertzbeat.collector.collect.httpsd.discovery.DiscoveryClient; diff --git a/collector/collector-basic/src/test/java/org/apache/hertzbeat/collector/collect/httpsd/HttpsdImplTest.java b/collector/colletcor-discovery/src/test/java/org/apache/hertzbeat/collector/collect/discovery/test/DiscoveryImplTest.java similarity index 100% rename from collector/collector-basic/src/test/java/org/apache/hertzbeat/collector/collect/httpsd/HttpsdImplTest.java rename to collector/colletcor-discovery/src/test/java/org/apache/hertzbeat/collector/collect/discovery/test/DiscoveryImplTest.java diff --git a/common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/HttpsdProtocol.java b/common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/DiscoveryProtocol.java similarity index 95% rename from common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/HttpsdProtocol.java rename to common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/DiscoveryProtocol.java index 94df4de175e..2bf164a8e42 100644 --- a/common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/HttpsdProtocol.java +++ b/common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/DiscoveryProtocol.java @@ -26,13 +26,14 @@ import org.apache.commons.lang3.StringUtils; /** - * Httpsd protocol + * Discovery protocol */ @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class HttpsdProtocol { +public class DiscoveryProtocol { + private String host; private String port; private String discoveryClientTypeName; From 6a2c1fcc5f19374edf9e34e92bbdd314ae28d88d Mon Sep 17 00:00:00 2001 From: yuluo-yx Date: Sun, 15 Sep 2024 14:36:44 +0800 Subject: [PATCH 2/4] [imporve]: Split discovery center related monitoring into a separate module Signed-off-by: yuluo-yx --- collector/collector-basic/pom.xml | 12 ---- collector/colletcor-discovery/pom.xml | 21 +++++++ .../colletcor/collect/DiscoveryImpl.java | 27 ++++---- .../collect/discovery/DiscoveryClient.java | 14 ++--- .../discovery/DiscoveryClientManagement.java | 21 +++---- .../constant/DiscoveryClientHealthStatus.java | 2 +- .../constant/DiscoveryClientInstance.java | 2 +- .../discovery/entity/ConnectConfig.java | 2 +- .../collect/discovery/entity/ServerInfo.java | 2 +- .../discovery/entity/ServiceInstance.java | 2 +- .../discovery/impl/ConsulDiscoveryClient.java | 18 +++--- .../discovery/impl/NacosDiscoveryClient.java | 20 +++--- .../discovery/test/DiscoveryImplTest.java | 63 ++++++++++--------- collector/pom.xml | 6 +- .../hertzbeat/common/entity/job/Metrics.java | 4 +- pom.xml | 2 +- 16 files changed, 110 insertions(+), 108 deletions(-) diff --git a/collector/collector-basic/pom.xml b/collector/collector-basic/pom.xml index 805bccb24d4..5a32d27b1b4 100644 --- a/collector/collector-basic/pom.xml +++ b/collector/collector-basic/pom.xml @@ -125,18 +125,6 @@ dnsjava ${dnsjava.version} - - - com.ecwid.consul - consul-api - ${consul-api.version} - - - - com.alibaba.nacos - nacos-client - ${nacos-client.version} - com.hivemq diff --git a/collector/colletcor-discovery/pom.xml b/collector/colletcor-discovery/pom.xml index 17a54d20f7d..12a02bf2396 100644 --- a/collector/colletcor-discovery/pom.xml +++ b/collector/colletcor-discovery/pom.xml @@ -3,6 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + org.apache.hertzbeat hertzbeat-collector @@ -18,4 +19,24 @@ UTF-8 + + + org.apache.hertzbeat + hertzbeat-collector-common + provided + + + + com.ecwid.consul + consul-api + ${consul-api.version} + + + + com.alibaba.nacos + nacos-client + ${nacos-client.version} + + + \ No newline at end of file diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/DiscoveryImpl.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/DiscoveryImpl.java index 41b05b3fc3e..563bdd7edfe 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/DiscoveryImpl.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/DiscoveryImpl.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.colletcor.collect; +package org.apache.hertzbeat.colletcor.collect; import java.lang.reflect.Field; import java.util.Objects; @@ -26,26 +26,25 @@ import com.google.common.annotations.VisibleForTesting; import lombok.Setter; import lombok.extern.slf4j.Slf4j; -import org.apache.colletcor.collect.discovery.DiscoveryClient; -import org.apache.colletcor.collect.discovery.DiscoveryClientManagement; +import org.apache.hertzbeat.colletcor.collect.discovery.DiscoveryClient; +import org.apache.hertzbeat.colletcor.collect.discovery.DiscoveryClientManagement; import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.collector.collect.AbstractCollect; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.DiscoveryClient; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.DiscoveryClientManagement; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.entity.ServerInfo; import org.apache.hertzbeat.collector.constants.CollectorConstants; import org.apache.hertzbeat.collector.dispatch.DispatchConstants; +import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServerInfo; import org.apache.hertzbeat.common.constants.CommonConstants; import org.apache.hertzbeat.common.entity.job.Metrics; -import org.apache.hertzbeat.common.entity.job.protocol.HttpsdProtocol; import org.apache.hertzbeat.common.entity.message.CollectRep; import org.apache.hertzbeat.common.util.CommonUtil; /** - * http_sd protocol collection implementation + * Discovery collect implementation */ + @Slf4j public class DiscoveryImpl extends AbstractCollect { + private static final String SERVER = "server"; @Setter @@ -54,17 +53,17 @@ public class DiscoveryImpl extends AbstractCollect { @Override public void preCheck(Metrics metrics) throws IllegalArgumentException { - HttpsdProtocol httpsdProtocol = metrics.getHttpsd(); - if (Objects.isNull(httpsdProtocol) || httpsdProtocol.isInvalid()){ + var discoveryProtocol = metrics.getDiscovery(); + if (Objects.isNull(discoveryProtocol) || discoveryProtocol.isInvalid()){ throw new IllegalArgumentException("http_sd collect must have a valid http_sd protocol param! "); } } @Override public void collect(CollectRep.MetricsData.Builder builder, long monitorId, String app, Metrics metrics) { - HttpsdProtocol httpsdProtocol = metrics.getHttpsd(); + var discoveryProtocol = metrics.getDiscovery(); - try (DiscoveryClient discoveryClient = discoveryClientManagement.getClient(httpsdProtocol)) { + try (DiscoveryClient discoveryClient = discoveryClientManagement.getClient(discoveryProtocol)) { collectMetrics(builder, metrics, discoveryClient); } catch (TransportException e1) { String errorMsg = "Consul " + CommonUtil.getMessageFromThrowable(e1); @@ -109,10 +108,6 @@ public String supportProtocol() { return DispatchConstants.PROTOCOL_HTTP_SD; } - private boolean checkParamsFailed(HttpsdProtocol httpsd) { - return Objects.isNull(httpsd) || httpsd.isInvalid(); - } - private void addColumnIfMatched(String fieldName, Object sourceObj, CollectRep.ValueRow.Builder valueRowBuilder) { String columnValue = null; try { diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClient.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClient.java index 074bc3a9475..1c70fa88b79 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClient.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClient.java @@ -17,14 +17,14 @@ * under the License. */ -package org.apache.colletcor.collect.discovery; +package org.apache.hertzbeat.colletcor.collect.discovery; import java.util.List; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.entity.ConnectConfig; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.entity.ServerInfo; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.entity.ServiceInstance; -import org.apache.hertzbeat.common.entity.job.protocol.HttpsdProtocol; +import org.apache.hertzbeat.colletcor.collect.discovery.entity.ConnectConfig; +import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServerInfo; +import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServiceInstance; +import org.apache.hertzbeat.common.entity.job.protocol.DiscoveryProtocol; /** * DiscoveryClient interface. @@ -33,10 +33,10 @@ public interface DiscoveryClient extends AutoCloseable { /** * Build connect config. - * @param httpsdProtocol httpsd protocol. + * @param discoveryProtocol discovery protocol. * @return connect config object. */ - ConnectConfig buildConnectConfig(HttpsdProtocol httpsdProtocol); + ConnectConfig buildConnectConfig(DiscoveryProtocol discoveryProtocol); /** * Initialize client. diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClientManagement.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClientManagement.java index 32f243049b6..a53f65284d9 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClientManagement.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClientManagement.java @@ -17,40 +17,39 @@ * under the License. */ -package org.apache.colletcor.collect.discovery; +package org.apache.hertzbeat.colletcor.collect.discovery; import java.util.Objects; - -import org.apache.hertzbeat.collector.collect.httpsd.constant.DiscoveryClientInstance; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.impl.ConsulDiscoveryClient; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.impl.NacosDiscoveryClient; -import org.apache.hertzbeat.common.entity.job.protocol.HttpsdProtocol; +import org.apache.hertzbeat.colletcor.collect.discovery.constant.DiscoveryClientInstance; +import org.apache.hertzbeat.colletcor.collect.discovery.impl.ConsulDiscoveryClient; +import org.apache.hertzbeat.colletcor.collect.discovery.impl.NacosDiscoveryClient; +import org.apache.hertzbeat.common.entity.job.protocol.DiscoveryProtocol; /** * Discovery Client Management */ public class DiscoveryClientManagement { - public DiscoveryClient getClient(HttpsdProtocol httpsdProtocol) { + public DiscoveryClient getClient(DiscoveryProtocol httpsdProtocol) { return createClient(httpsdProtocol, DiscoveryClientInstance.getByName(httpsdProtocol.getDiscoveryClientTypeName())); } - private DiscoveryClient createClient(HttpsdProtocol httpsdProtocol, DiscoveryClientInstance discoveryClientInstance) { + private DiscoveryClient createClient(DiscoveryProtocol discoveryProtocol, DiscoveryClientInstance discoveryClientInstance) { if (Objects.equals(discoveryClientInstance, DiscoveryClientInstance.NOT_SUPPORT)) { return null; } - return doCreateClient(httpsdProtocol, discoveryClientInstance); + return doCreateClient(discoveryProtocol, discoveryClientInstance); } - private DiscoveryClient doCreateClient(HttpsdProtocol httpsdProtocol, DiscoveryClientInstance discoveryClientInstance) { + private DiscoveryClient doCreateClient(DiscoveryProtocol discoveryProtocol, DiscoveryClientInstance discoveryClientInstance) { DiscoveryClient discoveryClient; switch (discoveryClientInstance) { case CONSUL -> discoveryClient = new ConsulDiscoveryClient(); case NACOS -> discoveryClient = new NacosDiscoveryClient(); default -> { return null; } } - discoveryClient.initClient(discoveryClient.buildConnectConfig(httpsdProtocol)); + discoveryClient.initClient(discoveryClient.buildConnectConfig(discoveryProtocol)); return discoveryClient; } } diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientHealthStatus.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientHealthStatus.java index cc962da8e2d..aad7b96408a 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientHealthStatus.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientHealthStatus.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.colletcor.collect.discovery.constant; +package org.apache.hertzbeat.colletcor.collect.discovery.constant; /** * Discovery client instance status. diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientInstance.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientInstance.java index 144f9bbc34d..4ca187146ed 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientInstance.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientInstance.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.colletcor.collect.discovery.constant; +package org.apache.hertzbeat.colletcor.collect.discovery.constant; import java.util.Arrays; import org.apache.commons.lang3.StringUtils; diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ConnectConfig.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ConnectConfig.java index 6f0168aede2..471bc1bf794 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ConnectConfig.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ConnectConfig.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.colletcor.collect.discovery.entity; +package org.apache.hertzbeat.colletcor.collect.discovery.entity; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServerInfo.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServerInfo.java index 7f450a0d873..c1e6293cd67 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServerInfo.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServerInfo.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.colletcor.collect.discovery.entity; +package org.apache.hertzbeat.colletcor.collect.discovery.entity; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServiceInstance.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServiceInstance.java index 7d34bba20d0..5ca6825546a 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServiceInstance.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServiceInstance.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.colletcor.collect.discovery.entity; +package org.apache.hertzbeat.colletcor.collect.discovery.entity; import java.util.Map; diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/ConsulDiscoveryClient.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/ConsulDiscoveryClient.java index ffe09723621..68de96f4808 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/ConsulDiscoveryClient.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/ConsulDiscoveryClient.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.colletcor.collect.discovery.impl; +package org.apache.hertzbeat.colletcor.collect.discovery.impl; import java.util.Collection; import java.util.List; @@ -28,12 +28,12 @@ import com.ecwid.consul.v1.agent.model.Self; import com.ecwid.consul.v1.agent.model.Service; import com.google.common.collect.Lists; +import org.apache.hertzbeat.colletcor.collect.discovery.DiscoveryClient; +import org.apache.hertzbeat.colletcor.collect.discovery.entity.ConnectConfig; +import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServerInfo; +import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServiceInstance; import org.apache.commons.lang3.StringUtils; -import org.apache.hertzbeat.collector.collect.discovery.DiscoveryClient; -import org.apache.hertzbeat.collector.collect.discovery.entity.ConnectConfig; -import org.apache.hertzbeat.collector.collect.discovery.entity.ServerInfo; -import org.apache.hertzbeat.collector.collect.discovery.entity.ServiceInstance; -import org.apache.hertzbeat.common.entity.job.protocol.HttpsdProtocol; +import org.apache.hertzbeat.common.entity.job.protocol.DiscoveryProtocol; /** * DiscoveryClient impl of Consul @@ -42,10 +42,10 @@ public class ConsulDiscoveryClient implements DiscoveryClient { private ConsulClient consulClient; @Override - public ConnectConfig buildConnectConfig(HttpsdProtocol httpsdProtocol) { + public ConnectConfig buildConnectConfig(DiscoveryProtocol discoveryProtocol) { return ConnectConfig.builder() - .host(httpsdProtocol.getHost()) - .port(Integer.parseInt(httpsdProtocol.getPort())) + .host(discoveryProtocol.getHost()) + .port(Integer.parseInt(discoveryProtocol.getPort())) .build(); } diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/NacosDiscoveryClient.java b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/NacosDiscoveryClient.java index bbc5a5e6c27..03c705c98ee 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/NacosDiscoveryClient.java +++ b/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/NacosDiscoveryClient.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.colletcor.collect.discovery.impl; +package org.apache.hertzbeat.colletcor.collect.discovery.impl; import java.util.Collections; import java.util.List; @@ -28,12 +28,12 @@ import com.alibaba.nacos.api.naming.NamingService; import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; -import org.apache.hertzbeat.collector.collect.httpsd.constant.DiscoveryClientHealthStatus; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.DiscoveryClient; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.entity.ConnectConfig; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.entity.ServerInfo; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.entity.ServiceInstance; -import org.apache.hertzbeat.common.entity.job.protocol.HttpsdProtocol; +import org.apache.hertzbeat.colletcor.collect.discovery.DiscoveryClient; +import org.apache.hertzbeat.colletcor.collect.discovery.constant.DiscoveryClientHealthStatus; +import org.apache.hertzbeat.colletcor.collect.discovery.entity.ConnectConfig; +import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServerInfo; +import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServiceInstance; +import org.apache.hertzbeat.common.entity.job.protocol.DiscoveryProtocol; /** * DiscoveryClient impl of Nacos @@ -44,10 +44,10 @@ public class NacosDiscoveryClient implements DiscoveryClient { private ConnectConfig localConnectConfig; @Override - public ConnectConfig buildConnectConfig(HttpsdProtocol httpsdProtocol) { + public ConnectConfig buildConnectConfig(DiscoveryProtocol discoveryProtocol) { return ConnectConfig.builder() - .host(httpsdProtocol.getHost()) - .port(Integer.parseInt(httpsdProtocol.getPort())) + .host(discoveryProtocol.getHost()) + .port(Integer.parseInt(discoveryProtocol.getPort())) .build(); } diff --git a/collector/colletcor-discovery/src/test/java/org/apache/hertzbeat/collector/collect/discovery/test/DiscoveryImplTest.java b/collector/colletcor-discovery/src/test/java/org/apache/hertzbeat/collector/collect/discovery/test/DiscoveryImplTest.java index 6ebf95bdce5..f035c8a0a59 100644 --- a/collector/colletcor-discovery/src/test/java/org/apache/hertzbeat/collector/collect/discovery/test/DiscoveryImplTest.java +++ b/collector/colletcor-discovery/src/test/java/org/apache/hertzbeat/collector/collect/discovery/test/DiscoveryImplTest.java @@ -15,19 +15,19 @@ * limitations under the License. */ -package org.apache.hertzbeat.collector.collect.httpsd; +package org.apache.hertzbeat.collector.collect.discovery.test; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.ArrayList; import java.util.List; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.DiscoveryClient; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.DiscoveryClientManagement; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.entity.ServerInfo; -import org.apache.hertzbeat.collector.collect.httpsd.discovery.entity.ServiceInstance; +import org.apache.hertzbeat.colletcor.collect.DiscoveryImpl; +import org.apache.hertzbeat.colletcor.collect.discovery.DiscoveryClient; +import org.apache.hertzbeat.colletcor.collect.discovery.DiscoveryClientManagement; +import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServerInfo; +import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServiceInstance; import org.apache.hertzbeat.common.entity.job.Metrics; -import org.apache.hertzbeat.common.entity.job.protocol.HttpsdProtocol; +import org.apache.hertzbeat.common.entity.job.protocol.DiscoveryProtocol; import org.apache.hertzbeat.common.entity.message.CollectRep; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; @@ -37,13 +37,14 @@ import org.mockito.junit.jupiter.MockitoExtension; /** - * Test case for {@link HttpsdImpl} + * Test case for {@link DiscoveryImpl} */ @ExtendWith(MockitoExtension.class) -class HttpsdImplTest { +class DiscoveryImplTest { + @InjectMocks @Spy - private HttpsdImpl httpsd; + private DiscoveryImpl discovery; @Mock private DiscoveryClient client; @@ -57,7 +58,7 @@ void testServerCollect() { String port = "123"; String host = "127.0.0.1"; - HttpsdProtocol httpsdProtocol = HttpsdProtocol.builder() + var httpsdProtocol = DiscoveryProtocol.builder() .port(port) .host(host) .discoveryClientTypeName("consul") @@ -68,7 +69,7 @@ void testServerCollect() { aliasField.add("responseTime"); Metrics metrics = new Metrics(); metrics.setName("server"); - metrics.setHttpsd(httpsdProtocol); + metrics.setDiscovery(httpsdProtocol); metrics.setAliasFields(aliasField); Mockito.when(discoveryClientManagement.getClient(httpsdProtocol)).thenReturn(client); @@ -77,13 +78,13 @@ void testServerCollect() { .port(port) .build(); Mockito.when(client.getServerInfo()).thenReturn(serverInfo); - httpsd.setDiscoveryClientManagement(discoveryClientManagement); - httpsd.preCheck(metrics); - httpsd.collect(builder, 1L, "test", metrics); + discovery.setDiscoveryClientManagement(discoveryClientManagement); + discovery.preCheck(metrics); + discovery.collect(builder, 1L, "test", metrics); for (CollectRep.ValueRow valueRow : builder.getValuesList()) { - assertEquals(host, valueRow.getColumns(0)); - assertEquals(port, valueRow.getColumns(1)); - assertNotNull(valueRow.getColumns(2)); + Assertions.assertEquals(host, valueRow.getColumns(0)); + Assertions.assertEquals(port, valueRow.getColumns(1)); + Assertions.assertNotNull(valueRow.getColumns(2)); } } @@ -93,7 +94,7 @@ void testServiceCollect() { String port = "123"; String host = "127.0.0.1"; - HttpsdProtocol httpsdProtocol = HttpsdProtocol.builder() + var discoveryProtocol = DiscoveryProtocol.builder() .port(port) .host(host) .discoveryClientTypeName("consul") @@ -105,10 +106,10 @@ void testServiceCollect() { aliasField.add("port"); Metrics metrics = new Metrics(); metrics.setName("service"); - metrics.setHttpsd(httpsdProtocol); + metrics.setDiscovery(discoveryProtocol); metrics.setAliasFields(aliasField); - Mockito.when(discoveryClientManagement.getClient(httpsdProtocol)).thenReturn(client); + Mockito.when(discoveryClientManagement.getClient(discoveryProtocol)).thenReturn(client); String serviceId = "test"; String serviceName = "service"; @@ -121,16 +122,16 @@ void testServiceCollect() { .build()); Mockito.when(client.getServices()).thenReturn(serviceInstances); - httpsd.setDiscoveryClientManagement(discoveryClientManagement); - httpsd.preCheck(metrics); - httpsd.collect(builder, 1L, "test", metrics); - assertEquals(builder.getValuesCount(), 1); + discovery.setDiscoveryClientManagement(discoveryClientManagement); + discovery.preCheck(metrics); + discovery.collect(builder, 1L, "test", metrics); + Assertions.assertEquals(builder.getValuesCount(), 1); for (CollectRep.ValueRow valueRow : builder.getValuesList()) { - assertEquals(serviceId, valueRow.getColumns(0)); - assertEquals(serviceName, valueRow.getColumns(1)); - assertEquals(host, valueRow.getColumns(2)); - assertEquals(port, valueRow.getColumns(3)); + Assertions.assertEquals(serviceId, valueRow.getColumns(0)); + Assertions.assertEquals(serviceName, valueRow.getColumns(1)); + Assertions.assertEquals(host, valueRow.getColumns(2)); + Assertions.assertEquals(port, valueRow.getColumns(3)); } } -} \ No newline at end of file +} diff --git a/collector/pom.xml b/collector/pom.xml index d1dccb9d625..c222415d03d 100644 --- a/collector/pom.xml +++ b/collector/pom.xml @@ -40,7 +40,8 @@ collector-mongodb collector-nebulagraph collector-rocketmq - + colletcor-discovery + @@ -77,13 +78,10 @@ org.apache.hertzbeat hertzbeat-common - apache-${project.artifactId}-${hzb.version} - - diff --git a/common/src/main/java/org/apache/hertzbeat/common/entity/job/Metrics.java b/common/src/main/java/org/apache/hertzbeat/common/entity/job/Metrics.java index 37b96db3307..9a798cfc84c 100644 --- a/common/src/main/java/org/apache/hertzbeat/common/entity/job/Metrics.java +++ b/common/src/main/java/org/apache/hertzbeat/common/entity/job/Metrics.java @@ -28,10 +28,10 @@ import lombok.Data; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.hertzbeat.common.entity.job.protocol.DiscoveryProtocol; import org.apache.hertzbeat.common.entity.job.protocol.DnsProtocol; import org.apache.hertzbeat.common.entity.job.protocol.FtpProtocol; import org.apache.hertzbeat.common.entity.job.protocol.HttpProtocol; -import org.apache.hertzbeat.common.entity.job.protocol.HttpsdProtocol; import org.apache.hertzbeat.common.entity.job.protocol.IcmpProtocol; import org.apache.hertzbeat.common.entity.job.protocol.ImapProtocol; import org.apache.hertzbeat.common.entity.job.protocol.JdbcProtocol; @@ -209,7 +209,7 @@ public class Metrics { /** * Monitoring configuration information using the public http_sd protocol */ - private HttpsdProtocol httpsd; + private DiscoveryProtocol discovery; /** * Monitoring configuration information using the public redfish protocol */ diff --git a/pom.xml b/pom.xml index d2a11c16e67..263a70bd26e 100644 --- a/pom.xml +++ b/pom.xml @@ -154,7 +154,7 @@ 4.9.4 3.5.2 1.4.5 - 2.2.1 + 2.2.4 3.6.0 4.0.2 1.0.0 From cb151691928eb0499cddd7cfc39aa80d3452d235 Mon Sep 17 00:00:00 2001 From: yuluo-yx Date: Sun, 15 Sep 2024 15:33:41 +0800 Subject: [PATCH 3/4] fix Signed-off-by: yuluo-yx --- .../pom.xml | 7 +++---- .../collect/discovery/DiscoveryClient.java | 8 ++++---- .../discovery/DiscoveryClientManagement.java | 8 ++++---- .../collect/discovery}/DiscoveryImpl.java | 6 ++---- .../constant/DiscoveryClientHealthStatus.java | 2 +- .../constant/DiscoveryClientInstance.java | 2 +- .../discovery/entity/ConnectConfig.java | 2 +- .../collect/discovery/entity/ServerInfo.java | 2 +- .../discovery/entity/ServiceInstance.java | 2 +- .../discovery/impl/ConsulDiscoveryClient.java | 10 +++++----- .../discovery/impl/NacosDiscoveryClient.java | 12 +++++------ .../discovery/test/DiscoveryImplTest.java | 10 +++++----- collector/collector/pom.xml | 6 ++++++ ...ertzbeat.collector.collect.AbstractCollect | 2 +- collector/pom.xml | 7 ++++++- home/blog/2024-06-15-hertzbeat-v1.6.0.md | 2 +- .../2024-06-15-hertzbeat-v1.6.0.md | 2 +- .../src/main/resources/define/app-http_sd.yml | 20 +++++++++---------- 18 files changed, 59 insertions(+), 51 deletions(-) rename collector/{colletcor-discovery => collector-discovery}/pom.xml (91%) rename collector/{colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor => collector-discovery/src/main/java/org/apache/hertzbeat/collector}/collect/discovery/DiscoveryClient.java (87%) rename collector/{colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor => collector-discovery/src/main/java/org/apache/hertzbeat/collector}/collect/discovery/DiscoveryClientManagement.java (89%) rename collector/{colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect => collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery}/DiscoveryImpl.java (95%) rename collector/{colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor => collector-discovery/src/main/java/org/apache/hertzbeat/collector}/collect/discovery/constant/DiscoveryClientHealthStatus.java (94%) rename collector/{colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor => collector-discovery/src/main/java/org/apache/hertzbeat/collector}/collect/discovery/constant/DiscoveryClientInstance.java (96%) rename collector/{colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor => collector-discovery/src/main/java/org/apache/hertzbeat/collector}/collect/discovery/entity/ConnectConfig.java (94%) rename collector/{colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor => collector-discovery/src/main/java/org/apache/hertzbeat/collector}/collect/discovery/entity/ServerInfo.java (94%) rename collector/{colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor => collector-discovery/src/main/java/org/apache/hertzbeat/collector}/collect/discovery/entity/ServiceInstance.java (95%) rename collector/{colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor => collector-discovery/src/main/java/org/apache/hertzbeat/collector}/collect/discovery/impl/ConsulDiscoveryClient.java (92%) rename collector/{colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor => collector-discovery/src/main/java/org/apache/hertzbeat/collector}/collect/discovery/impl/NacosDiscoveryClient.java (92%) rename collector/{colletcor-discovery => collector-discovery}/src/test/java/org/apache/hertzbeat/collector/collect/discovery/test/DiscoveryImplTest.java (93%) diff --git a/collector/colletcor-discovery/pom.xml b/collector/collector-discovery/pom.xml similarity index 91% rename from collector/colletcor-discovery/pom.xml rename to collector/collector-discovery/pom.xml index 12a02bf2396..1b21ba767c6 100644 --- a/collector/colletcor-discovery/pom.xml +++ b/collector/collector-discovery/pom.xml @@ -3,15 +3,14 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.apache.hertzbeat hertzbeat-collector 2.0-SNAPSHOT - org.apache - hertzbeat-colletcor-discovery + hertzbeat-collector-discovery + ${project.artifactId} 17 @@ -39,4 +38,4 @@ - \ No newline at end of file + diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClient.java b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/DiscoveryClient.java similarity index 87% rename from collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClient.java rename to collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/DiscoveryClient.java index 1c70fa88b79..301345d4d81 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClient.java +++ b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/DiscoveryClient.java @@ -17,13 +17,13 @@ * under the License. */ -package org.apache.hertzbeat.colletcor.collect.discovery; +package org.apache.hertzbeat.collector.collect.discovery; import java.util.List; -import org.apache.hertzbeat.colletcor.collect.discovery.entity.ConnectConfig; -import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServerInfo; -import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServiceInstance; +import org.apache.hertzbeat.collector.collect.discovery.entity.ConnectConfig; +import org.apache.hertzbeat.collector.collect.discovery.entity.ServerInfo; +import org.apache.hertzbeat.collector.collect.discovery.entity.ServiceInstance; import org.apache.hertzbeat.common.entity.job.protocol.DiscoveryProtocol; /** diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClientManagement.java b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/DiscoveryClientManagement.java similarity index 89% rename from collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClientManagement.java rename to collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/DiscoveryClientManagement.java index a53f65284d9..bbc7751069b 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/DiscoveryClientManagement.java +++ b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/DiscoveryClientManagement.java @@ -17,12 +17,12 @@ * under the License. */ -package org.apache.hertzbeat.colletcor.collect.discovery; +package org.apache.hertzbeat.collector.collect.discovery; import java.util.Objects; -import org.apache.hertzbeat.colletcor.collect.discovery.constant.DiscoveryClientInstance; -import org.apache.hertzbeat.colletcor.collect.discovery.impl.ConsulDiscoveryClient; -import org.apache.hertzbeat.colletcor.collect.discovery.impl.NacosDiscoveryClient; +import org.apache.hertzbeat.collector.collect.discovery.constant.DiscoveryClientInstance; +import org.apache.hertzbeat.collector.collect.discovery.impl.ConsulDiscoveryClient; +import org.apache.hertzbeat.collector.collect.discovery.impl.NacosDiscoveryClient; import org.apache.hertzbeat.common.entity.job.protocol.DiscoveryProtocol; /** diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/DiscoveryImpl.java b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/DiscoveryImpl.java similarity index 95% rename from collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/DiscoveryImpl.java rename to collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/DiscoveryImpl.java index 563bdd7edfe..c91ff2be3fb 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/DiscoveryImpl.java +++ b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/DiscoveryImpl.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.hertzbeat.colletcor.collect; +package org.apache.hertzbeat.collector.collect.discovery; import java.lang.reflect.Field; import java.util.Objects; @@ -26,13 +26,11 @@ import com.google.common.annotations.VisibleForTesting; import lombok.Setter; import lombok.extern.slf4j.Slf4j; -import org.apache.hertzbeat.colletcor.collect.discovery.DiscoveryClient; -import org.apache.hertzbeat.colletcor.collect.discovery.DiscoveryClientManagement; import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.collector.collect.AbstractCollect; import org.apache.hertzbeat.collector.constants.CollectorConstants; import org.apache.hertzbeat.collector.dispatch.DispatchConstants; -import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServerInfo; +import org.apache.hertzbeat.collector.collect.discovery.entity.ServerInfo; import org.apache.hertzbeat.common.constants.CommonConstants; import org.apache.hertzbeat.common.entity.job.Metrics; import org.apache.hertzbeat.common.entity.message.CollectRep; diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientHealthStatus.java b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/constant/DiscoveryClientHealthStatus.java similarity index 94% rename from collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientHealthStatus.java rename to collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/constant/DiscoveryClientHealthStatus.java index aad7b96408a..d4f7788b532 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientHealthStatus.java +++ b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/constant/DiscoveryClientHealthStatus.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.hertzbeat.colletcor.collect.discovery.constant; +package org.apache.hertzbeat.collector.collect.discovery.constant; /** * Discovery client instance status. diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientInstance.java b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/constant/DiscoveryClientInstance.java similarity index 96% rename from collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientInstance.java rename to collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/constant/DiscoveryClientInstance.java index 4ca187146ed..c548f74fd78 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/constant/DiscoveryClientInstance.java +++ b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/constant/DiscoveryClientInstance.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.hertzbeat.colletcor.collect.discovery.constant; +package org.apache.hertzbeat.collector.collect.discovery.constant; import java.util.Arrays; import org.apache.commons.lang3.StringUtils; diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ConnectConfig.java b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/entity/ConnectConfig.java similarity index 94% rename from collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ConnectConfig.java rename to collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/entity/ConnectConfig.java index 471bc1bf794..f8620ee11e5 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ConnectConfig.java +++ b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/entity/ConnectConfig.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.hertzbeat.colletcor.collect.discovery.entity; +package org.apache.hertzbeat.collector.collect.discovery.entity; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServerInfo.java b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/entity/ServerInfo.java similarity index 94% rename from collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServerInfo.java rename to collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/entity/ServerInfo.java index c1e6293cd67..e4643b16800 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServerInfo.java +++ b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/entity/ServerInfo.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.hertzbeat.colletcor.collect.discovery.entity; +package org.apache.hertzbeat.collector.collect.discovery.entity; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServiceInstance.java b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/entity/ServiceInstance.java similarity index 95% rename from collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServiceInstance.java rename to collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/entity/ServiceInstance.java index 5ca6825546a..b50ffbbc29f 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/entity/ServiceInstance.java +++ b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/entity/ServiceInstance.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.hertzbeat.colletcor.collect.discovery.entity; +package org.apache.hertzbeat.collector.collect.discovery.entity; import java.util.Map; diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/ConsulDiscoveryClient.java b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/impl/ConsulDiscoveryClient.java similarity index 92% rename from collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/ConsulDiscoveryClient.java rename to collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/impl/ConsulDiscoveryClient.java index 68de96f4808..c7d50eeb737 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/ConsulDiscoveryClient.java +++ b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/impl/ConsulDiscoveryClient.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.hertzbeat.colletcor.collect.discovery.impl; +package org.apache.hertzbeat.collector.collect.discovery.impl; import java.util.Collection; import java.util.List; @@ -28,10 +28,10 @@ import com.ecwid.consul.v1.agent.model.Self; import com.ecwid.consul.v1.agent.model.Service; import com.google.common.collect.Lists; -import org.apache.hertzbeat.colletcor.collect.discovery.DiscoveryClient; -import org.apache.hertzbeat.colletcor.collect.discovery.entity.ConnectConfig; -import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServerInfo; -import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServiceInstance; +import org.apache.hertzbeat.collector.collect.discovery.DiscoveryClient; +import org.apache.hertzbeat.collector.collect.discovery.entity.ConnectConfig; +import org.apache.hertzbeat.collector.collect.discovery.entity.ServerInfo; +import org.apache.hertzbeat.collector.collect.discovery.entity.ServiceInstance; import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.common.entity.job.protocol.DiscoveryProtocol; diff --git a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/NacosDiscoveryClient.java b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/impl/NacosDiscoveryClient.java similarity index 92% rename from collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/NacosDiscoveryClient.java rename to collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/impl/NacosDiscoveryClient.java index 03c705c98ee..43cb512f9fa 100644 --- a/collector/colletcor-discovery/src/main/java/org/apache/hertzbeat/colletcor/collect/discovery/impl/NacosDiscoveryClient.java +++ b/collector/collector-discovery/src/main/java/org/apache/hertzbeat/collector/collect/discovery/impl/NacosDiscoveryClient.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.hertzbeat.colletcor.collect.discovery.impl; +package org.apache.hertzbeat.collector.collect.discovery.impl; import java.util.Collections; import java.util.List; @@ -28,11 +28,11 @@ import com.alibaba.nacos.api.naming.NamingService; import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; -import org.apache.hertzbeat.colletcor.collect.discovery.DiscoveryClient; -import org.apache.hertzbeat.colletcor.collect.discovery.constant.DiscoveryClientHealthStatus; -import org.apache.hertzbeat.colletcor.collect.discovery.entity.ConnectConfig; -import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServerInfo; -import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServiceInstance; +import org.apache.hertzbeat.collector.collect.discovery.DiscoveryClient; +import org.apache.hertzbeat.collector.collect.discovery.constant.DiscoveryClientHealthStatus; +import org.apache.hertzbeat.collector.collect.discovery.entity.ConnectConfig; +import org.apache.hertzbeat.collector.collect.discovery.entity.ServerInfo; +import org.apache.hertzbeat.collector.collect.discovery.entity.ServiceInstance; import org.apache.hertzbeat.common.entity.job.protocol.DiscoveryProtocol; /** diff --git a/collector/colletcor-discovery/src/test/java/org/apache/hertzbeat/collector/collect/discovery/test/DiscoveryImplTest.java b/collector/collector-discovery/src/test/java/org/apache/hertzbeat/collector/collect/discovery/test/DiscoveryImplTest.java similarity index 93% rename from collector/colletcor-discovery/src/test/java/org/apache/hertzbeat/collector/collect/discovery/test/DiscoveryImplTest.java rename to collector/collector-discovery/src/test/java/org/apache/hertzbeat/collector/collect/discovery/test/DiscoveryImplTest.java index f035c8a0a59..bd79874c146 100644 --- a/collector/colletcor-discovery/src/test/java/org/apache/hertzbeat/collector/collect/discovery/test/DiscoveryImplTest.java +++ b/collector/collector-discovery/src/test/java/org/apache/hertzbeat/collector/collect/discovery/test/DiscoveryImplTest.java @@ -19,11 +19,11 @@ import java.util.ArrayList; import java.util.List; -import org.apache.hertzbeat.colletcor.collect.DiscoveryImpl; -import org.apache.hertzbeat.colletcor.collect.discovery.DiscoveryClient; -import org.apache.hertzbeat.colletcor.collect.discovery.DiscoveryClientManagement; -import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServerInfo; -import org.apache.hertzbeat.colletcor.collect.discovery.entity.ServiceInstance; +import org.apache.hertzbeat.collector.collect.discovery.DiscoveryImpl; +import org.apache.hertzbeat.collector.collect.discovery.DiscoveryClient; +import org.apache.hertzbeat.collector.collect.discovery.DiscoveryClientManagement; +import org.apache.hertzbeat.collector.collect.discovery.entity.ServerInfo; +import org.apache.hertzbeat.collector.collect.discovery.entity.ServiceInstance; import org.apache.hertzbeat.common.entity.job.Metrics; import org.apache.hertzbeat.common.entity.job.protocol.DiscoveryProtocol; import org.apache.hertzbeat.common.entity.message.CollectRep; diff --git a/collector/collector/pom.xml b/collector/collector/pom.xml index e4e2801b1f8..d2b7b8ba824 100644 --- a/collector/collector/pom.xml +++ b/collector/collector/pom.xml @@ -63,6 +63,12 @@ ${hertzbeat.version} + + org.apache.hertzbeat + hertzbeat-collector-discovery + ${hertzbeat.version} + + org.springframework.boot diff --git a/collector/collector/src/main/resources/META-INF/services/org.apache.hertzbeat.collector.collect.AbstractCollect b/collector/collector/src/main/resources/META-INF/services/org.apache.hertzbeat.collector.collect.AbstractCollect index 69b4076fe4f..badb4c377c8 100644 --- a/collector/collector/src/main/resources/META-INF/services/org.apache.hertzbeat.collector.collect.AbstractCollect +++ b/collector/collector/src/main/resources/META-INF/services/org.apache.hertzbeat.collector.collect.AbstractCollect @@ -20,7 +20,7 @@ org.apache.hertzbeat.collector.collect.nginx.NginxCollectImpl org.apache.hertzbeat.collector.collect.memcached.MemcachedCollectImpl org.apache.hertzbeat.collector.collect.nebulagraph.NebulaGraphCollectImpl org.apache.hertzbeat.collector.collect.pop3.Pop3CollectImpl -org.apache.hertzbeat.collector.collect.httpsd.HttpsdImpl +org.apache.hertzbeat.collector.collect.discovery.DiscoveryImpl org.apache.hertzbeat.collector.collect.redfish.RedfishCollectImpl org.apache.hertzbeat.collector.collect.nebulagraph.NgqlCollectImpl org.apache.hertzbeat.collector.collect.imap.ImapCollectImpl diff --git a/collector/pom.xml b/collector/pom.xml index c222415d03d..886e2c3167d 100644 --- a/collector/pom.xml +++ b/collector/pom.xml @@ -40,7 +40,7 @@ collector-mongodb collector-nebulagraph collector-rocketmq - colletcor-discovery + collector-discovery @@ -70,6 +70,11 @@ hertzbeat-collector-rocketmq ${hertzbeat.version} + + org.apache.hertzbeat + hertzbeat-collector-discovery + ${hertzbeat.version} + diff --git a/home/blog/2024-06-15-hertzbeat-v1.6.0.md b/home/blog/2024-06-15-hertzbeat-v1.6.0.md index 8b13b01f293..dfd61b0bdf0 100644 --- a/home/blog/2024-06-15-hertzbeat-v1.6.0.md +++ b/home/blog/2024-06-15-hertzbeat-v1.6.0.md @@ -190,7 +190,7 @@ Upgrade Guide: * [improve] Optimize websocket monitor by @LiuTianyou in * [refactor] Split the WarehouseProperties class by @xuziyang in -* [test] Add test for HttpsdImpl by @crossoverJie in +* [test] Add test for Service Discovery by @crossoverJie in * [fix] Fix the wrong comment by @xuziyang in * [refactor] trans and use assert by @dukbong in * [bugfix] modify the command in the mongodb monitoring template by @LiuTianyou in diff --git a/home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-06-15-hertzbeat-v1.6.0.md b/home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-06-15-hertzbeat-v1.6.0.md index 974381300de..c451a2fef44 100644 --- a/home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-06-15-hertzbeat-v1.6.0.md +++ b/home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-06-15-hertzbeat-v1.6.0.md @@ -190,7 +190,7 @@ keywords: [open source, monitoring, alerting] - [feature] Add Apache Hbase RegionServer monitoring by @zhangshenghang in - [improve] Optimize websocket monitor by @LiuTianyou in - [refactor] Split the WarehouseProperties class by @xuziyang in -- [test] Add test for HttpsdImpl by @crossoverJie in +- [test] Add test for Service Discovery by @crossoverJie in - [fix] Fix the wrong comment by @xuziyang in - [refactor] trans and use assert by @dukbong in - [bugfix] modify the command in the mongodb monitoring template by @LiuTianyou in diff --git a/manager/src/main/resources/define/app-http_sd.yml b/manager/src/main/resources/define/app-http_sd.yml index e3803b5c1b8..2c0b820dea9 100644 --- a/manager/src/main/resources/define/app-http_sd.yml +++ b/manager/src/main/resources/define/app-http_sd.yml @@ -16,16 +16,16 @@ # The monitoring type category:service-application service monitoring db-database monitoring mid-middleware custom-custom monitoring os-operating system monitoring category: service # The monitoring type eg: linux windows tomcat mysql aws... -app: httpsd +app: service-discovery # The monitoring i18n name name: - zh-CN: HTTP SD监控 - en-US: HTTP SD MONITORS + zh-CN: Service Discovery 监控 + en-US: Service Discovery MONITORS # The description and help of this monitoring type help: - zh-CN: HertzBeat 对 HTTP SD 的相关指标进行监测。 - en-US: HertzBeat monitors related indicators of HTTP SD. - zh-TW: HertzBeat對HTTP SD相關名額進行監測。 + zh-CN: HertzBeat 对服务发现的相关指标进行监测。 + en-US: HertzBeat monitors related indicators of service discovery. + zh-TW: HertzBeat對服務發現相關名額進行監測。 # Input params define for monitoring(render web ui by the definition) params: # field-param field key @@ -89,8 +89,8 @@ metrics: i18n: zh-CN: 响应时间 en-US: Response Time - protocol: httpsd - httpsd: + protocol: discovery + discovery: host: ^_^host^_^ port: ^_^port^_^ discoveryClientTypeName: ^_^discoveryClientTypeName^_^ @@ -127,8 +127,8 @@ metrics: i18n: zh-CN: 服务健康状态 en-US: Health Status - protocol: httpsd - httpsd: + protocol: discovery + discovery: host: ^_^host^_^ port: ^_^port^_^ discoveryClientTypeName: ^_^discoveryClientTypeName^_^ From d69de1083816aa5ce4fc17667750886e891dfcf1 Mon Sep 17 00:00:00 2001 From: yuluo-yx Date: Sun, 15 Sep 2024 16:02:31 +0800 Subject: [PATCH 4/4] fix: add license header Signed-off-by: yuluo-yx --- collector/collector-discovery/pom.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/collector/collector-discovery/pom.xml b/collector/collector-discovery/pom.xml index 1b21ba767c6..337425773a9 100644 --- a/collector/collector-discovery/pom.xml +++ b/collector/collector-discovery/pom.xml @@ -1,4 +1,20 @@ +