Skip to content

Commit

Permalink
refactor: move health module into function module.
Browse files Browse the repository at this point in the history
more files will be added in function module
  • Loading branch information
Lambert-Rao committed Mar 7, 2024
1 parent f75c394 commit 702b96a
Show file tree
Hide file tree
Showing 20 changed files with 201 additions and 93 deletions.
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -36,4 +36,6 @@ public interface HealthCheckService {

public void init();

public void destroy();

}
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.check.config;
package org.apache.eventmesh.dashboard.console.function.health.check.config;

import java.util.Properties;

Expand All @@ -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;
Expand All @@ -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;
}
}
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.check.impl;
package org.apache.eventmesh.dashboard.console.function.health.check.impl;

public class StorageRocketmqCheck {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 * * * * ? *"


Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,23 @@
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`;
Expand All @@ -52,7 +53,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`;
Expand All @@ -74,29 +76,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`;
Expand All @@ -121,7 +126,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.';



Expand All @@ -141,7 +147,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`
Expand All @@ -168,7 +175,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`
Expand All @@ -185,7 +193,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`
Expand All @@ -209,4 +218,5 @@ CREATE TABLE `meta`
INDEX `idx_cluster_id` (`cluster_id`)

) ENGINE = InnoDB
DEFAULT CHARSET = utf8 COMMENT ='注册中心信息表';
DEFAULT CHARSET = utf8mb4,
DEFAULT COLLATE = utf8mb4_bin COMMENT ='注册中心信息表';
Loading

0 comments on commit 702b96a

Please sign in to comment.