Skip to content

Commit

Permalink
[ISSUE #49] RocketMQ and Nacos health check (#53)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Lambert-Rao committed Mar 9, 2024
1 parent 4eb9f83 commit c21462c
Show file tree
Hide file tree
Showing 51 changed files with 1,434 additions and 183 deletions.
63 changes: 48 additions & 15 deletions eventmesh-dashboard-console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand All @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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";
}
Original file line number Diff line number Diff line change
@@ -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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,21 @@

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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
public class HealthCheckResultEntity extends BaseEntity {

private static final long serialVersionUID = -7350585209577598040L;
@Schema(name = "id", description = "primary key")
private Long id;

private Long clusterId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -127,6 +127,7 @@ public void deleteCheckService(String resourceType, Long resourceId) {
if (Objects.isNull(subMap)) {
return;
}
subMap.get(resourceId).destroy();
subMap.remove(resourceId);
if (subMap.isEmpty()) {
checkServiceMap.remove(resourceType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit c21462c

Please sign in to comment.