This is an automated email from the ASF dual-hosted git repository.
xiatian pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/eventmesh-dashboard.git
The following commit(s) were added to refs/heads/dev by this push:
new c21462c [ISSUE #49] RocketMQ and Nacos health check (#53)
c21462c is described below
commit c21462cce1af948a50805df3be8ad29b7d8ceefb
Author: Lambert Rao <[email protected]>
AuthorDate: Sat Mar 9 15:57:23 2024 +0800
[ISSUE #49] RocketMQ and Nacos health check (#53)
* style: `sql` `entities` `mapper` improvement
* refactor: move health module into function module.
more files will be added in function module
* feat: add rocketmq check and nacos check
* fix: ci utf8
* fix: pom
* feat: add StoreType Enum
---
eventmesh-dashboard-console/pom.xml | 63 +++++--
.../console/config/HealthCheckConfig.java | 2 +-
.../constant/health/HealthCheckTypeConstant.java | 39 +++++
.../console/constant/health/HealthConstant.java | 61 +++++++
.../dashboard/console/entity/base/BaseEntity.java | 10 +-
.../entity/connection/ConnectionEntity.java | 6 -
.../console/entity/connector/ConnectorEntity.java | 3 -
.../entity/health/HealthCheckResultEntity.java | 2 -
.../dashboard/console/entity/meta/MetaEntity.java | 7 +-
.../HealthConstant.java => enums/StoreType.java} | 12 +-
.../console/enums/health/HealthCheckType.java | 16 +-
.../{ => function}/health/CheckResultCache.java | 6 +-
.../{ => function}/health/HealthExecutor.java | 8 +-
.../{ => function}/health/HealthService.java | 15 +-
.../health/annotation/HealthCheckType.java | 2 +-
.../health/callback/HealthCheckCallback.java | 4 +-
.../health/check/AbstractHealthCheckService.java | 4 +-
.../health/check/HealthCheckService.java | 8 +-
.../check/config/HealthCheckObjectConfig.java | 19 ++-
.../health/check/impl/StorageRocketmqCheck.java | 2 +-
.../health/check/impl/meta/NacosConfigCheck.java | 102 +++++++++++
.../health/check/impl/meta/NacosRegisterCheck.java | 87 ++++++++++
.../health/check/impl/storage/RedisCheck.java} | 28 ++-
.../storage/rocketmq4/Rocketmq4BrokerCheck.java | 98 +++++++++++
.../rocketmq4/Rocketmq4NameServerCheck.java | 85 ++++++++++
.../storage/rocketmq4/Rocketmq4TopicCheck.java | 188 +++++++++++++++++++++
.../dashboard/console/mapper/meta/MetaMapper.java | 4 +-
.../console/spring/support/FunctionManager.java | 4 +-
.../spring/support/FunctionManagerLoader.java | 2 +-
.../src/main/resources/application-dev.yml | 7 +-
.../src/main/resources/eventmesh-dashboard.sql | 68 ++++----
.../src/main/resources/logback-dev.xml | 50 ++++++
.../{ => function}/health/HealthExecutorTest.java | 14 +-
.../{ => function}/health/HealthServiceTest.java | 17 +-
.../check/impl/meta/NacosConfigCheckTest.java} | 42 +++--
.../check/impl/meta/NacosRegisterCheckTest.java} | 42 +++--
.../health/check/impl/storage/RedisCheckTest.java} | 33 ++--
.../rocketmq4/RocketmqBrokerCheckTest.java} | 37 ++--
.../rocketmq4/RocketmqNameserverCheckTest.java} | 37 ++--
.../storage/rocketmq4/RocketmqTopicCheckTest.java | 75 ++++++++
.../health/HealthServiceIntegrateTest.java | 12 +-
.../dashboard/console/linkage/log/TestOprLog.java | 17 ++
.../mapper/connection/ConnectionMapperTest.java | 6 +-
.../mapper/connector/ConnectorMapperTest.java | 8 +-
.../mapper/health/HealthCheckResultMapperTest.java | 24 +--
.../console/mapper/meta/MetaMapperTest.java | 4 +-
.../{TestGroupMapper.java => GroupMapperTest.java} | 19 ++-
...emberMapper.java => GroupMemberMapperTest.java} | 19 ++-
.../{testTopicMapper.java => TopicMapperTest.java} | 19 ++-
.../src/test/resources/logback-test.xml | 50 ++++++
pom.xml | 26 +--
51 files changed, 1270 insertions(+), 243 deletions(-)
diff --git a/eventmesh-dashboard-console/pom.xml
b/eventmesh-dashboard-console/pom.xml
index b071854..1fe1905 100644
--- a/eventmesh-dashboard-console/pom.xml
+++ b/eventmesh-dashboard-console/pom.xml
@@ -65,28 +65,46 @@
<scope>runtime</scope>
</dependency>
- <!-- health check client -->
- <!-- EventMesh SDK -->
+ <!-- Meta - nacos client -->
<dependency>
- <groupId>org.apache.eventmesh</groupId>
- <artifactId>eventmesh-sdk-java</artifactId>
- <version>1.10.0-release</version>
- <exclusions>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit-dep</artifactId>
- </exclusion>
- </exclusions>
+ <groupId>com.alibaba.nacos</groupId>
+ <artifactId>nacos-client</artifactId>
+ <version>${nacos.version}</version>
</dependency>
+
+ <!-- health check client -->
+ <!-- EventMesh SDK -->
+<!-- <dependency>-->
+<!-- <groupId>org.apache.eventmesh</groupId>-->
+<!-- <artifactId>eventmesh-sdk-java</artifactId>-->
+<!-- <version>1.10.0-release</version>-->
+<!-- <exclusions>-->
+<!-- <exclusion>-->
+<!-- <groupId>junit</groupId>-->
+<!-- <artifactId>junit</artifactId>-->
+<!-- </exclusion>-->
+<!-- <exclusion>-->
+<!-- <groupId>junit</groupId>-->
+<!-- <artifactId>junit-dep</artifactId>-->
+<!-- </exclusion>-->
+<!-- </exclusions>-->
+<!-- </dependency>-->
<!-- storage redis client -->
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
</dependency>
+ <!-- rocketmq client -->
+ <dependency>
+ <groupId>org.apache.rocketmq</groupId>
+ <artifactId>rocketmq-client</artifactId>
+ <version>4.9.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.rocketmq</groupId>
+ <artifactId>rocketmq-tools</artifactId>
+ <version>5.2.0</version>
+ </dependency>
<!-- health check client end -->
<!-- Unit Test -->
@@ -105,4 +123,19 @@
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>3.2.2</version>
+ <configuration>
+ <excludes>
+
<exclude>**/org/apache/eventmesh/dashboard/console/integration/**/*.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
\ No newline at end of file
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/HealthCheckConfig.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/HealthCheckConfig.java
index 8588311..bbf0571 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/HealthCheckConfig.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/HealthCheckConfig.java
@@ -17,7 +17,7 @@
package org.apache.eventmesh.dashboard.console.config;
-import
org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
import java.util.List;
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/health/HealthCheckTypeConstant.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/health/HealthCheckTypeConstant.java
new file mode 100644
index 0000000..6765bab
--- /dev/null
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/health/HealthCheckTypeConstant.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.eventmesh.dashboard.console.constant.health;
+
+public class HealthCheckTypeConstant {
+
+ public static final String HEALTH_CHECK_TYPE_UNKNOWN = "unknown";
+
+ public static final String HEALTH_CHECK_TYPE_CLUSTER = "cluster";
+
+ public static final String HEALTH_CHECK_TYPE_RUNTIME = "runtime";
+ public static final String HEALTH_CHECK_TYPE_STORAGE = "storage";
+ public static final String HEALTH_CHECK_TYPE_META = "meta";
+ public static final String HEALTH_CHECK_TYPE_TOPIC = "topic";
+
+ public static final String HEALTH_CHECK_SUBTYPE_REDIS = "redis";
+ public static final String HEALTH_CHECK_SUBTYPE_MYSQL = "mysql";
+ public static final String HEALTH_CHECK_SUBTYPE_ROCKETMQ_BROKER =
"rocketmq4-broker";
+ public static final String HEALTH_CHECK_SUBTYPE_ROCKETMQ_NAMESERVER =
"rocketmq4-nameserver";
+ public static final String HEALTH_CHECK_SUBTYPE_ROCKETMQ_TOPIC =
"rocketmq4-topic";
+
+ public static final String HEALTH_CHECK_SUBTYPE_NACOS_CONFIG =
"nacos-config";
+ public static final String HEALTH_CHECK_SUBTYPE_NACOS_REGISTER =
"nacos-register";
+}
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/health/HealthConstant.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/health/HealthConstant.java
new file mode 100644
index 0000000..e243b30
--- /dev/null
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/health/HealthConstant.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.eventmesh.dashboard.console.constant.health;
+
+public class HealthConstant {
+ public static final String NEW_LINE_ENDING = "\n";
+
+ public static final String RUNTIME_CHECK_TOPIC =
"eventmesh-dashboard-healthcheck-topic";
+
+ public static final String RUNTIME_CHECK_CONTENT_KEY =
"eventmesh-dashboard-healthcheck-content";
+
+ public static final String RUNTIME_CHECK_CONTENT_BODY =
"eventmesh-dashboard-healthcheck-content-body";
+
+ public static final String CLOUDEVENT_CONTENT_TYPE =
"application/cloudevents+json";
+
+
+ public static final String ENV = "test";
+ public static final String HOST = "localhost";
+ public static final String PASSWORD = "PASSWORD";
+ public static final String USER_NAME = "PU4283";
+ public static final String GROUP = "EventmeshTestGroup";
+ public static final String PATH = "/data/app/umg_proxy";
+ public static final Integer PORT = 8362;
+ public static final String VERSION = "2.0.11";
+ public static final String IDC = "FT";
+ public static final String SUBSYSTEM = "5023";
+
+ public static final String ROCKETMQ_CHECK_PRODUCER_GROUP =
"eventmesh-dashboard-healthcheck-rocketmq-producer-group";
+
+ public static final String ROCKETMQ_CHECK_CONSUMER_GROUP =
"eventmesh-dashboard-healthcheck-rocketmq-consumer-group";
+
+ public static final String ROCKETMQ_CHECK_TOPIC = "DO-NOT-USE-THIS-TOPIC-"
+ +
"eventmesh-dashboard-healthcheck-rocketmq-topic-90a78a5d-b803-447e-8c48-1c87ab0c74d9";
+ public static final String ROCKETMQ_CHECK_TOPIC_MSG =
"eventmesh-dashboard-healthcheck-rocketmq-message";
+
+ public static final String NACOS_CHECK_DATA_ID = "DO-NOT-USE-THIS-"
+ +
"eventmesh-dashboard-healthcheck-nacos-data-id-28e2933f-a47b-439d-b14b-7d9970c37042";
+
+ public static final String NACOS_CHECK_GROUP =
"EVENTMESH_DASHBOARD_HEALTH_CHECK_GROUP";
+
+ public static final String NACOS_CHECK_CONTENT = "eventmesh-dashboard";
+
+ public static final String NACOS_CHECK_SERVICE_NAME =
"eventmesh-dashboard-healthcheck-nacos-service-name";
+
+ public static final String NACOS_CHECK_SERVICE_CLUSTER_NAME =
"eventmesh-dashboard-healthcheck-nacos-service-cluster-name";
+}
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseEntity.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseEntity.java
index 14192fa..5d0984d 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseEntity.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseEntity.java
@@ -24,13 +24,21 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
+/**
+ * Base Entity provide some basic fields that every Eventmesh Dashboard Entity
would have
+ */
@Data
@Schema(name = "BaseEntity", description = "Base entity")
public class BaseEntity implements Serializable {
private static final long serialVersionUID = -2697805837923579585L;
+ /**
+ * Primary key
+ */
+ @Schema(name = "id", description = "primary key")
+ protected Long id;
- private Long clusterId;
+ protected Long clusterId;
protected Timestamp createTime;
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionEntity.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionEntity.java
index 0a451cf..626e793 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionEntity.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionEntity.java
@@ -40,12 +40,6 @@ public class ConnectionEntity extends BaseEntity {
private static final long serialVersionUID = 6565578252656944905L;
- /**
- * Primary key
- */
- @Schema(name = "id", description = "primary key")
- private Long id;
-
/**
* Runtime cluster id
*/
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connector/ConnectorEntity.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connector/ConnectorEntity.java
index 1681ac2..66db0f9 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connector/ConnectorEntity.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connector/ConnectorEntity.java
@@ -34,9 +34,6 @@ public class ConnectorEntity extends BaseEntity {
private static final long serialVersionUID = -8226303660232951326L;
- @Schema(name = "id", description = "primary key")
- private Long id;
-
private Long clusterId;
private String name;
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/health/HealthCheckResultEntity.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/health/HealthCheckResultEntity.java
index e8578eb..f427b66 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/health/HealthCheckResultEntity.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/health/HealthCheckResultEntity.java
@@ -32,8 +32,6 @@ import lombok.NoArgsConstructor;
public class HealthCheckResultEntity extends BaseEntity {
private static final long serialVersionUID = -7350585209577598040L;
- @Schema(name = "id", description = "primary key")
- private Long id;
private Long clusterId;
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/meta/MetaEntity.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/meta/MetaEntity.java
index 2c32e28..a6871eb 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/meta/MetaEntity.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/meta/MetaEntity.java
@@ -33,12 +33,6 @@ public class MetaEntity extends BaseEntity {
private static final long serialVersionUID = 7176263169716424469L;
- /**
- * Primary key
- */
- @Schema(name = "id", description = "Primary key")
- private Long id;
-
private String name;
private String type;
@@ -59,6 +53,7 @@ public class MetaEntity extends BaseEntity {
/**
* 0: not active, 1: active
+ *
* @see StatusEnum
*/
@Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"},
description = "0:inactive, 1:active")
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/HealthConstant.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/StoreType.java
similarity index 83%
rename from
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/HealthConstant.java
rename to
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/StoreType.java
index 979f578..b4721cc 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/HealthConstant.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/StoreType.java
@@ -15,8 +15,14 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.constant;
+package org.apache.eventmesh.dashboard.console.enums;
+
+public enum StoreType {
+ ROCKETMQ,
+ KAFKA,
+ STANDALONE,
+ PULSAR,
+ RABBITMQ,
+ REDIS,
-public class HealthConstant {
- public static final String NEW_LINE_ENDING = "\n";
}
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckType.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckType.java
index 3ee990b..abd918f 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckType.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckType.java
@@ -17,20 +17,26 @@
package org.apache.eventmesh.dashboard.console.enums.health;
+import static
org.apache.eventmesh.dashboard.console.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_TYPE_CLUSTER;
+import static
org.apache.eventmesh.dashboard.console.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_TYPE_RUNTIME;
+import static
org.apache.eventmesh.dashboard.console.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_TYPE_STORAGE;
+import static
org.apache.eventmesh.dashboard.console.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_TYPE_TOPIC;
+import static
org.apache.eventmesh.dashboard.console.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_TYPE_UNKNOWN;
+
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
public enum HealthCheckType {
- UNKNOWN(0, "unknown"),
+ UNKNOWN(0, HEALTH_CHECK_TYPE_UNKNOWN),
- CLUSTER(1, "cluster"),
+ CLUSTER(1, HEALTH_CHECK_TYPE_CLUSTER),
- RUNTIME(2, "runtime"),
+ RUNTIME(2, HEALTH_CHECK_TYPE_RUNTIME),
- TOPIC(3, "topic"),
+ TOPIC(3, HEALTH_CHECK_TYPE_TOPIC),
- STORAGE(4, "storage");
+ STORAGE(4, HEALTH_CHECK_TYPE_STORAGE);
@Getter
private final Integer number;
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/CheckResultCache.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/CheckResultCache.java
similarity index 93%
rename from
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/CheckResultCache.java
rename to
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/CheckResultCache.java
index 66dcd44..4da837f 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/CheckResultCache.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/CheckResultCache.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.health;
+package org.apache.eventmesh.dashboard.console.function.health;
-import org.apache.eventmesh.dashboard.console.constant.HealthConstant;
+import org.apache.eventmesh.dashboard.console.constant.health.HealthConstant;
import org.apache.eventmesh.dashboard.console.enums.health.HealthCheckStatus;
-import
org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
import java.time.LocalDateTime;
import java.util.Collections;
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/HealthExecutor.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutor.java
similarity index 94%
rename from
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/HealthExecutor.java
rename to
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutor.java
index 49d76e2..fac6eb7 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/HealthExecutor.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutor.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.health;
+package org.apache.eventmesh.dashboard.console.function.health;
import
org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity;
import org.apache.eventmesh.dashboard.console.enums.health.HealthCheckStatus;
import org.apache.eventmesh.dashboard.console.enums.health.HealthCheckType;
-import
org.apache.eventmesh.dashboard.console.health.CheckResultCache.CheckResult;
-import
org.apache.eventmesh.dashboard.console.health.callback.HealthCheckCallback;
-import
org.apache.eventmesh.dashboard.console.health.check.AbstractHealthCheckService;
+import
org.apache.eventmesh.dashboard.console.function.health.CheckResultCache.CheckResult;
+import
org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback;
+import
org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService;
import org.apache.eventmesh.dashboard.console.service.health.HealthDataService;
import java.util.ArrayList;
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/HealthService.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthService.java
similarity index 92%
rename from
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/HealthService.java
rename to
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthService.java
index 333fa99..b07fd64 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/HealthService.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthService.java
@@ -15,13 +15,13 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.health;
+package org.apache.eventmesh.dashboard.console.function.health;
-import
org.apache.eventmesh.dashboard.console.health.CheckResultCache.CheckResult;
-import
org.apache.eventmesh.dashboard.console.health.annotation.HealthCheckType;
-import
org.apache.eventmesh.dashboard.console.health.check.AbstractHealthCheckService;
-import
org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig;
-import
org.apache.eventmesh.dashboard.console.health.check.impl.StorageRedisCheck;
+import
org.apache.eventmesh.dashboard.console.function.health.CheckResultCache.CheckResult;
+import
org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType;
+import
org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
+import
org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.RedisCheck;
import org.apache.eventmesh.dashboard.console.service.health.HealthDataService;
import java.lang.reflect.Constructor;
@@ -55,7 +55,7 @@ public class HealthService {
private static final Map<String, Class<?>> HEALTH_CHECK_CLASS_CACHE = new
HashMap<>();
static {
- setClassCache(StorageRedisCheck.class);
+ setClassCache(RedisCheck.class);
}
private static void setClassCache(Class<?> clazz) {
@@ -127,6 +127,7 @@ public class HealthService {
if (Objects.isNull(subMap)) {
return;
}
+ subMap.get(resourceId).destroy();
subMap.remove(resourceId);
if (subMap.isEmpty()) {
checkServiceMap.remove(resourceType);
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/annotation/HealthCheckType.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/annotation/HealthCheckType.java
similarity index 95%
rename from
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/annotation/HealthCheckType.java
rename to
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/annotation/HealthCheckType.java
index 6f39658..7a23b90 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/annotation/HealthCheckType.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/annotation/HealthCheckType.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.health.annotation;
+package org.apache.eventmesh.dashboard.console.function.health.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/callback/HealthCheckCallback.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/callback/HealthCheckCallback.java
similarity index 87%
rename from
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/callback/HealthCheckCallback.java
rename to
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/callback/HealthCheckCallback.java
index 7f7b360..541d30c 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/callback/HealthCheckCallback.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/callback/HealthCheckCallback.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.health.callback;
+package org.apache.eventmesh.dashboard.console.function.health.callback;
-import org.apache.eventmesh.dashboard.console.health.HealthExecutor;
+import org.apache.eventmesh.dashboard.console.function.health.HealthExecutor;
/**
* Callback used by HealthService.doCheck to notify the caller of the result
of the health check.<br>
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/AbstractHealthCheckService.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/AbstractHealthCheckService.java
similarity index 87%
rename from
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/AbstractHealthCheckService.java
rename to
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/AbstractHealthCheckService.java
index 6fa7045..3a3ab99 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/AbstractHealthCheckService.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/AbstractHealthCheckService.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.health.check;
+package org.apache.eventmesh.dashboard.console.function.health.check;
-import
org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
import lombok.Getter;
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/HealthCheckService.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/HealthCheckService.java
similarity index 83%
rename from
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/HealthCheckService.java
rename to
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/HealthCheckService.java
index 8f37363..1461d38 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/HealthCheckService.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/HealthCheckService.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.health.check;
+package org.apache.eventmesh.dashboard.console.function.health.check;
-import org.apache.eventmesh.dashboard.console.health.HealthExecutor;
-import
org.apache.eventmesh.dashboard.console.health.callback.HealthCheckCallback;
+import org.apache.eventmesh.dashboard.console.function.health.HealthExecutor;
+import
org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback;
/**
* Health check service interface.<br>
@@ -36,4 +36,6 @@ public interface HealthCheckService {
public void init();
+ public void destroy();
+
}
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/config/HealthCheckObjectConfig.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/config/HealthCheckObjectConfig.java
similarity index 75%
rename from
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/config/HealthCheckObjectConfig.java
rename to
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/config/HealthCheckObjectConfig.java
index 8c350b4..79e8c82 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/config/HealthCheckObjectConfig.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/config/HealthCheckObjectConfig.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.health.check.config;
+package org.apache.eventmesh.dashboard.console.function.health.check.config;
import java.util.Properties;
@@ -38,8 +38,11 @@ public class HealthCheckObjectConfig {
private Long clusterId;
+ //Prioritize passing in this field for a url.
+ //redis, nacos
private String connectUrl;
- //mysql, redis
+
+ //redis
private String host;
private Integer port;
@@ -51,5 +54,15 @@ public class HealthCheckObjectConfig {
//mysql, redis
private String database;
- private Long requestTimeoutMillis = Long.MAX_VALUE;
+ private Long requestTimeoutMillis = 100000L;
+
+ private RocketmqConfig rocketmqConfig = new RocketmqConfig();
+
+ @Data
+ public class RocketmqConfig {
+
+ private String nameServerUrl;
+ private String brokerUrl;
+ private String endPoint;
+ }
}
\ No newline at end of file
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRocketmqCheck.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/StorageRocketmqCheck.java
similarity index 91%
rename from
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRocketmqCheck.java
rename to
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/StorageRocketmqCheck.java
index b6f56b8..c200f07 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRocketmqCheck.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/StorageRocketmqCheck.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.health.check.impl;
+package org.apache.eventmesh.dashboard.console.function.health.check.impl;
public class StorageRocketmqCheck {
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheck.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheck.java
new file mode 100644
index 0000000..db82e1f
--- /dev/null
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheck.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.eventmesh.dashboard.console.function.health.check.impl.meta;
+
+import static
org.apache.eventmesh.dashboard.console.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_SUBTYPE_NACOS_CONFIG;
+import static
org.apache.eventmesh.dashboard.console.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_TYPE_META;
+import static
org.apache.eventmesh.dashboard.console.constant.health.HealthConstant.NACOS_CHECK_CONTENT;
+import static
org.apache.eventmesh.dashboard.console.constant.health.HealthConstant.NACOS_CHECK_DATA_ID;
+import static
org.apache.eventmesh.dashboard.console.constant.health.HealthConstant.NACOS_CHECK_GROUP;
+
+import
org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType;
+import
org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback;
+import
org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
+
+import java.util.Properties;
+import java.util.concurrent.CompletableFuture;
+
+import com.alibaba.nacos.api.NacosFactory;
+import com.alibaba.nacos.api.config.ConfigService;
+import com.alibaba.nacos.api.exception.NacosException;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@HealthCheckType(type = HEALTH_CHECK_TYPE_META, subType =
HEALTH_CHECK_SUBTYPE_NACOS_CONFIG)
+public class NacosConfigCheck extends AbstractHealthCheckService {
+
+ private ConfigService configService;
+
+ public NacosConfigCheck(HealthCheckObjectConfig healthCheckObjectConfig) {
+ super(healthCheckObjectConfig);
+ }
+
+ @Override
+ public void doCheck(HealthCheckCallback callback) {
+ CompletableFuture.runAsync(() -> {
+ try {
+ String content = configService.getConfig(NACOS_CHECK_DATA_ID,
NACOS_CHECK_GROUP, getConfig().getRequestTimeoutMillis());
+ if (NACOS_CHECK_CONTENT.equals(content)) {
+ callback.onSuccess();
+ } else {
+ callback.onFail(new RuntimeException("NacosCheck failed.
Content is wrong."));
+ }
+ } catch (NacosException e) {
+ callback.onFail(e);
+ }
+ });
+ }
+
+ @Override
+ public void init() {
+ //create a config
+ try {
+ Properties properties = new Properties();
+ properties.put("serverAddr", getConfig().getConnectUrl());
+ ConfigService configService =
NacosFactory.createConfigService(properties);
+ boolean isPublishOk =
configService.publishConfig(NACOS_CHECK_DATA_ID, NACOS_CHECK_GROUP,
+ NACOS_CHECK_CONTENT);
+ if (!isPublishOk) {
+ log.error("NacosCheck init failed caused by crate config
failed");
+ }
+ } catch (NacosException e) {
+ log.error("NacosCheck init failed caused by {}", e.getErrMsg());
+ }
+
+ try {
+ Properties properties = new Properties();
+ properties.put("serverAddr", getConfig().getConnectUrl());
+ configService = NacosFactory.createConfigService(properties);
+ } catch (NacosException e) {
+ log.error("NacosCheck init failed caused by {}", e.getErrMsg());
+ }
+ }
+
+ @Override
+ public void destroy() {
+ if (configService != null) {
+ try {
+ configService.removeConfig(NACOS_CHECK_DATA_ID,
NACOS_CHECK_GROUP);
+ } catch (NacosException e) {
+ log.error("NacosCheck destroy failed caused by {}",
e.getErrMsg());
+ }
+
+ }
+ }
+}
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosRegisterCheck.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosRegisterCheck.java
new file mode 100644
index 0000000..90ec2ea
--- /dev/null
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosRegisterCheck.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.eventmesh.dashboard.console.function.health.check.impl.meta;
+
+import static
org.apache.eventmesh.dashboard.console.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_SUBTYPE_NACOS_REGISTER;
+import static
org.apache.eventmesh.dashboard.console.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_TYPE_META;
+import static
org.apache.eventmesh.dashboard.console.constant.health.HealthConstant.NACOS_CHECK_SERVICE_CLUSTER_NAME;
+import static
org.apache.eventmesh.dashboard.console.constant.health.HealthConstant.NACOS_CHECK_SERVICE_NAME;
+
+import
org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType;
+import
org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback;
+import
org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
+
+import java.util.Properties;
+import java.util.concurrent.CompletableFuture;
+
+import com.alibaba.nacos.api.exception.NacosException;
+import com.alibaba.nacos.api.naming.NamingFactory;
+import com.alibaba.nacos.api.naming.NamingService;
+import com.alibaba.nacos.api.naming.pojo.Instance;
+
+import lombok.extern.slf4j.Slf4j;
+
+
+@Slf4j
+@HealthCheckType(type = HEALTH_CHECK_TYPE_META, subType =
HEALTH_CHECK_SUBTYPE_NACOS_REGISTER)
+public class NacosRegisterCheck extends AbstractHealthCheckService {
+
+ private NamingService namingService;
+
+ public NacosRegisterCheck(HealthCheckObjectConfig healthCheckObjectConfig)
{
+ super(healthCheckObjectConfig);
+ }
+
+ @Override
+ public void doCheck(HealthCheckCallback callback) {
+ CompletableFuture.runAsync(() -> {
+ try {
+ Instance result =
namingService.selectOneHealthyInstance(NACOS_CHECK_SERVICE_NAME);
+ if (result.isHealthy()) {
+ callback.onSuccess();
+ } else {
+ callback.onFail(new RuntimeException("NacosCheck failed.
Service is not healthy."));
+ }
+ } catch (NacosException e) {
+ callback.onFail(e);
+ }
+ });
+ }
+
+ @Override
+ public void init() {
+ try {
+ Properties properties = new Properties();
+ properties.put("serverAddr", getConfig().getConnectUrl());
+ namingService = NamingFactory.createNamingService(properties);
+ namingService.registerInstance(NACOS_CHECK_SERVICE_NAME,
"11.11.11.11", 8888, NACOS_CHECK_SERVICE_CLUSTER_NAME);
+ } catch (NacosException e) {
+ log.error("NacosRegisterCheck init failed", e);
+ }
+ }
+
+ @Override
+ public void destroy() {
+ try {
+ namingService.deregisterInstance(NACOS_CHECK_SERVICE_NAME,
"11.11.11.11", 8888, NACOS_CHECK_SERVICE_CLUSTER_NAME);
+ } catch (NacosException e) {
+ log.error("NacosRegisterCheck destroy failed", e);
+ }
+ }
+}
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheck.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheck.java
similarity index 73%
rename from
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheck.java
rename to
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheck.java
index 00cfad8..71488ac 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheck.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheck.java
@@ -15,12 +15,14 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.health.check.impl;
+package
org.apache.eventmesh.dashboard.console.function.health.check.impl.storage;
-import
org.apache.eventmesh.dashboard.console.health.annotation.HealthCheckType;
-import
org.apache.eventmesh.dashboard.console.health.callback.HealthCheckCallback;
-import
org.apache.eventmesh.dashboard.console.health.check.AbstractHealthCheckService;
-import
org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig;
+import static
org.apache.eventmesh.dashboard.console.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_TYPE_STORAGE;
+
+import
org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType;
+import
org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback;
+import
org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
import java.time.Duration;
import java.util.Objects;
@@ -30,13 +32,15 @@ import io.lettuce.core.RedisURI;
import io.lettuce.core.RedisURI.Builder;
import io.lettuce.core.api.async.RedisAsyncCommands;
+import lombok.extern.slf4j.Slf4j;
-@HealthCheckType(type = "storage", subType = "redis")
-public class StorageRedisCheck extends AbstractHealthCheckService {
+@Slf4j
+@HealthCheckType(type = HEALTH_CHECK_TYPE_STORAGE, subType = "redis")
+public class RedisCheck extends AbstractHealthCheckService {
private RedisClient redisClient;
- public StorageRedisCheck(HealthCheckObjectConfig healthCheckObjectConfig) {
+ public RedisCheck(HealthCheckObjectConfig healthCheckObjectConfig) {
super(healthCheckObjectConfig);
}
@@ -55,6 +59,7 @@ public class StorageRedisCheck extends
AbstractHealthCheckService {
return null;
});
} catch (Exception e) {
+ log.error(e.toString());
callback.onFail(e);
}
}
@@ -79,4 +84,11 @@ public class StorageRedisCheck extends
AbstractHealthCheckService {
}
redisClient = RedisClient.create(redisUrl);
}
+
+ @Override
+ public void destroy() {
+ if (redisClient != null) {
+ redisClient.shutdown();
+ }
+ }
}
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4BrokerCheck.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4BrokerCheck.java
new file mode 100644
index 0000000..5fb92cf
--- /dev/null
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4BrokerCheck.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.rocketmq4;
+
+
+import static
org.apache.eventmesh.dashboard.console.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_SUBTYPE_ROCKETMQ_BROKER;
+import static
org.apache.eventmesh.dashboard.console.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_TYPE_STORAGE;
+
+import
org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType;
+import
org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback;
+import
org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
+
+import org.apache.rocketmq.common.protocol.RequestCode;
+import org.apache.rocketmq.remoting.InvokeCallback;
+import org.apache.rocketmq.remoting.RemotingClient;
+import org.apache.rocketmq.remoting.netty.NettyClientConfig;
+import org.apache.rocketmq.remoting.netty.NettyRemotingClient;
+import org.apache.rocketmq.remoting.netty.ResponseFuture;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@HealthCheckType(type = HEALTH_CHECK_TYPE_STORAGE, subType =
HEALTH_CHECK_SUBTYPE_ROCKETMQ_BROKER)
+public class Rocketmq4BrokerCheck extends AbstractHealthCheckService {
+
+ private RemotingClient remotingClient;
+
+
+ public Rocketmq4BrokerCheck(HealthCheckObjectConfig
healthCheckObjectConfig) {
+ super(healthCheckObjectConfig);
+ }
+
+ @Override
+ public void doCheck(HealthCheckCallback callback) {
+ try {
+ RemotingCommand request =
RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_RUNTIME_INFO, null);
+
remotingClient.invokeAsync(getConfig().getRocketmqConfig().getBrokerUrl(),
request, getConfig().getRequestTimeoutMillis(),
+ new InvokeCallback() {
+ @Override
+ public void operationComplete(ResponseFuture
responseFuture) {
+ if (responseFuture.isSendRequestOK()) {
+ callback.onSuccess();
+ } else {
+ callback.onFail(new
RuntimeException("RocketmqNameServerCheck failed caused by " +
responseFuture.getCause()));
+ }
+ }
+
+ });
+ } catch (Exception e) {
+ log.error("RocketmqCheck failed.", e);
+ callback.onFail(e);
+ }
+ }
+
+ @Override
+ public void init() {
+ if (getConfig().getRocketmqConfig().getBrokerUrl() == null ||
getConfig().getRocketmqConfig().getBrokerUrl().isEmpty()) {
+ throw new IllegalArgumentException("RocketmqCheck failed.
BrokerUrl is null.");
+ }
+
+ NettyClientConfig config = new NettyClientConfig();
+ config.setUseTLS(false);
+ remotingClient = new NettyRemotingClient(config);
+ remotingClient.start();
+
+ if (getConfig().getConnectUrl() == null ||
getConfig().getConnectUrl().isEmpty()) {
+ if (getConfig().getHost() != null && getConfig().getPort() !=
null) {
+ getConfig().setConnectUrl(getConfig().getHost() + ":" +
getConfig().getPort());
+ }
+ }
+
+ if (getConfig().getConnectUrl() == null) {
+ log.error("RocketmqCheck failed. ConnectUrl is null.");
+ }
+ }
+
+ @Override
+ public void destroy() {
+
+ }
+}
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4NameServerCheck.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4NameServerCheck.java
new file mode 100644
index 0000000..08df28b
--- /dev/null
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4NameServerCheck.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.rocketmq4;
+
+import
org.apache.eventmesh.dashboard.console.constant.health.HealthCheckTypeConstant;
+import
org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType;
+import
org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback;
+import
org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
+
+import org.apache.rocketmq.common.protocol.RequestCode;
+import org.apache.rocketmq.remoting.InvokeCallback;
+import org.apache.rocketmq.remoting.RemotingClient;
+import org.apache.rocketmq.remoting.netty.NettyClientConfig;
+import org.apache.rocketmq.remoting.netty.NettyRemotingClient;
+import org.apache.rocketmq.remoting.netty.ResponseFuture;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@HealthCheckType(type = HealthCheckTypeConstant.HEALTH_CHECK_TYPE_STORAGE,
subType = HealthCheckTypeConstant.HEALTH_CHECK_SUBTYPE_ROCKETMQ_NAMESERVER)
+public class Rocketmq4NameServerCheck extends AbstractHealthCheckService {
+
+ private RemotingClient remotingClient;
+
+ public Rocketmq4NameServerCheck(HealthCheckObjectConfig
healthCheckObjectConfig) {
+ super(healthCheckObjectConfig);
+ }
+
+ @Override
+ public void doCheck(HealthCheckCallback callback) {
+ try {
+ RemotingCommand request =
RemotingCommand.createRequestCommand(RequestCode.GET_NAMESRV_CONFIG, null);
+
remotingClient.invokeAsync(getConfig().getRocketmqConfig().getNameServerUrl(),
request, getConfig().getRequestTimeoutMillis(),
+ new InvokeCallback() {
+ @Override
+ public void operationComplete(ResponseFuture
responseFuture) {
+ if (responseFuture.isSendRequestOK()) {
+ callback.onSuccess();
+ } else {
+ callback.onFail(new
RuntimeException("RocketmqNameServerCheck failed caused by " +
responseFuture.getCause()));
+ }
+ }
+
+ });
+ } catch (Exception e) {
+ log.error("RocketmqCheck failed.", e);
+ callback.onFail(e);
+ }
+ }
+
+ @Override
+ public void init() {
+ if (getConfig().getRocketmqConfig().getNameServerUrl() == null ||
getConfig().getRocketmqConfig().getNameServerUrl().isEmpty()) {
+ throw new RuntimeException("RocketmqNameServerCheck init failed,
nameServerUrl is empty");
+ }
+
+ NettyClientConfig config = new NettyClientConfig();
+ config.setUseTLS(false);
+ remotingClient = new NettyRemotingClient(config);
+ remotingClient.start();
+
+ }
+
+ @Override
+ public void destroy() {
+
+ }
+}
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4TopicCheck.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4TopicCheck.java
new file mode 100644
index 0000000..7554762
--- /dev/null
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4TopicCheck.java
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.rocketmq4;
+
+import static org.apache.rocketmq.client.producer.SendStatus.SEND_OK;
+
+import
org.apache.eventmesh.dashboard.console.constant.health.HealthCheckTypeConstant;
+import org.apache.eventmesh.dashboard.console.constant.health.HealthConstant;
+import
org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType;
+import
org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback;
+import
org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
+
+import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+import
org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
+import org.apache.rocketmq.client.producer.DefaultMQProducer;
+import org.apache.rocketmq.client.producer.SendCallback;
+import org.apache.rocketmq.client.producer.SendResult;
+import org.apache.rocketmq.common.TopicFilterType;
+import org.apache.rocketmq.common.constant.PermName;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.protocol.RequestCode;
+import org.apache.rocketmq.common.protocol.header.CreateTopicRequestHeader;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+import org.apache.rocketmq.remoting.RemotingClient;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.netty.NettyClientConfig;
+import org.apache.rocketmq.remoting.netty.NettyRemotingClient;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@HealthCheckType(type = HealthCheckTypeConstant.HEALTH_CHECK_TYPE_STORAGE,
subType = HealthCheckTypeConstant.HEALTH_CHECK_SUBTYPE_ROCKETMQ_TOPIC)
+public class Rocketmq4TopicCheck extends AbstractHealthCheckService {
+
+ private RemotingClient remotingClient;
+
+ private DefaultMQPushConsumer consumer;
+
+ private DefaultMQProducer producer;
+
+ private Long startTime;
+
+ private BlockingQueue<Message> consumedMessages = new
LinkedBlockingQueue<>();
+
+ public Rocketmq4TopicCheck(HealthCheckObjectConfig
healthCheckObjectConfig) {
+ super(healthCheckObjectConfig);
+ }
+
+ @Override
+ public void doCheck(HealthCheckCallback callback) {
+ startTime = System.currentTimeMillis();
+ String uuid = UUID.randomUUID().toString();
+ log.debug("RocketmqTopicCheck start, uuid:{}", uuid);
+ try {
+ Message msg = new Message(HealthConstant.ROCKETMQ_CHECK_TOPIC,
"eventmesh-dashboard-rocketmq-topic-check", uuid
+ .getBytes(
+ RemotingHelper.DEFAULT_CHARSET));
+ synchronized (this) {
+ producer.send(msg, new SendCallback() {
+ @Override
+ public void onSuccess(SendResult sendResult) {
+ if (!sendResult.getSendStatus().equals(SEND_OK)) {
+ log.error("send message failed, sendResult:{}",
sendResult);
+ callback.onFail(new Exception("send message failed
for reason:" + sendResult.getSendStatus().toString()));
+ return;
+ }
+ consume(callback, uuid);
+ }
+
+ @Override
+ public void onException(Throwable e) {
+ log.error("send message failed", e);
+ callback.onFail((Exception) e);
+ }
+ });
+ }
+
+ } catch (Exception e) {
+ log.error("RocketmqTopicCheck failed when producing message.", e);
+ callback.onFail(e);
+ }
+
+ }
+
+ private synchronized void consume(HealthCheckCallback callback, String
uuid) {
+ try {
+ while (System.currentTimeMillis() - startTime <
getConfig().getRequestTimeoutMillis()) {
+ Message message =
consumedMessages.poll(System.currentTimeMillis() - startTime,
TimeUnit.MILLISECONDS);
+ if (message != null) {
+ log.debug("RocketmqTopicCheck consume message:{}", new
String(message.getBody()));
+ if (Arrays.equals(message.getBody(), uuid.getBytes())) {
+ callback.onSuccess();
+ return;
+ }
+ }
+ }
+ callback.onFail(new TimeoutException("consume message timeout"));
+ } catch (Exception e) {
+ log.error("RocketmqTopicCheck failed when consuming message.", e);
+ callback.onFail(e);
+ }
+ }
+
+ @Override
+ public void init() {
+ NettyClientConfig config = new NettyClientConfig();
+ config.setUseTLS(false);
+ remotingClient = new NettyRemotingClient(config);
+ remotingClient.start();
+
+ //TODO there are many functions that can be reused, they should be
collected in a util module
+ //this function that create topics can be reused
+ try {
+ CreateTopicRequestHeader requestHeader = new
CreateTopicRequestHeader();
+ requestHeader.setTopic(HealthConstant.ROCKETMQ_CHECK_TOPIC);
+
requestHeader.setTopicFilterType(TopicFilterType.SINGLE_TAG.name());
+ requestHeader.setReadQueueNums(8);
+ requestHeader.setWriteQueueNums(8);
+ requestHeader.setPerm(PermName.PERM_READ | PermName.PERM_WRITE);
+ RemotingCommand request =
RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_TOPIC,
requestHeader);
+ Object result =
remotingClient.invokeSync(getConfig().getRocketmqConfig().getBrokerUrl(),
request, getConfig().getRequestTimeoutMillis());
+ log.info(result.toString());
+ } catch (Exception e) {
+ log.error("RocketmqTopicCheck init failed when examining topic
stats.", e);
+ return;
+ }
+
+ try {
+ producer = new
DefaultMQProducer(HealthConstant.ROCKETMQ_CHECK_PRODUCER_GROUP);
+
producer.setNamesrvAddr(getConfig().getRocketmqConfig().getNameServerUrl());
+ producer.setCompressMsgBodyOverHowmuch(16);
+ producer.start();
+
+ consumer = new
DefaultMQPushConsumer(HealthConstant.ROCKETMQ_CHECK_CONSUMER_GROUP);
+ consumer.setMessageModel(MessageModel.CLUSTERING);
+
consumer.setNamesrvAddr(getConfig().getRocketmqConfig().getNameServerUrl());
+ consumer.subscribe(HealthConstant.ROCKETMQ_CHECK_TOPIC, "*");
+ consumer.registerMessageListener(new MessageListenerConcurrently()
{
+ @Override
+ public ConsumeConcurrentlyStatus
consumeMessage(List<MessageExt> list, ConsumeConcurrentlyContext
consumeConcurrentlyContext) {
+ consumedMessages.addAll(list);
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }
+ });
+ consumer.start();
+
+ } catch (Exception e) {
+ log.error("RocketmqCheck initialization failed when creating
Rocketmq4 clients.", e);
+ }
+
+
+ }
+
+ @Override
+ public void destroy() {
+ producer.shutdown();
+ consumer.shutdown();
+ }
+}
+
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapper.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapper.java
index ab57fc1..d51a9ef 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapper.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapper.java
@@ -26,6 +26,8 @@ import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
+import java.util.List;
+
/**
* Mybatis Mapper for the table of meta.
*/
@@ -35,7 +37,7 @@ public interface MetaMapper {
MetaEntity selectById(MetaEntity metaEntity);
@Select("SELECT * FROM meta WHERE cluster_id = #{clusterId} LIMIT 1")
- MetaEntity selectByClusterId(MetaEntity metaEntity);
+ List<MetaEntity> selectByClusterId(MetaEntity metaEntity);
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
@Insert("INSERT INTO meta (name, type, version, cluster_id, host, port,
role, username, params, status)"
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManager.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManager.java
index 50f5efb..a0a6130 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManager.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManager.java
@@ -17,8 +17,8 @@
package org.apache.eventmesh.dashboard.console.spring.support;
-import org.apache.eventmesh.dashboard.console.health.CheckResultCache;
-import org.apache.eventmesh.dashboard.console.health.HealthService;
+import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache;
+import org.apache.eventmesh.dashboard.console.function.health.HealthService;
import org.apache.eventmesh.dashboard.console.service.health.HealthDataService;
import lombok.Getter;
diff --git
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerLoader.java
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerLoader.java
index 405cedc..e2fcba4 100644
---
a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerLoader.java
+++
b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerLoader.java
@@ -17,7 +17,7 @@
package org.apache.eventmesh.dashboard.console.spring.support;
-import org.apache.eventmesh.dashboard.console.health.HealthService;
+import org.apache.eventmesh.dashboard.console.function.health.HealthService;
import org.apache.eventmesh.dashboard.console.service.health.HealthDataService;
import javax.annotation.PostConstruct;
diff --git a/eventmesh-dashboard-console/src/main/resources/application-dev.yml
b/eventmesh-dashboard-console/src/main/resources/application-dev.yml
index 3074e0c..3b3c83b 100644
--- a/eventmesh-dashboard-console/src/main/resources/application-dev.yml
+++ b/eventmesh-dashboard-console/src/main/resources/application-dev.yml
@@ -44,12 +44,11 @@ spring:
test-while-idle: true
min-evictable-idle-time-millis: 300000
+logging:
+ config: classpath:logback-dev.xml
+
mybatis:
type-aliases-package: org.apache.eventmesh.dashboard.console.entity
-# cron job config, use cron expression
-cron:
- #health check job
- health: "0/15 * * * * ? *"
diff --git
a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql
b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql
index c24a554..7c5e38b 100644
--- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql
+++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql
@@ -132,22 +132,23 @@ create index idx_store_id_runtime_id
DROP TABLE IF EXISTS `group`;
CREATE TABLE `group`
(
- `id` bigint unsigned NOT NULL
AUTO_INCREMENT COMMENT 'id',
- `cluster_id` bigint NOT NULL
DEFAULT '-1' COMMENT '集群id',
- `name` varchar(192) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
DEFAULT '' COMMENT 'Group名称',
- `member_count` int unsigned NOT NULL
DEFAULT '0' COMMENT '成员数',
+ `id` bigint unsigned NOT
NULL AUTO_INCREMENT COMMENT 'id',
+ `cluster_id` bigint NOT
NULL DEFAULT '-1' COMMENT '集群id',
+ `name` varchar(192) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT
NULL DEFAULT '' COMMENT 'Group名称',
+ `member_count` int unsigned NOT
NULL DEFAULT '0' COMMENT '成员数',
`members` varchar(1024) COMMENT 'group的member列表',
- `type` tinyint NOT NULL
COMMENT 'group类型 0:consumer 1:producer',
- `state` varchar(64) NOT NULL
DEFAULT '' COMMENT '状态',
- `create_time` timestamp NOT NULL
DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_time` timestamp NOT NULL
DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
- `is_delete` int NOT NULL
DEFAULT '0',
+ `type` tinyint NOT
NULL COMMENT 'group类型 0:consumer 1:producer',
+ `state` varchar(64) NOT
NULL DEFAULT '' COMMENT '状态',
+ `create_time` timestamp NOT
NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+ `update_time` timestamp NOT
NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
+ `is_delete` int NOT
NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_cluster_phy_id_name` (`cluster_id`, `name`),
KEY `cluster_id` (`cluster_id`, `name`)
) ENGINE = InnoDB
AUTO_INCREMENT = 322
- DEFAULT CHARSET = utf8mb3 COMMENT ='Group信息表';
+ DEFAULT CHARSET = utf8mb4,
+ DEFAULT COLLATE = utf8mb4_bin COMMENT ='Group信息表';
DROP TABLE IF EXISTS `group_member`;
@@ -167,7 +168,8 @@ CREATE TABLE `group_member`
KEY `cluster_id` (`cluster_id`, `topic_name`, `group_name`)
) ENGINE = InnoDB
AUTO_INCREMENT = 257
- DEFAULT CHARSET = utf8mb3 COMMENT ='GroupMember信息表';
+ DEFAULT CHARSET = utf8mb4,
+ DEFAULT COLLATE = utf8mb4_bin COMMENT ='GroupMember信息表';
DROP TABLE IF EXISTS `operation_log`;
@@ -189,29 +191,32 @@ CREATE TABLE `operation_log`
KEY `idx_status` (`status`)
) ENGINE = InnoDB
AUTO_INCREMENT = 68
- DEFAULT CHARSET = utf8mb3 COMMENT ='操作记录信息表';
+ DEFAULT CHARSET = utf8mb4,
+ DEFAULT COLLATE = utf8mb4_bin COMMENT ='操作记录信息表';
DROP TABLE IF EXISTS `topic`;
CREATE TABLE `topic`
(
- `id` bigint unsigned NOT NULL
AUTO_INCREMENT COMMENT 'id',
- `cluster_id` bigint NOT NULL
DEFAULT '-1' COMMENT '集群ID',
- `topic_name` varchar(192) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
DEFAULT '' COMMENT 'Topic名称',
- `runtime_id` varchar(2048) NOT NULL
DEFAULT '' COMMENT 'RuntimeId',
- `storage_id` varchar(2048) NOT NULL
DEFAULT '' COMMENT 'StorageId',
- `retention_ms` bigint NOT NULL
DEFAULT '-2' COMMENT '保存时间,-2:未知,-1:无限制,>=0对应时间,单位ms',
- `type` tinyint NOT NULL
DEFAULT '0' COMMENT 'Topic类型,默认0,0:普通,1:EventMesh内部',
- `description` varchar(1024)
DEFAULT '' COMMENT '备注信息',
- `create_time` timestamp NOT NULL
DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(尽量与Topic实际创建时间一致)',
- `update_time` timestamp NOT NULL
DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间(尽量与Topic实际创建时间一致)',
- `is_delete` int NOT NULL
DEFAULT '0',
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+ `cluster_id` bigint NOT NULL DEFAULT '-1' COMMENT '集群ID',
+ `topic_name` varchar(192) CHARACTER SET utf8mb4
+ COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT 'Topic名称',
+ `runtime_id` varchar(2048) NOT NULL DEFAULT '' COMMENT 'RuntimeId',
+ `storage_id` varchar(2048) NOT NULL DEFAULT '' COMMENT 'StorageId',
+ `retention_ms` bigint NOT NULL DEFAULT '-2' COMMENT
'保存时间,-2:未知,-1:无限制,>=0对应时间,单位ms',
+ `type` tinyint NOT NULL DEFAULT '0' COMMENT
'Topic类型,默认0,0:普通,1:EventMesh内部',
+ `description` varchar(1024) DEFAULT '' COMMENT '备注信息',
+ `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT
'创建时间(尽量与Topic实际创建时间一致)',
+ `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT
'修改时间(尽量与Topic实际创建时间一致)',
+ `is_delete` int NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_cluster_phy_id_topic_name` (`cluster_id`, `topic_name`),
KEY `cluster_id` (`cluster_id`, `topic_name`)
) ENGINE = InnoDB
AUTO_INCREMENT = 562
- DEFAULT CHARSET = utf8mb3 COMMENT ='Topic信息表';
+ DEFAULT CHARSET = utf8mb4,
+ DEFAULT COLLATE = utf8mb4_bin COMMENT ='Topic信息表';
DROP TABLE IF EXISTS `client`;
@@ -236,7 +241,8 @@ CREATE TABLE `client`
PRIMARY KEY (`id`),
INDEX `idx_cluster_id` (`cluster_id`)
) ENGINE = InnoDB
- DEFAULT CHARSET = utf8 COMMENT ='client is an SDK application that can
produce or consume events.';
+ DEFAULT CHARSET = utf8mb4,
+ DEFAULT COLLATE = utf8mb4_bin COMMENT ='client is an SDK application that
can produce or consume events.';
@@ -256,7 +262,8 @@ CREATE TABLE `connector`
PRIMARY KEY (`id`),
INDEX `idx_cluster_id` (`cluster_id`)
) ENGINE = InnoDB
- DEFAULT CHARSET = utf8 COMMENT ='Connector信息表';
+ DEFAULT CHARSET = utf8mb4,
+ DEFAULT COLLATE = utf8mb4_bin COMMENT ='Connector信息表';
DROP TABLE IF EXISTS `connection`;
CREATE TABLE `connection`
@@ -283,7 +290,8 @@ CREATE TABLE `connection`
INDEX `idx_source_id` (`source_id`),
INDEX `idx_sink_id` (`sink_id`)
) ENGINE = InnoDB
- DEFAULT CHARSET = utf8 COMMENT ='connection from event source to event sink.
event source can be a source connector or a producer client.';
+ DEFAULT CHARSET = utf8mb4,
+ DEFAULT COLLATE = utf8mb4_bin COMMENT ='connection from event source to
event sink. event source can be a source connector or a producer client.';
DROP TABLE IF EXISTS `health_check_result`;
CREATE TABLE `health_check_result`
@@ -300,7 +308,8 @@ CREATE TABLE `health_check_result`
INDEX `idx_cluster_id` (`cluster_id`),
INDEX `idx_type` (`type`)
) ENGINE = InnoDB
- DEFAULT CHARSET = utf8 COMMENT ='健康检查结果';
+ DEFAULT CHARSET = utf8mb4,
+ DEFAULT COLLATE = utf8mb4_bin COMMENT ='健康检查结果';
DROP TABLE IF EXISTS `meta`;
CREATE TABLE `meta`
@@ -324,4 +333,5 @@ CREATE TABLE `meta`
INDEX `idx_cluster_id` (`cluster_id`)
) ENGINE = InnoDB
- DEFAULT CHARSET = utf8 COMMENT ='注册中心信息表';
\ No newline at end of file
+ DEFAULT CHARSET = utf8mb4,
+ DEFAULT COLLATE = utf8mb4_bin COMMENT ='注册中心信息表';
\ No newline at end of file
diff --git a/eventmesh-dashboard-console/src/main/resources/logback-dev.xml
b/eventmesh-dashboard-console/src/main/resources/logback-dev.xml
new file mode 100644
index 0000000..e86bb3e
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/resources/logback-dev.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You 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.
+ -->
+
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder charset="UTF-8">
+ <pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] %p %t - %m%n</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="FILE"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${user.home}/logs/eventmesh-dashboard.log</file>
+ <append>true</append>
+ <rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+
<fileNamePattern>${user.home}/logs/eventmesh-dashboard-%d{yyyy-MM-dd}.%i.log
+ </fileNamePattern>
+ <timeBasedFileNamingAndTriggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+ <maxFileSize>104857600</maxFileSize>
+ </timeBasedFileNamingAndTriggeringPolicy>
+ <MaxHistory>10</MaxHistory>
+ </rollingPolicy>
+ <encoder>
+ <pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] %p %t - %m%n</pattern>
+ <charset class="java.nio.charset.Charset">UTF-8</charset>
+ </encoder>
+ </appender>
+
+ <root level="DEBUG">
+ <appender-ref ref="STDOUT" />
+ <appender-ref ref="FILE" />
+ </root>
+
+</configuration>
\ No newline at end of file
diff --git
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/HealthExecutorTest.java
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java
similarity index 93%
rename from
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/HealthExecutorTest.java
rename to
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java
index d7626ed..e36eb61 100644
---
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/HealthExecutorTest.java
+++
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.health;
+package org.apache.eventmesh.dashboard.console.function.health;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
@@ -26,9 +26,9 @@ import
org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication;
import
org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity;
import org.apache.eventmesh.dashboard.console.enums.health.HealthCheckStatus;
import org.apache.eventmesh.dashboard.console.enums.health.HealthCheckType;
-import
org.apache.eventmesh.dashboard.console.health.callback.HealthCheckCallback;
-import
org.apache.eventmesh.dashboard.console.health.check.AbstractHealthCheckService;
-import
org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig;
+import
org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback;
+import
org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
import
org.apache.eventmesh.dashboard.console.service.health.impl.HealthDataServiceDatabaseImpl;
import java.util.concurrent.CompletableFuture;
@@ -77,7 +77,7 @@ class HealthExecutorTest {
}).when(successHealthCheckService).doCheck(any(HealthCheckCallback.class));
Mockito.lenient().doAnswer((Answer<Void>) invocation -> {
HealthCheckCallback callback = invocation.getArgument(0);
- callback.onFail(new RuntimeException("TestRuntimeException"));
+ callback.onFail(new RuntimeException("TestRuntimeException: This
check is designed to be failed. Ignore This!"));
return null;
}).when(failHealthCheckService).doCheck(any(HealthCheckCallback.class));
Mockito.lenient().doAnswer((Answer<Void>) invocation -> {
@@ -100,7 +100,7 @@ class HealthExecutorTest {
config1.setHealthCheckResourceType("storage");
config1.setHealthCheckResourceSubType("redis");
config1.setConnectUrl("redis://localhost:6379");
- config1.setSimpleClassName("StorageRedisCheck");
+ config1.setSimpleClassName("RedisCheck");
config1.setClusterId(1L);
Mockito.lenient().when(successHealthCheckService.getConfig()).thenReturn(config1);
Mockito.lenient().when(timeoutHealthCheckService.getConfig()).thenReturn(config1);
@@ -109,7 +109,7 @@ class HealthExecutorTest {
config2.setHealthCheckResourceType("storage");
config2.setHealthCheckResourceSubType("redis");
config2.setConnectUrl("redis://localhost:6379");
- config2.setSimpleClassName("StorageRedisCheck");
+ config2.setSimpleClassName("RedisCheck");
config2.setClusterId(1L);
Mockito.lenient().when(failHealthCheckService.getConfig()).thenReturn(config2);
}
diff --git
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/HealthServiceTest.java
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthServiceTest.java
similarity index 88%
rename from
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/HealthServiceTest.java
rename to
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthServiceTest.java
index 9a2c393..4d15316 100644
---
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/HealthServiceTest.java
+++
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthServiceTest.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.health;
+package org.apache.eventmesh.dashboard.console.function.health;
-import
org.apache.eventmesh.dashboard.console.health.callback.HealthCheckCallback;
-import
org.apache.eventmesh.dashboard.console.health.check.AbstractHealthCheckService;
-import
org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig;
+import
org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback;
+import
org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
import org.apache.eventmesh.dashboard.console.service.health.HealthDataService;
import org.junit.jupiter.api.BeforeEach;
@@ -58,7 +58,7 @@ class HealthServiceTest {
void testInsertCheckServiceWithSimpleClassName() {
HealthCheckObjectConfig config = new HealthCheckObjectConfig();
config.setInstanceId(1L);
- config.setSimpleClassName("StorageRedisCheck");
+ config.setSimpleClassName("RedisCheck");
config.setHealthCheckResourceType("storage");
config.setHealthCheckResourceSubType("redis");
config.setClusterId(1L);
@@ -89,7 +89,7 @@ class HealthServiceTest {
}
@Test
- void testExecuteAll(){
+ void testExecuteAll() {
HealthCheckObjectConfig config = new HealthCheckObjectConfig();
config.setInstanceId(1L);
config.setHealthCheckResourceType("storage");
@@ -115,5 +115,10 @@ class HealthServiceTest {
public void init() {
}
+
+ @Override
+ public void destroy() {
+
+ }
}
}
\ No newline at end of file
diff --git
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheckTest.java
similarity index 51%
copy from
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java
copy to
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheckTest.java
index 74ac54c..6613395 100644
---
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java
+++
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheckTest.java
@@ -15,42 +15,56 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.health.check.impl;
+package org.apache.eventmesh.dashboard.console.function.health.check.impl.meta;
-import
org.apache.eventmesh.dashboard.console.health.callback.HealthCheckCallback;
-import
org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig;
+import
org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
+import java.util.concurrent.CountDownLatch;
+
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-class StorageRedisCheckTest {
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+class NacosConfigCheckTest {
- private StorageRedisCheck storageRedisCheck;
+ private NacosConfigCheck nacosCheck;
@BeforeEach
public void init() {
HealthCheckObjectConfig config = new HealthCheckObjectConfig();
config.setInstanceId(1L);
- config.setHealthCheckResourceType("storage");
- config.setHealthCheckResourceSubType("redis");
- config.setSimpleClassName("StorageRedisCheck");
+ config.setHealthCheckResourceType("meta");
+ config.setHealthCheckResourceSubType("nacos");
config.setClusterId(1L);
- config.setConnectUrl("redis://localhost:6379");
- storageRedisCheck = new StorageRedisCheck(config);
+ config.setConnectUrl("127.0.0.1:8848");
+ nacosCheck = new NacosConfigCheck(config);
}
@Test
- public void testDoCheck() {
- storageRedisCheck.doCheck(new HealthCheckCallback() {
+ public void testDoCheck() throws InterruptedException {
+ CountDownLatch latch = new CountDownLatch(1);
+ nacosCheck.doCheck(new HealthCheckCallback() {
@Override
public void onSuccess() {
- System.out.println("success");
+ latch.countDown();
+ log.info("{} success", this.getClass().getSimpleName());
}
@Override
public void onFail(Exception e) {
- System.out.println("fail");
+ latch.countDown();
+ log.error("{}, failed for reason {}",
this.getClass().getSimpleName(), e);
}
});
+ latch.await();
+ }
+
+ @AfterEach
+ public void destroy() {
+ nacosCheck.destroy();
}
}
\ No newline at end of file
diff --git
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosRegisterCheckTest.java
similarity index 50%
copy from
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java
copy to
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosRegisterCheckTest.java
index 74ac54c..1b97df1 100644
---
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java
+++
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosRegisterCheckTest.java
@@ -15,42 +15,56 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.health.check.impl;
+package org.apache.eventmesh.dashboard.console.function.health.check.impl.meta;
-import
org.apache.eventmesh.dashboard.console.health.callback.HealthCheckCallback;
-import
org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig;
+import
org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
+import java.util.concurrent.CountDownLatch;
+
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-class StorageRedisCheckTest {
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+class NacosRegisterCheckTest {
- private StorageRedisCheck storageRedisCheck;
+ private NacosRegisterCheck nacosRegisterCheck;
@BeforeEach
public void init() {
HealthCheckObjectConfig config = new HealthCheckObjectConfig();
config.setInstanceId(1L);
- config.setHealthCheckResourceType("storage");
- config.setHealthCheckResourceSubType("redis");
- config.setSimpleClassName("StorageRedisCheck");
+ config.setHealthCheckResourceType("meta");
+ config.setHealthCheckResourceSubType("nacos");
config.setClusterId(1L);
- config.setConnectUrl("redis://localhost:6379");
- storageRedisCheck = new StorageRedisCheck(config);
+ config.setConnectUrl("127.0.0.1:8848");
+ nacosRegisterCheck = new NacosRegisterCheck(config);
}
@Test
- public void testDoCheck() {
- storageRedisCheck.doCheck(new HealthCheckCallback() {
+ public void testDoCheck() throws InterruptedException {
+ CountDownLatch latch = new CountDownLatch(1);
+ nacosRegisterCheck.doCheck(new HealthCheckCallback() {
@Override
public void onSuccess() {
- System.out.println("success");
+ latch.countDown();
+ log.info("{} success", this.getClass().getSimpleName());
}
@Override
public void onFail(Exception e) {
- System.out.println("fail");
+ latch.countDown();
+ log.error("{}, failed for reason {}",
this.getClass().getSimpleName(), e);
}
});
+ latch.await();
+ }
+
+ @AfterEach
+ public void destroy() {
+ nacosRegisterCheck.destroy();
}
}
\ No newline at end of file
diff --git
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheckTest.java
similarity index 57%
copy from
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java
copy to
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheckTest.java
index 74ac54c..45cef81 100644
---
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java
+++
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheckTest.java
@@ -15,17 +15,22 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.health.check.impl;
+package
org.apache.eventmesh.dashboard.console.function.health.check.impl.storage;
-import
org.apache.eventmesh.dashboard.console.health.callback.HealthCheckCallback;
-import
org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig;
+import
org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
+
+import java.util.concurrent.CountDownLatch;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-class StorageRedisCheckTest {
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+class RedisCheckTest {
- private StorageRedisCheck storageRedisCheck;
+ private RedisCheck redisCheck;
@BeforeEach
public void init() {
@@ -33,24 +38,28 @@ class StorageRedisCheckTest {
config.setInstanceId(1L);
config.setHealthCheckResourceType("storage");
config.setHealthCheckResourceSubType("redis");
- config.setSimpleClassName("StorageRedisCheck");
+ config.setSimpleClassName("RedisCheck");
config.setClusterId(1L);
- config.setConnectUrl("redis://localhost:6379");
- storageRedisCheck = new StorageRedisCheck(config);
+ config.setConnectUrl("redis://127.0.0.1:6379");
+ redisCheck = new RedisCheck(config);
}
@Test
- public void testDoCheck() {
- storageRedisCheck.doCheck(new HealthCheckCallback() {
+ public void testDoCheck() throws InterruptedException {
+ CountDownLatch latch = new CountDownLatch(1);
+ redisCheck.doCheck(new HealthCheckCallback() {
@Override
public void onSuccess() {
- System.out.println("success");
+ latch.countDown();
+ log.info("{} success", this.getClass().getSimpleName());
}
@Override
public void onFail(Exception e) {
- System.out.println("fail");
+ latch.countDown();
+ log.error("{}, failed for reason {}",
this.getClass().getSimpleName(), e);
}
});
+ latch.await();
}
}
\ No newline at end of file
diff --git
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqBrokerCheckTest.java
similarity index 52%
copy from
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java
copy to
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqBrokerCheckTest.java
index 74ac54c..abf7ab2 100644
---
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java
+++
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqBrokerCheckTest.java
@@ -15,42 +15,47 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.health.check.impl;
+package
org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.rocketmq4;
-import
org.apache.eventmesh.dashboard.console.health.callback.HealthCheckCallback;
-import
org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig;
+import
org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
+
+import java.util.concurrent.CountDownLatch;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-class StorageRedisCheckTest {
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+class RocketmqBrokerCheckTest {
- private StorageRedisCheck storageRedisCheck;
+ private Rocketmq4BrokerCheck rocketmqCheck;
@BeforeEach
public void init() {
HealthCheckObjectConfig config = new HealthCheckObjectConfig();
- config.setInstanceId(1L);
- config.setHealthCheckResourceType("storage");
- config.setHealthCheckResourceSubType("redis");
- config.setSimpleClassName("StorageRedisCheck");
- config.setClusterId(1L);
- config.setConnectUrl("redis://localhost:6379");
- storageRedisCheck = new StorageRedisCheck(config);
+ config.getRocketmqConfig().setBrokerUrl("127.0.0.1:10911");
+ config.setRequestTimeoutMillis(1000L);
+ rocketmqCheck = new Rocketmq4BrokerCheck(config);
}
@Test
- public void testDoCheck() {
- storageRedisCheck.doCheck(new HealthCheckCallback() {
+ public void testDoCheck() throws InterruptedException {
+ CountDownLatch latch = new CountDownLatch(1);
+ rocketmqCheck.doCheck(new HealthCheckCallback() {
@Override
public void onSuccess() {
- System.out.println("success");
+ latch.countDown();
+ log.info("{} success", this.getClass().getSimpleName());
}
@Override
public void onFail(Exception e) {
- System.out.println("fail");
+ latch.countDown();
+ log.error("{}, failed for reason {}",
this.getClass().getSimpleName(), e);
}
});
+ latch.await();
}
}
\ No newline at end of file
diff --git
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqNameserverCheckTest.java
similarity index 52%
rename from
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java
rename to
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqNameserverCheckTest.java
index 74ac54c..92677ba 100644
---
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java
+++
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqNameserverCheckTest.java
@@ -15,42 +15,47 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.health.check.impl;
+package
org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.rocketmq4;
-import
org.apache.eventmesh.dashboard.console.health.callback.HealthCheckCallback;
-import
org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig;
+import
org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
+
+import java.util.concurrent.CountDownLatch;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-class StorageRedisCheckTest {
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+class RocketmqNameserverCheckTest {
- private StorageRedisCheck storageRedisCheck;
+ private Rocketmq4NameServerCheck rocketmqCheck;
@BeforeEach
public void init() {
HealthCheckObjectConfig config = new HealthCheckObjectConfig();
- config.setInstanceId(1L);
- config.setHealthCheckResourceType("storage");
- config.setHealthCheckResourceSubType("redis");
- config.setSimpleClassName("StorageRedisCheck");
- config.setClusterId(1L);
- config.setConnectUrl("redis://localhost:6379");
- storageRedisCheck = new StorageRedisCheck(config);
+ config.getRocketmqConfig().setNameServerUrl("127.0.0.1:9876");
+ config.setRequestTimeoutMillis(1000L);
+ rocketmqCheck = new Rocketmq4NameServerCheck(config);
}
@Test
- public void testDoCheck() {
- storageRedisCheck.doCheck(new HealthCheckCallback() {
+ public void testDoCheck() throws InterruptedException {
+ CountDownLatch latch = new CountDownLatch(1);
+ rocketmqCheck.doCheck(new HealthCheckCallback() {
@Override
public void onSuccess() {
- System.out.println("success");
+ latch.countDown();
+ log.info("{} success", this.getClass().getSimpleName());
}
@Override
public void onFail(Exception e) {
- System.out.println("fail");
+ latch.countDown();
+ log.error("{}, failed for reason {}",
this.getClass().getSimpleName(), e);
}
});
+ latch.await();
}
}
\ No newline at end of file
diff --git
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqTopicCheckTest.java
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqTopicCheckTest.java
new file mode 100644
index 0000000..8a90a5b
--- /dev/null
+++
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqTopicCheckTest.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.rocketmq4;
+
+import
org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
+
+import java.util.concurrent.CountDownLatch;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+class RocketmqTopicCheckTest {
+
+ private Rocketmq4TopicCheck rocketmqCheck;
+
+ @BeforeEach
+ public void init() throws InterruptedException {
+ HealthCheckObjectConfig config = new HealthCheckObjectConfig();
+ config.getRocketmqConfig().setBrokerUrl("127.0.0.1:10911");
+ config.getRocketmqConfig().setNameServerUrl("127.0.0.1:9876");
+ config.setRequestTimeoutMillis(1000000L);
+ rocketmqCheck = new Rocketmq4TopicCheck(config);
+ }
+
+ @Test
+ public void testDoCheck() throws InterruptedException {
+ CountDownLatch latch = new CountDownLatch(2);
+ rocketmqCheck.doCheck(new HealthCheckCallback() {
+ @Override
+ public void onSuccess() {
+ latch.countDown();
+ log.info("{} success", this.getClass().getSimpleName());
+ }
+
+ @Override
+ public void onFail(Exception e) {
+ latch.countDown();
+ log.error("{}, failed for reason {}",
this.getClass().getSimpleName(), e);
+ }
+ });
+ rocketmqCheck.doCheck(new HealthCheckCallback() {
+ @Override
+ public void onSuccess() {
+ latch.countDown();
+ log.info("{} success", this.getClass().getSimpleName());
+ }
+
+ @Override
+ public void onFail(Exception e) {
+ latch.countDown();
+ log.error("{}, failed for reason {}",
this.getClass().getSimpleName(), e);
+ }
+ });
+ latch.await();
+ }
+}
\ No newline at end of file
diff --git
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/integration/health/HealthServiceIntegrateTest.java
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/integration/health/HealthServiceIntegrateTest.java
index e8fdb5f..2a780f4 100644
---
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/integration/health/HealthServiceIntegrateTest.java
+++
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/integration/health/HealthServiceIntegrateTest.java
@@ -19,9 +19,9 @@ package
org.apache.eventmesh.dashboard.console.integration.health;
import
org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity;
import org.apache.eventmesh.dashboard.console.enums.health.HealthCheckType;
-import org.apache.eventmesh.dashboard.console.health.CheckResultCache;
-import org.apache.eventmesh.dashboard.console.health.HealthService;
-import
org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig;
+import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache;
+import org.apache.eventmesh.dashboard.console.function.health.HealthService;
+import
org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig;
import org.apache.eventmesh.dashboard.console.service.health.HealthDataService;
import java.util.List;
@@ -38,12 +38,14 @@ import org.springframework.test.context.jdbc.Sql;
@ActiveProfiles("test")
@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts =
{"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"})
public class HealthServiceIntegrateTest {
+
HealthService healthService = new HealthService();
@Autowired
private HealthDataService healthDataService;
private final CheckResultCache checkResultCache = new CheckResultCache();
+
@BeforeEach
void init() {
healthService.createExecutor(healthDataService, checkResultCache);
@@ -66,7 +68,7 @@ public class HealthServiceIntegrateTest {
queryEntity.setClusterId(1L);
queryEntity.setType(HealthCheckType.STORAGE.getNumber());
queryEntity.setTypeId(1L);
- List<HealthCheckResultEntity> results =
healthDataService.queryHealthCheckResultByClusterIdAndTypeAndTypeId(queryEntity);
- Assertions.assertEquals(2,results.size());
+ List<HealthCheckResultEntity> results =
healthDataService.queryHealthCheckResultByClusterIdAndTypeAndTypeId(queryEntity);
+ Assertions.assertEquals(2, results.size());
}
}
diff --git
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java
index afaf8d8..9004738 100644
---
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java
+++
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.eventmesh.dashboard.console.linkage.log;
import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication;
diff --git
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapperTest.java
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapperTest.java
index 4f28229..6106e17 100644
---
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapperTest.java
+++
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapperTest.java
@@ -83,15 +83,15 @@ class ConnectionMapperTest {
@Test
public void testInsert() {
- ConnectionEntity connectionEntity = new ConnectionEntity(1L, 1L,
"connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description");
+ ConnectionEntity connectionEntity = new ConnectionEntity(1L,
"connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description");
connectionMapper.insert(connectionEntity);
assertEquals(7, connectionMapper.selectAll().size());
}
@Test
public void testBatchInsert() {
- ConnectionEntity connectionEntity1 = new ConnectionEntity(1L, 1L,
"connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description");
- ConnectionEntity connectionEntity2 = new ConnectionEntity(1L, 1L,
"connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description");
+ ConnectionEntity connectionEntity1 = new ConnectionEntity(1L,
"connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description");
+ ConnectionEntity connectionEntity2 = new ConnectionEntity(1L,
"connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description");
connectionMapper.batchInsert(Arrays.asList(connectionEntity1,
connectionEntity2));
assertEquals(8, connectionMapper.selectAll().size());
}
diff --git
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapperTest.java
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapperTest.java
index 0bb360b..786597d 100644
---
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapperTest.java
+++
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapperTest.java
@@ -69,7 +69,7 @@ class ConnectorMapperTest {
@Test
public void testInsert() {
- ConnectorEntity connectorEntity = new ConnectorEntity(1L, 1L, "test",
"test", "test", 0, 2, "test");
+ ConnectorEntity connectorEntity = new ConnectorEntity(1L, "test",
"test", "test", 0, 2, "test");
connectorMapper.insert(connectorEntity);
assertNotNull(connectorEntity);
@@ -78,9 +78,9 @@ class ConnectorMapperTest {
@Test
public void testBatchInsert() {
- ConnectorEntity connectorEntity1 = new ConnectorEntity(1L, 1L, "test",
"test", "test", 0, 2, "test");
- ConnectorEntity connectorEntity2 = new ConnectorEntity(1L, 1L, "test",
"test", "test", 0, 2, "test");
- ConnectorEntity connectorEntity3 = new ConnectorEntity(1L, 1L, "test",
"test", "test", 0, 2, "test");
+ ConnectorEntity connectorEntity1 = new ConnectorEntity(1L, "test",
"test", "test", 0, 2, "test");
+ ConnectorEntity connectorEntity2 = new ConnectorEntity(1L, "test",
"test", "test", 0, 2, "test");
+ ConnectorEntity connectorEntity3 = new ConnectorEntity(1L, "test",
"test", "test", 0, 2, "test");
List<ConnectorEntity> connectorEntityList = new ArrayList<>();
connectorEntityList.add(connectorEntity1);
connectorEntityList.add(connectorEntity2);
diff --git
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapperTest.java
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapperTest.java
index 1ceb8fc..30e6690 100644
---
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapperTest.java
+++
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapperTest.java
@@ -17,7 +17,7 @@
package org.apache.eventmesh.dashboard.console.mapper.health;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication;
import
org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity;
@@ -58,7 +58,7 @@ class HealthCheckResultMapperTest {
@Test
public void testSelectByClusterIdAndTypeAndTypeId() {
- HealthCheckResultEntity healthCheckResultEntity = new
HealthCheckResultEntity(1L, 1L, 1, 1L, "", 1);
+ HealthCheckResultEntity healthCheckResultEntity = new
HealthCheckResultEntity(1L, 1, 1L, "", 1);
healthCheckResultEntity =
healthCheckResultMapper.selectByClusterIdAndTypeAndTypeId(healthCheckResultEntity).get(0);
assertEquals(1, healthCheckResultEntity.getId());
assertEquals(0, healthCheckResultEntity.getStatus());
@@ -66,7 +66,7 @@ class HealthCheckResultMapperTest {
@Test
public void testSelectByClusterIdAndType() {
- HealthCheckResultEntity healthCheckResultEntity = new
HealthCheckResultEntity(1L, 1L, 1, 1L, "", 1);
+ HealthCheckResultEntity healthCheckResultEntity = new
HealthCheckResultEntity(1L, 1, 1L, "", 1);
List<HealthCheckResultEntity> results =
healthCheckResultMapper.selectByClusterIdAndType(healthCheckResultEntity);
assertEquals(2, results.size());
}
@@ -84,7 +84,7 @@ class HealthCheckResultMapperTest {
@Test
public void testInsert() {
- HealthCheckResultEntity healthCheckResultEntity = new
HealthCheckResultEntity(1L, 5L, 1, 5L, "", 1);
+ HealthCheckResultEntity healthCheckResultEntity = new
HealthCheckResultEntity(5L, 1, 5L, "", 1);
healthCheckResultMapper.insert(healthCheckResultEntity);
healthCheckResultEntity =
healthCheckResultMapper.selectById(healthCheckResultEntity);
assertEquals(7, healthCheckResultEntity.getId());
@@ -92,8 +92,8 @@ class HealthCheckResultMapperTest {
@Test
public void testBatchInsert() {
- HealthCheckResultEntity healthCheckResultEntity1 = new
HealthCheckResultEntity(1L, 1L, 1, 5L, "", 1);
- HealthCheckResultEntity healthCheckResultEntity2 = new
HealthCheckResultEntity(1L, 1L, 1, 6L, "", 1);
+ HealthCheckResultEntity healthCheckResultEntity1 = new
HealthCheckResultEntity(1L, 1, 5L, "", 1);
+ HealthCheckResultEntity healthCheckResultEntity2 = new
HealthCheckResultEntity(1L, 1, 6L, "", 1);
healthCheckResultMapper.batchInsert(Arrays.asList(healthCheckResultEntity1,
healthCheckResultEntity2));
List<HealthCheckResultEntity> results =
healthCheckResultMapper.selectByClusterIdAndType(healthCheckResultEntity1);
assertEquals(4, results.size());
@@ -101,7 +101,7 @@ class HealthCheckResultMapperTest {
@Test
public void testUpdate() {
- HealthCheckResultEntity healthCheckResultEntity = new
HealthCheckResultEntity(1L, 1L, 1, 1L, "reason", 0);
+ HealthCheckResultEntity healthCheckResultEntity = new
HealthCheckResultEntity(1L, 1, 1L, "reason", 0);
healthCheckResultMapper.update(healthCheckResultEntity);
healthCheckResultEntity =
healthCheckResultMapper.selectByClusterIdAndTypeAndTypeId(healthCheckResultEntity).get(0);
assertEquals(0, healthCheckResultEntity.getStatus());
@@ -109,8 +109,10 @@ class HealthCheckResultMapperTest {
@Test
public void testBatchUpdate() {
- HealthCheckResultEntity healthCheckResultEntity1 = new
HealthCheckResultEntity(1L, 1L, 1, 1L, "reason", 0);
- HealthCheckResultEntity healthCheckResultEntity2 = new
HealthCheckResultEntity(2L, 1L, 1, 1L, "reason", 0);
+ HealthCheckResultEntity healthCheckResultEntity1 = new
HealthCheckResultEntity(1L, 1, 1L, "reason", 0);
+ healthCheckResultEntity1.setId(1L);
+ HealthCheckResultEntity healthCheckResultEntity2 = new
HealthCheckResultEntity(1L, 1, 1L, "reason", 0);
+ healthCheckResultEntity2.setId(2L);
healthCheckResultMapper.batchUpdate(Arrays.asList(healthCheckResultEntity1,
healthCheckResultEntity2));
healthCheckResultEntity1 =
healthCheckResultMapper.selectById(healthCheckResultEntity1);
healthCheckResultEntity2 =
healthCheckResultMapper.selectById(healthCheckResultEntity2);
@@ -121,8 +123,8 @@ class HealthCheckResultMapperTest {
@Test
public void testUpdateByClusterIdAndTypeAndTypeId() {
- HealthCheckResultEntity entity1 = new HealthCheckResultEntity(null,
1L, 1, 1L, "reason", 2);
- HealthCheckResultEntity entity2 = new HealthCheckResultEntity(null,
1L, 1, 1L, "reason", 2);
+ HealthCheckResultEntity entity1 = new HealthCheckResultEntity(1L, 1,
1L, "reason", 2);
+ HealthCheckResultEntity entity2 = new HealthCheckResultEntity(1L, 1,
1L, "reason", 2);
healthCheckResultMapper.batchInsert(Arrays.asList(entity1, entity2));
List<HealthCheckResultEntity> toBeUpdate =
healthCheckResultMapper.getIdsNeedToBeUpdateByClusterIdAndTypeAndTypeId(
diff --git
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapperTest.java
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapperTest.java
index 9d05b40..5888eda 100644
---
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapperTest.java
+++
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapperTest.java
@@ -20,6 +20,7 @@ package org.apache.eventmesh.dashboard.console.mapper.meta;
import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication;
import org.apache.eventmesh.dashboard.console.entity.meta.MetaEntity;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -42,6 +43,7 @@ class MetaMapperTest {
public void testSelectByClusterId() {
MetaEntity metaEntity = new MetaEntity();
metaEntity.setClusterId(1L);
- metaEntity = metaMapper.selectByClusterId(metaEntity);
+ metaEntity = metaMapper.selectByClusterId(metaEntity).get(0);
+ Assertions.assertEquals("nacos", metaEntity.getType());
}
}
\ No newline at end of file
diff --git
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupMapper.java
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/GroupMapperTest.java
similarity index 82%
rename from
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupMapper.java
rename to
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/GroupMapperTest.java
index f02fcaf..41eca99 100644
---
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupMapper.java
+++
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/GroupMapperTest.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.eventmesh.dashboard.console.unit.group;
import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication;
@@ -16,7 +33,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = EventMeshDashboardApplication.class)
-public class TestGroupMapper {
+public class GroupMapperTest {
@Autowired
private OprGroupMapper groupMapper;
diff --git
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberMapper.java
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/GroupMemberMapperTest.java
similarity index 88%
rename from
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberMapper.java
rename to
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/GroupMemberMapperTest.java
index d3a20a0..76fa849 100644
---
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberMapper.java
+++
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/GroupMemberMapperTest.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.eventmesh.dashboard.console.unit.groupmember;
import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication;
@@ -16,7 +33,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = EventMeshDashboardApplication.class)
-public class testGroupMemberMapper {
+public class GroupMemberMapperTest {
@Autowired
OprGroupMemberMapper groupMemberMapper;
diff --git
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicMapper.java
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TopicMapperTest.java
similarity index 84%
rename from
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicMapper.java
rename to
eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TopicMapperTest.java
index 7472792..929953a 100644
---
a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicMapper.java
+++
b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TopicMapperTest.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.eventmesh.dashboard.console.unit.topic;
import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication;
@@ -16,7 +33,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = EventMeshDashboardApplication.class)
-public class testTopicMapper {
+public class TopicMapperTest {
@Autowired
private TopicMapper topicMapper;
diff --git a/eventmesh-dashboard-console/src/test/resources/logback-test.xml
b/eventmesh-dashboard-console/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..e86bb3e
--- /dev/null
+++ b/eventmesh-dashboard-console/src/test/resources/logback-test.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You 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.
+ -->
+
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder charset="UTF-8">
+ <pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] %p %t - %m%n</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="FILE"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${user.home}/logs/eventmesh-dashboard.log</file>
+ <append>true</append>
+ <rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+
<fileNamePattern>${user.home}/logs/eventmesh-dashboard-%d{yyyy-MM-dd}.%i.log
+ </fileNamePattern>
+ <timeBasedFileNamingAndTriggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+ <maxFileSize>104857600</maxFileSize>
+ </timeBasedFileNamingAndTriggeringPolicy>
+ <MaxHistory>10</MaxHistory>
+ </rollingPolicy>
+ <encoder>
+ <pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] %p %t - %m%n</pattern>
+ <charset class="java.nio.charset.Charset">UTF-8</charset>
+ </encoder>
+ </appender>
+
+ <root level="DEBUG">
+ <appender-ref ref="STDOUT" />
+ <appender-ref ref="FILE" />
+ </root>
+
+</configuration>
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 68372bf..f0645ad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,13 +74,14 @@
<url>https://github.com/apache/eventmesh-dashboard/issues</url>
</issueManagement>
- <properties>
- <maven.compiler.source>8</maven.compiler.source>
- <maven.compiler.target>8</maven.compiler.target>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <spring-boot.version>2.7.6</spring-boot.version>
- <mybatis-spring-boot.version>2.3.2</mybatis-spring-boot.version>
- </properties>
+ <properties>
+ <maven.compiler.source>8</maven.compiler.source>
+ <maven.compiler.target>8</maven.compiler.target>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <spring-boot.version>2.7.6</spring-boot.version>
+ <mybatis-spring-boot.version>2.3.2</mybatis-spring-boot.version>
+ <nacos.version>2.1.2</nacos.version>
+ </properties>
<modules>
<module>eventmesh-dashboard-console</module>
@@ -135,17 +136,6 @@
</execution>
</executions>
</plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>3.2.2</version>
- <configuration>
- <excludes>
-
<exclude>**/org/apache/eventmesh/dashboard/console/integration/**/*.java</exclude>
- </excludes>
- </configuration>
- </plugin>
</plugins>
</build>
</project>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]