From 0a6ee0a68ee93efcb91b512374311ca16872b16f Mon Sep 17 00:00:00 2001 From: pizihao <48643103+pizihao@users.noreply.github.com> Date: Tue, 6 Sep 2022 18:50:58 +0800 Subject: [PATCH 01/11] improve the way to get port and ip (#663) * improve the way to get port and ip * fix : Code format --- .../common/model/WebIpAndPortInfo.java | 101 ++++++++++++++ .../event/AbstractRefreshListener.java | 126 ++++-------------- .../AdapterExecutorsRefreshListener.java | 2 +- 3 files changed, 129 insertions(+), 100 deletions(-) create mode 100644 hippo4j-common/src/main/java/cn/hippo4j/common/model/WebIpAndPortInfo.java diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/model/WebIpAndPortInfo.java b/hippo4j-common/src/main/java/cn/hippo4j/common/model/WebIpAndPortInfo.java new file mode 100644 index 00000000..a2dce703 --- /dev/null +++ b/hippo4j-common/src/main/java/cn/hippo4j/common/model/WebIpAndPortInfo.java @@ -0,0 +1,101 @@ +/* + * 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 cn.hippo4j.common.model; + +import lombok.Data; +import lombok.extern.slf4j.Slf4j; + +/** + * web ip and port info + */ +@Data +@Slf4j +public class WebIpAndPortInfo { + + protected static final String ALL = "*"; + protected static final String SPOT = "\\."; + protected static final String COLON = ":"; + private String ip; + private String port; + private String[] ipSegment; + + public WebIpAndPortInfo(String ip, String port) { + this.ip = ip; + this.port = port; + this.ipSegment = ip.split(SPOT); + } + + public static WebIpAndPortInfo build(String node) { + if (ALL.equals(node)) { + return new WebIpAndPortInfo(ALL, ALL); + } + String[] ipPort = node.split(COLON); + if (ipPort.length != 2) { + log.error("The IP address format is error : {}", node); + return null; + } + return new WebIpAndPortInfo(ipPort[0], ipPort[1]); + } + + /** + * check + * + * @param appIpSegment application ip segment + * @param port application port + */ + public boolean check(String[] appIpSegment, String port) { + return checkPort(port) && checkIp(appIpSegment); + } + + /** + * check ip + * + * @param appIpSegment application ip segment + */ + protected boolean checkIp(String[] appIpSegment) { + if (ALL.equals(this.ip)) { + return true; + } + boolean flag = true; + for (int i = 0; i < ipSegment.length && flag; i++) { + String propIp = ipSegment[i]; + String appIp = appIpSegment[i]; + flag = contrastSegment(appIp, propIp); + } + return flag; + } + + /** + * check port + * + * @param port application port + */ + protected boolean checkPort(String port) { + return contrastSegment(port, this.port); + } + + /** + * Check whether the strings are the same + * + * @param appIp appIp + * @param propIp propIp + */ + protected boolean contrastSegment(String appIp, String propIp) { + return ALL.equals(propIp) || appIp.equals(propIp); + } +} \ No newline at end of file diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AbstractRefreshListener.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AbstractRefreshListener.java index a42793a5..5a8c9468 100644 --- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AbstractRefreshListener.java +++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AbstractRefreshListener.java @@ -17,14 +17,14 @@ package cn.hippo4j.config.springboot.starter.refresher.event; +import cn.hippo4j.adapter.web.WebThreadPoolHandlerChoose; +import cn.hippo4j.adapter.web.WebThreadPoolService; import cn.hippo4j.common.config.ApplicationContextHolder; +import cn.hippo4j.common.model.WebIpAndPortInfo; import cn.hippo4j.common.toolkit.Assert; import cn.hippo4j.common.toolkit.StringUtil; import cn.hippo4j.core.toolkit.inet.InetUtils; -import lombok.Data; import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.web.context.WebServerInitializedEvent; -import org.springframework.context.event.EventListener; import java.util.Arrays; import java.util.Objects; @@ -36,33 +36,33 @@ import java.util.Objects; public abstract class AbstractRefreshListener implements RefreshListener { protected static final String ALL = "*"; - - protected static final String SPOT = "\\."; - protected static final String SEPARATOR = ","; - protected static final String COLON = ":"; - - /** - * application ip - */ - protected final String[] ipSegment; - /** - * application post + * application ip and application post */ - protected String port; + protected static volatile WebIpAndPortInfo webIpAndPort; + + protected void initIpAndPort() { + if (webIpAndPort == null) { + synchronized (AbstractRefreshListener.class) { + if (webIpAndPort == null) { + webIpAndPort = getWebIpAndPortInfo(); + } + } + } + } - AbstractRefreshListener() { + private WebIpAndPortInfo getWebIpAndPortInfo() { InetUtils inetUtils = ApplicationContextHolder.getBean(InetUtils.class); InetUtils.HostInfo loopBackHostInfo = inetUtils.findFirstNonLoopBackHostInfo(); Assert.notNull(loopBackHostInfo, "Unable to get the application IP address"); - ipSegment = loopBackHostInfo.getIpAddress().split(SPOT); - } - - @EventListener(WebServerInitializedEvent.class) - public void webServerInitializedListener(WebServerInitializedEvent event) { - port = String.valueOf(event.getWebServer().getPort()); + String ip = loopBackHostInfo.getIpAddress(); + WebThreadPoolHandlerChoose webThreadPoolHandlerChoose = ApplicationContextHolder.getBean(WebThreadPoolHandlerChoose.class); + WebThreadPoolService webThreadPoolService = webThreadPoolHandlerChoose.choose(); + // when get the port at startup, can get the message: "port xxx was already in use" or use two ports + String port = String.valueOf(webThreadPoolService.getWebServer().getPort()); + return new WebIpAndPortInfo(ip, port); } /** @@ -81,6 +81,9 @@ public abstract class AbstractRefreshListener implements RefreshListener implements RefreshListener i.check(ipSegment, port)); + .anyMatch(i -> i.check(webIpAndPort.getIpSegment(), webIpAndPort.getPort())); } /** @@ -103,79 +106,4 @@ public abstract class AbstractRefreshListener implements RefreshListener { if (Objects.equals(val.mark(), each.getMark())) { val.updateThreadPool(BeanUtil.toBean(each, ThreadPoolAdapterParameter.class)); From fc344994a2daa8e6a9e25d46e7af53cb3bc11c3f Mon Sep 17 00:00:00 2001 From: weihubeats Date: Tue, 6 Sep 2022 19:01:40 +0800 Subject: [PATCH 02/11] Support h2 database (#660) * Support h2 database * update application.properties --- hippo4j-config/pom.xml | 6 + .../src/main/resources/application.properties | 22 +- .../sql-script/h2/hippo4j_manager.sql | 234 ++++++++++++++++++ 3 files changed, 257 insertions(+), 5 deletions(-) create mode 100755 hippo4j-server/src/main/resources/sql-script/h2/hippo4j_manager.sql diff --git a/hippo4j-config/pom.xml b/hippo4j-config/pom.xml index a183212c..28ce448e 100644 --- a/hippo4j-config/pom.xml +++ b/hippo4j-config/pom.xml @@ -35,6 +35,12 @@ runtime + + com.h2database + h2 + runtime + + cn.hutool hutool-all diff --git a/hippo4j-server/src/main/resources/application.properties b/hippo4j-server/src/main/resources/application.properties index b8779e7c..7c71961b 100644 --- a/hippo4j-server/src/main/resources/application.properties +++ b/hippo4j-server/src/main/resources/application.properties @@ -5,6 +5,8 @@ ### Server Startup Port server.port=6691 +spring.profiles.active= h2 + ### Server Tomcat server.tomcat.accesslog.enabled=true server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i @@ -24,13 +26,9 @@ hippo4j.core.clean-history-data-enable=true # hippo4j.core.monitor.report-type=netty #*************** Config Module Related Configurations ***************# -### Data source customization section -spring.datasource.url=jdbc:mysql://localhost:3306/hippo4j_manager?characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 -spring.datasource.username=root -spring.datasource.password=root + ### Hikari Datasource -spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.hikari.pool-name=Hikari spring.datasource.hikari.connectionTimeout=30000 spring.datasource.hikari.idleTimeout=30000 @@ -47,3 +45,17 @@ mybatis-plus.global-config.banner=false mybatis-plus.global-config.db-config.logic-delete-field=delFlag mybatis-plus.global-config.db-config.logic-delete-value=1 mybatis-plus.global-config.db-config.logic-not-delete-value=0 + + +spring.profiles=mysql +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.url=jdbc:mysql://localhost:3306/hippo4j_manager?characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 +spring.datasource.username=root +spring.datasource.password=root +--- +spring.profiles=h2 +spring.datasource.driver-class-name=org.h2.Driver +spring.datasource.url=jdbc:h2:mem:hippo4j_manager;DB_CLOSE_DELAY=-1;MODE=MySQL; +spring.datasource.username=sa +spring.datasource.password=sa +spring.datasource.schema=classpath:sql-script/h2/hippo4j_manager.sql \ No newline at end of file diff --git a/hippo4j-server/src/main/resources/sql-script/h2/hippo4j_manager.sql b/hippo4j-server/src/main/resources/sql-script/h2/hippo4j_manager.sql new file mode 100755 index 00000000..02fbc4b4 --- /dev/null +++ b/hippo4j-server/src/main/resources/sql-script/h2/hippo4j_manager.sql @@ -0,0 +1,234 @@ + + +/******************************************/ +/* 数据库全名 = hippo4j_manager */ +/* 表名称 = tenant */ +/******************************************/ +DROP TABLE IF EXISTS `tenant`, `tenant_info`; +CREATE TABLE `tenant` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `tenant_id` varchar(128) DEFAULT NULL COMMENT '租户ID', + `tenant_name` varchar(128) DEFAULT NULL COMMENT '租户名称', + `tenant_desc` varchar(256) DEFAULT NULL COMMENT '租户介绍', + `owner` varchar(32) DEFAULT '-' COMMENT '负责人', + `gmt_create` datetime DEFAULT NULL COMMENT '创建时间', + `gmt_modified` datetime DEFAULT NULL COMMENT '修改时间', + `del_flag` tinyint(1) DEFAULT NULL COMMENT '是否删除', + PRIMARY KEY (`id`), + UNIQUE KEY `tenant_id` (`id`), + KEY `uk_tenantinfo_tenantid` (`tenant_id`,`del_flag`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='租户表'; + + +DROP TABLE IF EXISTS `item`, `item_info`; +CREATE TABLE `item` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `tenant_id` varchar(128) DEFAULT NULL COMMENT '租户ID', + `item_id` varchar(128) DEFAULT NULL COMMENT '项目ID', + `item_name` varchar(128) DEFAULT NULL COMMENT '项目名称', + `item_desc` varchar(256) DEFAULT NULL COMMENT '项目介绍', + `owner` varchar(32) DEFAULT NULL COMMENT '负责人', + `gmt_create` datetime DEFAULT NULL COMMENT '创建时间', + `gmt_modified` datetime DEFAULT NULL COMMENT '修改时间', + `del_flag` tinyint(1) DEFAULT NULL COMMENT '是否删除', + PRIMARY KEY (`id`), + UNIQUE KEY `item_id` (`id`), + UNIQUE KEY `item_uk_iteminfo_tenantitem` (`tenant_id`,`item_id`,`del_flag`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='项目表'; + +/******************************************/ +/* 数据库全名 = hippo4j_manager */ +/* 表名称 = config */ +/******************************************/ +DROP TABLE IF EXISTS `config`, `config_info`; +CREATE TABLE `config` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `tenant_id` varchar(128) DEFAULT NULL COMMENT '租户ID', + `item_id` varchar(256) DEFAULT NULL COMMENT '项目ID', + `tp_id` varchar(56) DEFAULT NULL COMMENT '线程池ID', + `tp_name` varchar(56) DEFAULT NULL COMMENT '线程池名称', + `core_size` int(11) DEFAULT NULL COMMENT '核心线程数', + `max_size` int(11) DEFAULT NULL COMMENT '最大线程数', + `queue_type` int(11) DEFAULT NULL COMMENT '队列类型...', + `capacity` int(11) DEFAULT NULL COMMENT '队列大小', + `rejected_type` int(11) DEFAULT NULL COMMENT '拒绝策略', + `keep_alive_time` int(11) DEFAULT NULL COMMENT '线程存活时间', + `allow_core_thread_time_out` tinyint(1) DEFAULT NULL COMMENT '允许核心线程超时', + `content` longtext COMMENT '线程池内容', + `md5` varchar(32) NOT NULL COMMENT 'MD5', + `is_alarm` tinyint(1) DEFAULT NULL COMMENT '是否报警', + `capacity_alarm` int(11) DEFAULT NULL COMMENT '容量报警', + `liveness_alarm` int(11) DEFAULT NULL COMMENT '活跃度报警', + `gmt_create` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `gmt_modified` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', + `del_flag` tinyint(1) DEFAULT NULL COMMENT '是否删除', + PRIMARY KEY (`id`), + UNIQUE KEY `config_id` (`id`), + UNIQUE KEY `config_uk_configinfo_datagrouptenant` (`tenant_id`,`item_id`,`tp_id`,`del_flag`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='线程池配置表'; + +/******************************************/ +/* 数据库全名 = hippo4j_manager */ +/* 表名称 = inst_config */ +/******************************************/ +DROP TABLE IF EXISTS `inst_config`; +CREATE TABLE `inst_config` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `tenant_id` varchar(128) DEFAULT NULL COMMENT '租户ID', + `item_id` varchar(256) DEFAULT NULL COMMENT '项目ID', + `tp_id` varchar(56) DEFAULT NULL COMMENT '线程池ID', + `instance_id` varchar(256) DEFAULT NULL COMMENT '实例ID', + `content` longtext COMMENT '线程池内容', + `md5` varchar(32) NOT NULL COMMENT 'MD5', + `gmt_create` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `gmt_modified` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + UNIQUE KEY `inst_config_id` (`id`), + KEY `idx_config_instance` (`tenant_id`,`item_id`,`tp_id`,`instance_id`) USING BTREE, + KEY `idx_instance` (`instance_id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='线程池配置实例表'; + +/******************************************/ +/* 数据库全名 = hippo4j_manager */ +/* 表名称 = his_run_data */ +/******************************************/ +DROP TABLE IF EXISTS `his_run_data`; +CREATE TABLE `his_run_data` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `tenant_id` varchar(128) DEFAULT NULL COMMENT '租户ID', + `item_id` varchar(256) DEFAULT NULL COMMENT '项目ID', + `tp_id` varchar(56) DEFAULT NULL COMMENT '线程池ID', + `instance_id` varchar(256) DEFAULT NULL COMMENT '实例ID', + `current_load` bigint(20) DEFAULT NULL COMMENT '当前负载', + `peak_load` bigint(20) DEFAULT NULL COMMENT '峰值负载', + `pool_size` bigint(20) DEFAULT NULL COMMENT '线程数', + `active_size` bigint(20) DEFAULT NULL COMMENT '活跃线程数', + `queue_capacity` bigint(20) DEFAULT NULL COMMENT '队列容量', + `queue_size` bigint(20) DEFAULT NULL COMMENT '队列元素', + `queue_remaining_capacity` bigint(20) DEFAULT NULL COMMENT '队列剩余容量', + `completed_task_count` bigint(20) DEFAULT NULL COMMENT '已完成任务计数', + `reject_count` bigint(20) DEFAULT NULL COMMENT '拒绝次数', + `timestamp` bigint(20) DEFAULT NULL COMMENT '时间戳', + `gmt_create` datetime DEFAULT NULL COMMENT '创建时间', + `gmt_modified` datetime DEFAULT NULL COMMENT '修改时间', + PRIMARY KEY (`id`), + KEY `idx_group_key` (`tenant_id`,`item_id`,`tp_id`,`instance_id`) USING BTREE, + KEY `idx_timestamp` (`timestamp`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='历史运行数据表'; + +/******************************************/ +/* 数据库全名 = hippo4j_manager */ +/* 表名称 = log_record_info */ +/******************************************/ +DROP TABLE IF EXISTS `log_record_info`; +CREATE TABLE `log_record_info` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `tenant` varchar(128) NOT NULL DEFAULT '' COMMENT '租户标识', + `biz_key` varchar(128) NOT NULL DEFAULT '' COMMENT '日志业务标识', + `biz_no` varchar(128) NOT NULL DEFAULT '' COMMENT '业务码标识', + `operator` varchar(64) NOT NULL DEFAULT '' COMMENT '操作人', + `action` varchar(128) NOT NULL DEFAULT '' COMMENT '动作', + `category` varchar(128) NOT NULL DEFAULT '' COMMENT '种类', + `detail` varchar(2048) NOT NULL DEFAULT '' COMMENT '修改的详细信息,可以为json', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + KEY `idx_biz_key` (`biz_key`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='操作日志表'; + +/******************************************/ +/* 数据库全名 = hippo4j_manager */ +/* 表名称 = user */ +/******************************************/ +DROP TABLE IF EXISTS `user`; +CREATE TABLE `user` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `user_name` varchar(64) NOT NULL COMMENT '用户名', + `password` varchar(512) NOT NULL COMMENT '用户密码', + `role` varchar(50) NOT NULL COMMENT '角色', + `gmt_create` datetime NOT NULL COMMENT '创建时间', + `gmt_modified` datetime NOT NULL COMMENT '修改时间', + `del_flag` tinyint(1) NOT NULL COMMENT '是否删除', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='用户表'; + +/******************************************/ +/* 数据库全名 = hippo4j_manager */ +/* 表名称 = role */ +/******************************************/ +DROP TABLE IF EXISTS `role`; +CREATE TABLE `role` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `role` varchar(64) NOT NULL COMMENT '角色', + `user_name` varchar(64) NOT NULL COMMENT '用户名', + `gmt_create` datetime NOT NULL COMMENT '创建时间', + `gmt_modified` datetime NOT NULL COMMENT '修改时间', + `del_flag` tinyint(1) NOT NULL COMMENT '是否删除', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='角色表'; + +/******************************************/ +/* 数据库全名 = hippo4j_manager */ +/* 表名称 = permission */ +/******************************************/ +DROP TABLE IF EXISTS `permission`; +CREATE TABLE `permission` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `role` varchar(512) NOT NULL COMMENT '角色', + `resource` varchar(512) NOT NULL COMMENT '资源', + `action` varchar(8) NOT NULL COMMENT '读写权限', + `gmt_create` datetime NOT NULL COMMENT '创建时间', + `gmt_modified` datetime NOT NULL COMMENT '修改时间', + `del_flag` tinyint(1) NOT NULL COMMENT '是否删除', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='权限表'; + +/******************************************/ +/* 数据库全名 = hippo4j_manager */ +/* 表名称 = notify */ +/******************************************/ +DROP TABLE IF EXISTS `alarm`, `notify`; +CREATE TABLE `notify` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `tenant_id` varchar(128) NOT NULL DEFAULT '' COMMENT '租户ID', + `item_id` varchar(128) NOT NULL COMMENT '项目ID', + `tp_id` varchar(128) NOT NULL COMMENT '线程池ID', + `platform` varchar(32) NOT NULL COMMENT '通知平台', + `type` varchar(32) NOT NULL COMMENT '通知类型', + `secret_key` varchar(256) NOT NULL COMMENT '密钥', + `interval` int(11) DEFAULT NULL COMMENT '报警间隔', + `receives` varchar(512) NOT NULL COMMENT '接收者', + `enable` tinyint(1) DEFAULT NULL COMMENT '是否启用', + `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', + `del_flag` tinyint(1) NOT NULL COMMENT '是否删除', + PRIMARY KEY (`id`), + UNIQUE KEY `notify_uk_notify_biz_key` (`tenant_id`,`item_id`,`tp_id`,`platform`,`type`,`del_flag`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='通知表'; + +/* 租户 */ +INSERT INTO `tenant` (`id`, `tenant_id`, `tenant_name`, `tenant_desc`, `owner`, `gmt_create`, `gmt_modified`, `del_flag`) VALUES ('1', 'prescription', '处方组', '负责维护处方服务, 包括不限于电子处方等业务', '谢良辰', '2021-10-24 13:42:11', '2021-10-24 13:42:11', '0'); + +/* 项目 */ +INSERT INTO `item` (`id`, `tenant_id`, `item_id`, `item_name`, `item_desc`, `owner`, `gmt_create`, `gmt_modified`, `del_flag`) VALUES ('1', 'prescription', 'dynamic-threadpool-example', '动态线程池示例项目', '动态线程池示例项目,对应 Hippo 项目的 example 模块', '马称', '2021-10-24 16:11:00', '2021-10-24 16:11:00', '0'); + +/* 线程池 */ +INSERT INTO `config` (`id`, `tenant_id`, `item_id`, `tp_id`, `tp_name`, `core_size`, `max_size`, `queue_type`, `capacity`, `rejected_type`, `keep_alive_time`, `allow_core_thread_time_out`, `content`, `md5`, `is_alarm`, `capacity_alarm`, `liveness_alarm`, `gmt_create`, `gmt_modified`, `del_flag`) VALUES ('1', 'prescription', 'dynamic-threadpool-example', 'message-consume', '示例消费者线程池', '5', '10', '9', '1024', '2', '9999', '0', '{\"tenantId\":\"prescription\",\"itemId\":\"dynamic-threadpool-example\",\"tpId\":\"message-consume\",\"coreSize\":5,\"maxSize\":10,\"queueType\":9,\"capacity\":1024,\"keepAliveTime\":9999,\"rejectedType\":2,\"isAlarm\":0,\"capacityAlarm\":80,\"livenessAlarm\":80,\"allowCoreThreadTimeOut\":0}', 'f80ea89044889fb6cec20e1a517f2ec3', '0', '80', '80', '2021-10-24 10:24:00', '2021-12-22 08:58:55', '0'), + ('2', 'prescription', 'dynamic-threadpool-example', 'message-produce', '示例生产者线程池', '5', '15', '9', '1024', '1', '9999', '0', '{\"tenantId\":\"prescription\",\"itemId\":\"dynamic-threadpool-example\",\"tpId\":\"message-produce\",\"coreSize\":5,\"maxSize\":15,\"queueType\":9,\"capacity\":1024,\"keepAliveTime\":9999,\"rejectedType\":1,\"isAlarm\":0,\"capacityAlarm\":30,\"livenessAlarm\":30,\"allowCoreThreadTimeOut\":0}', '525e1429468bcfe98df7e70a75710051', '0', '30', '30', '2021-10-24 10:24:00', '2021-12-22 08:59:02', '0'); + +/* 用户 */ +INSERT INTO `user` (`id`, `user_name`, `password`, `role`, `gmt_create`, `gmt_modified`, `del_flag`) VALUES ('1', 'admin', '$2a$10$2KCqRbra0Yn2TwvkZxtfLuWuUP5KyCWsljO/ci5pLD27pqR3TV1vy', 'ROLE_ADMIN', '2021-11-04 21:35:17', '2021-11-15 23:04:59', '0'); + +/* 通知表 */ +INSERT INTO `notify` (`id`, `tenant_id`, `item_id`, `tp_id`, `platform`, `type`, `secret_key`, `interval`, `receives`, `enable`, `gmt_create`, `gmt_modified`, `del_flag`) VALUES ('1', 'prescription', 'dynamic-threadpool-example', 'message-produce', 'DING', 'CONFIG', '4a582a588a161d6e3a1bd1de7eea9ee9f562cdfcbe56b6e72029e7fd512b2eae', NULL, '15601166691', '0', '2021-11-18 22:49:50', '2021-11-18 22:49:50', '0'), + ('2', 'prescription', 'dynamic-threadpool-example', 'message-produce', 'DING', 'ALARM', '4a582a588a161d6e3a1bd1de7eea9ee9f562cdfcbe56b6e72029e7fd512b2eae', '30', '15601166691', '0', '2021-11-18 22:50:06', '2021-11-18 22:50:06', '0'); + +/* 1.1.0 Upgrade Start */ +ALTER TABLE `config` DROP INDEX `config_uk_configinfo_datagrouptenant`; +ALTER TABLE `item` DROP INDEX `item_uk_iteminfo_tenantitem`; +ALTER TABLE `tenant` DROP INDEX `uk_tenantinfo_tenantid`; +/* 1.1.0 Upgrade End */ + +/* 1.4.0 Upgrade Start */ +ALTER TABLE config Modify COLUMN keep_alive_time int(11) COMMENT '线程存活时间(秒)'; +ALTER TABLE config Add execute_time_out int(11) COMMENT '执行超时时间(毫秒)' AFTER keep_alive_time; +/* 1.4.0 Upgrade Start */ \ No newline at end of file From 7f2dc4d4d0c1b94be9cce35c530d49d429f8ea7e Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Tue, 6 Sep 2022 19:04:43 +0800 Subject: [PATCH 03/11] Supplementary Links --- docs/docs/user_docs/intro.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/docs/user_docs/intro.md b/docs/docs/user_docs/intro.md index c2198e5f..51706c1b 100644 --- a/docs/docs/user_docs/intro.md +++ b/docs/docs/user_docs/intro.md @@ -56,6 +56,8 @@ Hippo-4J 获得了一些宝贵的荣誉,这属于每一位对 Hippo-4J 做出 ## 友情链接 +- [[ LiteFlow ]](https://liteflow.yomahub.com/):轻量,快速,稳定可编排的组件式规则引擎。 + - [[ Sa-Token ]](https://github.com/dromara/sa-token):一个轻量级 java 权限认证框架,让鉴权变得简单、优雅! - [[ HertzBeat ]](https://github.com/dromara/hertzbeat):易用友好的云监控系统, 无需 Agent, 强大自定义监控能力。 From 5636356cf43f5a7bd3ec47a614a08e270046a907 Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Tue, 6 Sep 2022 19:05:34 +0800 Subject: [PATCH 04/11] Change Quick Start Documentation --- docs/docs/user_docs/user_guide/quick-start.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/docs/user_docs/user_guide/quick-start.md b/docs/docs/user_docs/user_guide/quick-start.md index 1f769714..3843e19b 100644 --- a/docs/docs/user_docs/user_guide/quick-start.md +++ b/docs/docs/user_docs/user_guide/quick-start.md @@ -2,15 +2,10 @@ sidebar_position: 3 --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - # 快速开始 ## 服务启动 -MySQL 创建名为 `hippo4j_manager` 的数据库,字符集选择 `utf8mb4`,并导入 [Hippo4J 初始化 SQL 语句](https://github.com/longtai-cn/hippo4j/blob/develop/hippo4j-server/conf/hippo4j_manager.sql)。 - 使用 Docker 运行服务端,可以灵活定制相关参数。如果 MySQL 非 Docker 部署,`MYSQL_HOST` 需要使用本地 IP。 ```shell From 8661f91c9febfe79bc81d6c05e096c7a085ac25b Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Tue, 6 Sep 2022 20:34:31 +0800 Subject: [PATCH 05/11] The official website quickly starts to modify --- docs/docs/user_docs/user_guide/quick-start.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/docs/user_docs/user_guide/quick-start.md b/docs/docs/user_docs/user_guide/quick-start.md index 3843e19b..5663cd6e 100644 --- a/docs/docs/user_docs/user_guide/quick-start.md +++ b/docs/docs/user_docs/user_guide/quick-start.md @@ -6,6 +6,8 @@ sidebar_position: 3 ## 服务启动 +MySQL 数据库导入 [Hippo4J 初始化 SQL 语句](https://github.com/longtai-cn/hippo4j/blob/develop/hippo4j-server/conf/hippo4j_manager.sql)。 + 使用 Docker 运行服务端,可以灵活定制相关参数。如果 MySQL 非 Docker 部署,`MYSQL_HOST` 需要使用本地 IP。 ```shell From cf38295bfdfe40749e95a29de93af3f8d17dbfe6 Mon Sep 17 00:00:00 2001 From: weihubeats Date: Tue, 6 Sep 2022 21:03:48 +0800 Subject: [PATCH 06/11] Support h2 database (#665) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Support h2 database * update application.properties * Support h2 database * h2数据库 --- .../src/main/resources/application-h2.properties | 6 ++++++ .../main/resources/application-mysql.properties | 5 +++++ .../src/main/resources/application.properties | 16 +--------------- 3 files changed, 12 insertions(+), 15 deletions(-) create mode 100644 hippo4j-server/src/main/resources/application-h2.properties create mode 100644 hippo4j-server/src/main/resources/application-mysql.properties diff --git a/hippo4j-server/src/main/resources/application-h2.properties b/hippo4j-server/src/main/resources/application-h2.properties new file mode 100644 index 00000000..b2a1a3d0 --- /dev/null +++ b/hippo4j-server/src/main/resources/application-h2.properties @@ -0,0 +1,6 @@ +spring.datasource.driver-class-name=org.h2.Driver +spring.datasource.url=jdbc:h2:mem:hippo4j_manager;DB_CLOSE_DELAY=-1;MODE=MySQL; +spring.datasource.username=sa +spring.datasource.password=sa +spring.datasource.schema=classpath:sql-script/h2/hippo4j_manager.sql + diff --git a/hippo4j-server/src/main/resources/application-mysql.properties b/hippo4j-server/src/main/resources/application-mysql.properties new file mode 100644 index 00000000..d751e3f9 --- /dev/null +++ b/hippo4j-server/src/main/resources/application-mysql.properties @@ -0,0 +1,5 @@ +### Data source customization section +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.url=jdbc:mysql://localhost:3306/hippo4j_manager?characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 +spring.datasource.username=root +spring.datasource.password=123456 \ No newline at end of file diff --git a/hippo4j-server/src/main/resources/application.properties b/hippo4j-server/src/main/resources/application.properties index 7c71961b..cb1a4477 100644 --- a/hippo4j-server/src/main/resources/application.properties +++ b/hippo4j-server/src/main/resources/application.properties @@ -44,18 +44,4 @@ mybatis-plus.global-config.banner=false # mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl mybatis-plus.global-config.db-config.logic-delete-field=delFlag mybatis-plus.global-config.db-config.logic-delete-value=1 -mybatis-plus.global-config.db-config.logic-not-delete-value=0 - - -spring.profiles=mysql -spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -spring.datasource.url=jdbc:mysql://localhost:3306/hippo4j_manager?characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 -spring.datasource.username=root -spring.datasource.password=root ---- -spring.profiles=h2 -spring.datasource.driver-class-name=org.h2.Driver -spring.datasource.url=jdbc:h2:mem:hippo4j_manager;DB_CLOSE_DELAY=-1;MODE=MySQL; -spring.datasource.username=sa -spring.datasource.password=sa -spring.datasource.schema=classpath:sql-script/h2/hippo4j_manager.sql \ No newline at end of file +mybatis-plus.global-config.db-config.logic-not-delete-value=0 \ No newline at end of file From 9050aea3f9ee8c8586455980ef850ccc4ac2f3c8 Mon Sep 17 00:00:00 2001 From: weihubeats Date: Tue, 6 Sep 2022 21:22:22 +0800 Subject: [PATCH 07/11] default database mysql (#666) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Support h2 database * update application.properties * Support h2 database * h2数据库 * default database mysql --- hippo4j-server/src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hippo4j-server/src/main/resources/application.properties b/hippo4j-server/src/main/resources/application.properties index cb1a4477..2c32d489 100644 --- a/hippo4j-server/src/main/resources/application.properties +++ b/hippo4j-server/src/main/resources/application.properties @@ -5,7 +5,7 @@ ### Server Startup Port server.port=6691 -spring.profiles.active= h2 +spring.profiles.active= mysql ### Server Tomcat server.tomcat.accesslog.enabled=true From 2033f1da61395a041cd95dc41c0f6548e9c56ea9 Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Tue, 6 Sep 2022 21:25:40 +0800 Subject: [PATCH 08/11] Change configuration format --- .../src/main/resources/application-h2.properties | 2 +- .../src/main/resources/application-mysql.properties | 2 +- hippo4j-server/src/main/resources/application.properties | 7 ++----- .../src/main/resources/sql-script/h2/hippo4j_manager.sql | 9 +++++---- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/hippo4j-server/src/main/resources/application-h2.properties b/hippo4j-server/src/main/resources/application-h2.properties index b2a1a3d0..5859aa19 100644 --- a/hippo4j-server/src/main/resources/application-h2.properties +++ b/hippo4j-server/src/main/resources/application-h2.properties @@ -1,6 +1,6 @@ +### Default database spring.datasource.driver-class-name=org.h2.Driver spring.datasource.url=jdbc:h2:mem:hippo4j_manager;DB_CLOSE_DELAY=-1;MODE=MySQL; spring.datasource.username=sa spring.datasource.password=sa spring.datasource.schema=classpath:sql-script/h2/hippo4j_manager.sql - diff --git a/hippo4j-server/src/main/resources/application-mysql.properties b/hippo4j-server/src/main/resources/application-mysql.properties index d751e3f9..2940c413 100644 --- a/hippo4j-server/src/main/resources/application-mysql.properties +++ b/hippo4j-server/src/main/resources/application-mysql.properties @@ -2,4 +2,4 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/hippo4j_manager?characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 spring.datasource.username=root -spring.datasource.password=123456 \ No newline at end of file +spring.datasource.password=root diff --git a/hippo4j-server/src/main/resources/application.properties b/hippo4j-server/src/main/resources/application.properties index 2c32d489..69a499af 100644 --- a/hippo4j-server/src/main/resources/application.properties +++ b/hippo4j-server/src/main/resources/application.properties @@ -4,8 +4,7 @@ ### Server Startup Port server.port=6691 - -spring.profiles.active= mysql +spring.profiles.active=mysql ### Server Tomcat server.tomcat.accesslog.enabled=true @@ -26,8 +25,6 @@ hippo4j.core.clean-history-data-enable=true # hippo4j.core.monitor.report-type=netty #*************** Config Module Related Configurations ***************# - - ### Hikari Datasource spring.datasource.hikari.pool-name=Hikari spring.datasource.hikari.connectionTimeout=30000 @@ -44,4 +41,4 @@ mybatis-plus.global-config.banner=false # mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl mybatis-plus.global-config.db-config.logic-delete-field=delFlag mybatis-plus.global-config.db-config.logic-delete-value=1 -mybatis-plus.global-config.db-config.logic-not-delete-value=0 \ No newline at end of file +mybatis-plus.global-config.db-config.logic-not-delete-value=0 diff --git a/hippo4j-server/src/main/resources/sql-script/h2/hippo4j_manager.sql b/hippo4j-server/src/main/resources/sql-script/h2/hippo4j_manager.sql index 02fbc4b4..2768fe2b 100755 --- a/hippo4j-server/src/main/resources/sql-script/h2/hippo4j_manager.sql +++ b/hippo4j-server/src/main/resources/sql-script/h2/hippo4j_manager.sql @@ -1,5 +1,3 @@ - - /******************************************/ /* 数据库全名 = hippo4j_manager */ /* 表名称 = tenant */ @@ -19,7 +17,10 @@ CREATE TABLE `tenant` ( KEY `uk_tenantinfo_tenantid` (`tenant_id`,`del_flag`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='租户表'; - +/******************************************/ +/* 数据库全名 = hippo4j_manager */ +/* 表名称 = item */ +/******************************************/ DROP TABLE IF EXISTS `item`, `item_info`; CREATE TABLE `item` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID', @@ -231,4 +232,4 @@ ALTER TABLE `tenant` DROP INDEX `uk_tenantinfo_tenantid`; /* 1.4.0 Upgrade Start */ ALTER TABLE config Modify COLUMN keep_alive_time int(11) COMMENT '线程存活时间(秒)'; ALTER TABLE config Add execute_time_out int(11) COMMENT '执行超时时间(毫秒)' AFTER keep_alive_time; -/* 1.4.0 Upgrade Start */ \ No newline at end of file +/* 1.4.0 Upgrade Start */ From 60a135259619211c384e8ef792ba6fce0c270591 Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Tue, 6 Sep 2022 21:29:36 +0800 Subject: [PATCH 09/11] Delete extra blank lines --- .../example/config/nacos/ConfigNacosExampleApplication.java | 1 - 1 file changed, 1 deletion(-) diff --git a/hippo4j-example/hippo4j-config-nacos-spring-boot-starter-example/src/main/java/cn/hippo4j/example/config/nacos/ConfigNacosExampleApplication.java b/hippo4j-example/hippo4j-config-nacos-spring-boot-starter-example/src/main/java/cn/hippo4j/example/config/nacos/ConfigNacosExampleApplication.java index 76847c66..71cdaa6f 100644 --- a/hippo4j-example/hippo4j-config-nacos-spring-boot-starter-example/src/main/java/cn/hippo4j/example/config/nacos/ConfigNacosExampleApplication.java +++ b/hippo4j-example/hippo4j-config-nacos-spring-boot-starter-example/src/main/java/cn/hippo4j/example/config/nacos/ConfigNacosExampleApplication.java @@ -28,5 +28,4 @@ public class ConfigNacosExampleApplication { public static void main(String[] args) { SpringApplication.run(ConfigNacosExampleApplication.class, args); } - } From 8ee0e4edee55c5a03e4c0d9a228aa5907eda2631 Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Tue, 6 Sep 2022 21:36:47 +0800 Subject: [PATCH 10/11] Code formatting optimization --- .../cn/hippo4j/common/model/WebIpAndPortInfo.java | 15 ++++++++++----- .../refresher/event/AbstractRefreshListener.java | 10 +++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/model/WebIpAndPortInfo.java b/hippo4j-common/src/main/java/cn/hippo4j/common/model/WebIpAndPortInfo.java index a2dce703..b2b101c1 100644 --- a/hippo4j-common/src/main/java/cn/hippo4j/common/model/WebIpAndPortInfo.java +++ b/hippo4j-common/src/main/java/cn/hippo4j/common/model/WebIpAndPortInfo.java @@ -21,17 +21,22 @@ import lombok.Data; import lombok.extern.slf4j.Slf4j; /** - * web ip and port info + * Web ip and port info */ @Data @Slf4j public class WebIpAndPortInfo { protected static final String ALL = "*"; + protected static final String SPOT = "\\."; + protected static final String COLON = ":"; + private String ip; + private String port; + private String[] ipSegment; public WebIpAndPortInfo(String ip, String port) { @@ -53,7 +58,7 @@ public class WebIpAndPortInfo { } /** - * check + * Check. * * @param appIpSegment application ip segment * @param port application port @@ -63,7 +68,7 @@ public class WebIpAndPortInfo { } /** - * check ip + * Check ip. * * @param appIpSegment application ip segment */ @@ -81,7 +86,7 @@ public class WebIpAndPortInfo { } /** - * check port + * Check port. * * @param port application port */ @@ -90,7 +95,7 @@ public class WebIpAndPortInfo { } /** - * Check whether the strings are the same + * Check whether the strings are the same. * * @param appIp appIp * @param propIp propIp diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AbstractRefreshListener.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AbstractRefreshListener.java index 5a8c9468..a630db60 100644 --- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AbstractRefreshListener.java +++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AbstractRefreshListener.java @@ -36,10 +36,11 @@ import java.util.Objects; public abstract class AbstractRefreshListener implements RefreshListener { protected static final String ALL = "*"; + protected static final String SEPARATOR = ","; /** - * application ip and application post + * Application ip and application post */ protected static volatile WebIpAndPortInfo webIpAndPort; @@ -60,7 +61,7 @@ public abstract class AbstractRefreshListener implements RefreshListener implements RefreshListener i.check(webIpAndPort.getIpSegment(), webIpAndPort.getPort())); + .anyMatch(each -> each.check(webIpAndPort.getIpSegment(), webIpAndPort.getPort())); } /** - * get nodes in new properties + * Get nodes in new properties. * * @param properties new properties * @return nodes in properties @@ -105,5 +106,4 @@ public abstract class AbstractRefreshListener implements RefreshListener Date: Wed, 7 Sep 2022 08:47:04 +0800 Subject: [PATCH 11/11] h2 bug (#667) --- .../config/config/MybatisPlusConfig.java | 7 ++++- .../service/impl/DashboardServiceImpl.java | 31 ++++++++++++------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/config/MybatisPlusConfig.java b/hippo4j-config/src/main/java/cn/hippo4j/config/config/MybatisPlusConfig.java index 82455fdd..f339efde 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/config/MybatisPlusConfig.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/config/MybatisPlusConfig.java @@ -20,6 +20,8 @@ package cn.hippo4j.config.config; import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; + +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -28,11 +30,14 @@ import org.springframework.context.annotation.Configuration; */ @Configuration public class MybatisPlusConfig { + + @Value("${spring.profiles.active}") + private String profilesActive; @Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); - interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.getDbType(profilesActive))); return interceptor; } } diff --git a/hippo4j-console/src/main/java/cn/hippo4j/console/service/impl/DashboardServiceImpl.java b/hippo4j-console/src/main/java/cn/hippo4j/console/service/impl/DashboardServiceImpl.java index a721cabb..f2603a0c 100644 --- a/hippo4j-console/src/main/java/cn/hippo4j/console/service/impl/DashboardServiceImpl.java +++ b/hippo4j-console/src/main/java/cn/hippo4j/console/service/impl/DashboardServiceImpl.java @@ -17,6 +17,12 @@ package cn.hippo4j.console.service.impl; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import cn.hippo4j.common.enums.DelEnum; import cn.hippo4j.common.model.InstanceInfo; import cn.hippo4j.common.toolkit.GroupKey; @@ -24,9 +30,17 @@ import cn.hippo4j.config.mapper.ConfigInfoMapper; import cn.hippo4j.config.mapper.HisRunDataMapper; import cn.hippo4j.config.mapper.ItemInfoMapper; import cn.hippo4j.config.mapper.TenantInfoMapper; -import cn.hippo4j.config.model.*; +import cn.hippo4j.config.model.CacheItem; +import cn.hippo4j.config.model.ConfigAllInfo; +import cn.hippo4j.config.model.ConfigInfoBase; +import cn.hippo4j.config.model.ItemInfo; +import cn.hippo4j.config.model.TenantInfo; import cn.hippo4j.config.service.ConfigCacheService; -import cn.hippo4j.console.model.*; +import cn.hippo4j.console.model.ChartInfo; +import cn.hippo4j.console.model.LineChartInfo; +import cn.hippo4j.console.model.PieChartInfo; +import cn.hippo4j.console.model.RankingChart; +import cn.hippo4j.console.model.TenantChart; import cn.hippo4j.console.service.DashboardService; import cn.hippo4j.discovery.core.BaseInstanceRegistry; import cn.hippo4j.discovery.core.Lease; @@ -38,13 +52,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; import lombok.AllArgsConstructor; -import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; +import org.springframework.stereotype.Service; import static cn.hippo4j.common.toolkit.ContentUtil.getGroupKey; @@ -67,9 +76,9 @@ public class DashboardServiceImpl implements DashboardService { @Override public ChartInfo getChartInfo() { - Integer tenantCount = tenantInfoMapper.selectCount(Wrappers.lambdaQuery(TenantInfo.class).eq(TenantInfo::getDelFlag, DelEnum.NORMAL)); - Integer itemCount = itemInfoMapper.selectCount(Wrappers.lambdaQuery(ItemInfo.class).eq(ItemInfo::getDelFlag, DelEnum.NORMAL)); - Integer threadPoolCount = configInfoMapper.selectCount(Wrappers.lambdaQuery(ConfigAllInfo.class).eq(ConfigAllInfo::getDelFlag, DelEnum.NORMAL)); + Integer tenantCount = tenantInfoMapper.selectCount(Wrappers.lambdaQuery(TenantInfo.class).eq(TenantInfo::getDelFlag, DelEnum.NORMAL.getCode())); + Integer itemCount = itemInfoMapper.selectCount(Wrappers.lambdaQuery(ItemInfo.class).eq(ItemInfo::getDelFlag, DelEnum.NORMAL.getIntCode())); + Integer threadPoolCount = configInfoMapper.selectCount(Wrappers.lambdaQuery(ConfigAllInfo.class).eq(ConfigAllInfo::getDelFlag, DelEnum.NORMAL.getCode())); ChartInfo chartInfo = new ChartInfo(); chartInfo.setTenantCount(tenantCount) .setItemCount(itemCount)