hippo4j-config code naming and log optimization

pull/486/head
chen.ma 2 years ago
parent 676e0fe5ee
commit df628c5a8f

@ -28,9 +28,6 @@ import static cn.hippo4j.common.constant.Constants.AVAILABLE_PROCESSORS;
/** /**
* Common config. * Common config.
*
* @author chen.ma
* @date 2021/7/19 21:03
*/ */
@Configuration @Configuration
public class CommonConfig { public class CommonConfig {
@ -53,5 +50,4 @@ public class CommonConfig {
monitorThreadPool.setAwaitTerminationMillis(5000); monitorThreadPool.setAwaitTerminationMillis(5000);
return monitorThreadPool; return monitorThreadPool;
} }
} }

@ -27,9 +27,6 @@ import java.util.Date;
/** /**
* Meta object handler. * Meta object handler.
*
* @author chen.ma
* @date 2021/7/1 22:43
*/ */
@Slf4j @Slf4j
@Component @Component
@ -39,7 +36,6 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
public void insertFill(MetaObject metaObject) { public void insertFill(MetaObject metaObject) {
this.strictInsertFill(metaObject, "gmtCreate", Date.class, new Date()); this.strictInsertFill(metaObject, "gmtCreate", Date.class, new Date());
this.strictInsertFill(metaObject, "gmtModified", Date.class, new Date()); this.strictInsertFill(metaObject, "gmtModified", Date.class, new Date());
this.strictInsertFill(metaObject, "delFlag", Integer.class, DelEnum.NORMAL.getIntCode()); this.strictInsertFill(metaObject, "delFlag", Integer.class, DelEnum.NORMAL.getIntCode());
} }
@ -47,5 +43,4 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
public void updateFill(MetaObject metaObject) { public void updateFill(MetaObject metaObject) {
this.strictInsertFill(metaObject, "gmtModified", Date.class, new Date()); this.strictInsertFill(metaObject, "gmtModified", Date.class, new Date());
} }
} }

@ -25,9 +25,6 @@ import org.springframework.context.annotation.Configuration;
/** /**
* Mybatis plus config. * Mybatis plus config.
*
* @author chen.ma
* @date 2021/6/29 20:22
*/ */
@Configuration @Configuration
public class MybatisPlusConfig { public class MybatisPlusConfig {
@ -38,5 +35,4 @@ public class MybatisPlusConfig {
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor; return interceptor;
} }
} }

@ -25,6 +25,9 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
/**
* Netty server config.
*/
@Configuration @Configuration
@ConditionalOnProperty(name = "hippo4j.core.monitor.report-type", havingValue = "netty") @ConditionalOnProperty(name = "hippo4j.core.monitor.report-type", havingValue = "netty")
public class NettyServerConfig { public class NettyServerConfig {

@ -25,9 +25,6 @@ import org.springframework.context.annotation.Configuration;
/** /**
* Server bootstrap properties. * Server bootstrap properties.
*
* @author chen.ma
* @date 2021/12/22 08:01
*/ */
@Slf4j @Slf4j
@Getter @Getter
@ -48,5 +45,8 @@ public class ServerBootstrapProperties {
*/ */
private Integer cleanHistoryDataPeriod = 30; private Integer cleanHistoryDataPeriod = 30;
/**
* Netty server port.
*/
private String nettyServerPort = "8899"; private String nettyServerPort = "8899";
} }

@ -39,9 +39,6 @@ import java.util.Map;
/** /**
* Server configuration controller. * Server configuration controller.
*
* @author chen.ma
* @date 2021/6/20 13:53
*/ */
@RestController @RestController
@AllArgsConstructor @AllArgsConstructor
@ -53,8 +50,7 @@ public class ConfigController {
private final ConfigServletInner configServletInner; private final ConfigServletInner configServletInner;
@GetMapping @GetMapping
public Result<ConfigInfoBase> detailConfigInfo( public Result<ConfigInfoBase> detailConfigInfo(@RequestParam("tpId") String tpId,
@RequestParam("tpId") String tpId,
@RequestParam("itemId") String itemId, @RequestParam("itemId") String itemId,
@RequestParam("namespace") String namespace, @RequestParam("namespace") String namespace,
@RequestParam(value = "instanceId", required = false) String instanceId) { @RequestParam(value = "instanceId", required = false) String instanceId) {
@ -73,21 +69,17 @@ public class ConfigController {
@PostMapping("/listener") @PostMapping("/listener")
public void listener(HttpServletRequest request, HttpServletResponse response) { public void listener(HttpServletRequest request, HttpServletResponse response) {
request.setAttribute("org.apache.catalina.ASYNC_SUPPORTED", true); request.setAttribute("org.apache.catalina.ASYNC_SUPPORTED", true);
String probeModify = request.getParameter(Constants.LISTENING_CONFIGS); String probeModify = request.getParameter(Constants.LISTENING_CONFIGS);
if (StringUtils.isEmpty(probeModify)) { if (StringUtils.isEmpty(probeModify)) {
throw new IllegalArgumentException("invalid probeModify"); throw new IllegalArgumentException("invalid probeModify");
} }
probeModify = URLDecoder.decode(probeModify, Constants.ENCODE); probeModify = URLDecoder.decode(probeModify, Constants.ENCODE);
Map<String, String> clientMd5Map; Map<String, String> clientMd5Map;
try { try {
clientMd5Map = Md5ConfigUtil.getClientMd5Map(probeModify); clientMd5Map = Md5ConfigUtil.getClientMd5Map(probeModify);
} catch (Throwable e) { } catch (Throwable e) {
throw new IllegalArgumentException("invalid probeModify"); throw new IllegalArgumentException("invalid probeModify");
} }
configServletInner.doPollingConfig(request, response, clientMd5Map, probeModify.length()); configServletInner.doPollingConfig(request, response, clientMd5Map, probeModify.length());
} }
@ -97,8 +89,6 @@ public class ConfigController {
if (StrUtil.isNotBlank(groupKey)) { if (StrUtil.isNotBlank(groupKey)) {
ConfigCacheService.removeConfigCache(groupKey); ConfigCacheService.removeConfigCache(groupKey);
} }
return Results.success(); return Results.success();
} }
} }

@ -22,9 +22,6 @@ import java.util.concurrent.atomic.AtomicLong;
/** /**
* An abstract class for event. * An abstract class for event.
*
* @author chen.ma
* @date 2021/6/23 18:59
*/ */
public abstract class AbstractEvent implements Serializable { public abstract class AbstractEvent implements Serializable {
@ -40,5 +37,4 @@ public abstract class AbstractEvent implements Serializable {
public long sequence() { public long sequence() {
return sequence; return sequence;
} }
} }

@ -19,9 +19,6 @@ package cn.hippo4j.config.event;
/** /**
* Slow event. * Slow event.
*
* @author chen.ma
* @date 2021/6/23 19:05
*/ */
public abstract class AbstractSlowEvent extends AbstractEvent { public abstract class AbstractSlowEvent extends AbstractEvent {
@ -29,5 +26,4 @@ public abstract class AbstractSlowEvent extends AbstractEvent {
public long sequence() { public long sequence() {
return 0; return 0;
} }
} }

@ -21,9 +21,6 @@ import org.springframework.util.StringUtils;
/** /**
* Config data change event. * Config data change event.
*
* @author chen.ma
* @date 2021/6/24 23:35
*/ */
public class ConfigDataChangeEvent extends AbstractEvent { public class ConfigDataChangeEvent extends AbstractEvent {
@ -39,11 +36,9 @@ public class ConfigDataChangeEvent extends AbstractEvent {
if (StringUtils.isEmpty(tenantId) || StringUtils.isEmpty(itemId) || StringUtils.isEmpty(tpId)) { if (StringUtils.isEmpty(tenantId) || StringUtils.isEmpty(itemId) || StringUtils.isEmpty(tpId)) {
throw new IllegalArgumentException("DataId is null or group is null"); throw new IllegalArgumentException("DataId is null or group is null");
} }
this.tenantId = tenantId; this.tenantId = tenantId;
this.itemId = itemId; this.itemId = itemId;
this.tpId = tpId; this.tpId = tpId;
this.lastModifiedTs = gmtModified; this.lastModifiedTs = gmtModified;
} }
} }

@ -19,19 +19,16 @@ package cn.hippo4j.config.event;
/** /**
* Local data change event. * Local data change event.
*
* @author chen.ma
* @date 2021/6/23 19:13
*/ */
public class LocalDataChangeEvent extends AbstractEvent { public class LocalDataChangeEvent extends AbstractEvent {
/** /**
* ++线 * Tenant + Item + Thread-pool
*/ */
public final String groupKey; public final String groupKey;
/** /**
* * Client instance unique identifier
*/ */
public final String identify; public final String identify;
@ -39,5 +36,4 @@ public class LocalDataChangeEvent extends AbstractEvent {
this.identify = identify; this.identify = identify;
this.groupKey = groupKey; this.groupKey = groupKey;
} }
} }

@ -23,9 +23,6 @@ import org.apache.ibatis.annotations.Mapper;
/** /**
* Config info mapper. * Config info mapper.
*
* @author chen.ma
* @date 2021/6/29 22:44
*/ */
@Mapper @Mapper
public interface ConfigInfoMapper extends BaseMapper<ConfigAllInfo> { public interface ConfigInfoMapper extends BaseMapper<ConfigAllInfo> {

@ -23,9 +23,6 @@ import org.apache.ibatis.annotations.Mapper;
/** /**
* Config instance mapper. * Config instance mapper.
*
* @author chen.ma
* @date 2021/12/5 19:18
*/ */
@Mapper @Mapper
public interface ConfigInstanceMapper extends BaseMapper<ConfigInstanceInfo> { public interface ConfigInstanceMapper extends BaseMapper<ConfigInstanceInfo> {

@ -21,11 +21,7 @@ import org.apache.ibatis.annotations.Mapper;
/** /**
* Dashboard mapper. * Dashboard mapper.
*
* @author chen.ma
* @date 2021/12/11 15:16
*/ */
@Mapper @Mapper
public interface DashboardMapper { public interface DashboardMapper {
} }

@ -28,9 +28,6 @@ import java.util.List;
/** /**
* His run data mapper. * His run data mapper.
*
* @author chen.ma
* @date 2021/12/10 21:33
*/ */
@Mapper @Mapper
public interface HisRunDataMapper extends BaseMapper<HisRunDataInfo> { public interface HisRunDataMapper extends BaseMapper<HisRunDataInfo> {
@ -71,34 +68,33 @@ public interface HisRunDataMapper extends BaseMapper<HisRunDataInfo> {
class ThreadPoolTaskRanking { class ThreadPoolTaskRanking {
/** /**
* id * Tenant id
*/ */
private String tenantId; private String tenantId;
/** /**
* id * Item id
*/ */
private String itemId; private String itemId;
/** /**
* 线id * Tp id
*/ */
private String tpId; private String tpId;
/** /**
* * Max completed task count
*/ */
private Long maxCompletedTaskCount; private Long maxCompletedTaskCount;
/** /**
* * Max queue size
*/ */
private Long maxQueueSize; private Long maxQueueSize;
/** /**
* * Max reject count
*/ */
private Long maxRejectCount; private Long maxRejectCount;
} }
} }

@ -23,9 +23,6 @@ import org.apache.ibatis.annotations.Mapper;
/** /**
* Item info mapper. * Item info mapper.
*
* @author chen.ma
* @date 2021/6/29 21:53
*/ */
@Mapper @Mapper
public interface ItemInfoMapper extends BaseMapper<ItemInfo> { public interface ItemInfoMapper extends BaseMapper<ItemInfo> {

@ -23,9 +23,6 @@ import org.apache.ibatis.annotations.Mapper;
/** /**
* Notify info mapper. * Notify info mapper.
*
* @author chen.ma
* @date 2021/11/17 22:04
*/ */
@Mapper @Mapper
public interface NotifyInfoMapper extends BaseMapper<NotifyInfo> { public interface NotifyInfoMapper extends BaseMapper<NotifyInfo> {

@ -23,9 +23,6 @@ import org.apache.ibatis.annotations.Mapper;
/** /**
* Operation log mapper. * Operation log mapper.
*
* @author chen.ma
* @date 2021/10/24 21:01
*/ */
@Mapper @Mapper
public interface OperationLogMapper extends BaseMapper<LogRecordInfo> { public interface OperationLogMapper extends BaseMapper<LogRecordInfo> {

@ -23,9 +23,6 @@ import org.apache.ibatis.annotations.Mapper;
/** /**
* Tenant info mapper. * Tenant info mapper.
*
* @author chen.ma
* @date 2021/6/29 22:44
*/ */
@Mapper @Mapper
public interface TenantInfoMapper extends BaseMapper<TenantInfo> { public interface TenantInfoMapper extends BaseMapper<TenantInfo> {

@ -26,9 +26,6 @@ import lombok.Setter;
/** /**
* Cache item. * Cache item.
*
* @author chen.ma
* @date 2021/6/24 21:23
*/ */
@Getter @Getter
@Setter @Setter
@ -58,5 +55,4 @@ public class CacheItem {
this.md5 = Md5Util.getTpContentMd5(configAllInfo); this.md5 = Md5Util.getTpContentMd5(configAllInfo);
this.groupKey = SingletonRepository.DataIdGroupIdCache.getSingleton(groupKey); this.groupKey = SingletonRepository.DataIdGroupIdCache.getSingleton(groupKey);
} }
} }

@ -30,9 +30,6 @@ import java.util.Date;
/** /**
* Config all info. * Config all info.
*
* @author chen.ma
* @date 2021/6/20 15:14
*/ */
@Data @Data
@TableName("config") @TableName("config")
@ -73,5 +70,4 @@ public class ConfigAllInfo extends ConfigInfo implements ThreadPoolParameter {
public String toString() { public String toString() {
return JSONUtil.toJSONString(this); return JSONUtil.toJSONString(this);
} }
} }

@ -21,13 +21,9 @@ import lombok.Data;
/** /**
* Config info. * Config info.
*
* @author chen.ma
* @date 2021/6/20 15:59
*/ */
@Data @Data
public class ConfigInfo extends ConfigInfoBase { public class ConfigInfo extends ConfigInfoBase {
private static final long serialVersionUID = -3504960832191834675L; private static final long serialVersionUID = -3504960832191834675L;
} }

@ -26,9 +26,6 @@ import java.io.Serializable;
/** /**
* Config info base. * Config info base.
*
* @author chen.ma
* @date 2021/6/20 14:05
*/ */
@Data @Data
public class ConfigInfoBase implements Serializable { public class ConfigInfoBase implements Serializable {
@ -117,5 +114,4 @@ public class ConfigInfoBase implements Serializable {
*/ */
@JsonIgnore @JsonIgnore
private String content; private String content;
} }

@ -24,9 +24,6 @@ import java.util.Date;
/** /**
* Config instance info. * Config instance info.
*
* @author chen.ma
* @date 2021/12/5 19:19
*/ */
@Data @Data
@TableName("inst_config") @TableName("inst_config")
@ -73,5 +70,4 @@ public class ConfigInstanceInfo {
*/ */
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private Date gmtCreate; private Date gmtCreate;
} }

@ -24,9 +24,6 @@ import java.util.Date;
/** /**
* His run data info. * His run data info.
*
* @author chen.ma
* @date 2021/12/10 21:30
*/ */
@Data @Data
@TableName("his_run_data") @TableName("his_run_data")
@ -119,5 +116,4 @@ public class HisRunDataInfo {
*/ */
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT_UPDATE)
private Date gmtModified; private Date gmtModified;
} }

@ -24,9 +24,6 @@ import java.util.Date;
/** /**
* Item info. * Item info.
*
* @author chen.ma
* @date 2021/6/29 21:53
*/ */
@Data @Data
@TableName("item") @TableName("item")
@ -81,5 +78,4 @@ public class ItemInfo {
@TableLogic @TableLogic
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private Integer delFlag; private Integer delFlag;
} }

@ -23,10 +23,7 @@ import lombok.Data;
import java.util.Date; import java.util.Date;
/** /**
* . * Notify info.
*
* @author chen.ma
* @date 2021/11/17 22:03
*/ */
@Data @Data
@TableName("notify") @TableName("notify")
@ -101,5 +98,4 @@ public class NotifyInfo {
*/ */
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private Integer delFlag; private Integer delFlag;
} }

@ -24,9 +24,6 @@ import java.util.Date;
/** /**
* Tenant info. * Tenant info.
*
* @author chen.ma
* @date 2021/6/29 22:04
*/ */
@Data @Data
@TableName("tenant") @TableName("tenant")
@ -75,5 +72,4 @@ public class TenantInfo {
*/ */
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private Integer delFlag; private Integer delFlag;
} }

@ -22,9 +22,6 @@ import lombok.Data;
/** /**
* Item query req dto. * Item query req dto.
*
* @author chen.ma
* @date 2021/6/29 22:28
*/ */
@Data @Data
public class ItemQueryReqDTO extends Page { public class ItemQueryReqDTO extends Page {

@ -24,9 +24,6 @@ import java.util.Date;
/** /**
* Item resp dto. * Item resp dto.
*
* @author chen.ma
* @date 2021/6/29 21:15
*/ */
@Data @Data
public class ItemRespDTO { public class ItemRespDTO {
@ -37,38 +34,38 @@ public class ItemRespDTO {
private Integer id; private Integer id;
/** /**
* tenantId * Tenant id
*/ */
private String tenantId; private String tenantId;
/** /**
* itemId * Item id
*/ */
private String itemId; private String itemId;
/** /**
* itemName * Item name
*/ */
private String itemName; private String itemName;
/** /**
* itemDesc * Item desc
*/ */
private String itemDesc; private String itemDesc;
/** /**
* owner * Owner
*/ */
private String owner; private String owner;
/** /**
* gmtCreate * Gmt create
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtCreate; private Date gmtCreate;
/** /**
* gmtModified * Gmt modified
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtModified; private Date gmtModified;

@ -23,38 +23,34 @@ import javax.validation.constraints.Pattern;
/** /**
* Item save req dto. * Item save req dto.
*
* @author chen.ma
* @date 2021/6/29 22:05
*/ */
@Data @Data
public class ItemSaveReqDTO { public class ItemSaveReqDTO {
/** /**
* tenantId * Tenant id
*/ */
@Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号") @Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号")
private String tenantId; private String tenantId;
/** /**
* itemId * Item id
*/ */
@Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号") @Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号")
private String itemId; private String itemId;
/** /**
* itemName * Item name
*/ */
private String itemName; private String itemName;
/** /**
* itemDesc * Item desc
*/ */
private String itemDesc; private String itemDesc;
/** /**
* owner * Owner
*/ */
private String owner; private String owner;
} }

@ -21,9 +21,6 @@ import lombok.Data;
/** /**
* Item update req dto. * Item update req dto.
*
* @author chen.ma
* @date 2021/6/29 22:05
*/ */
@Data @Data
public class ItemUpdateReqDTO { public class ItemUpdateReqDTO {
@ -37,5 +34,4 @@ public class ItemUpdateReqDTO {
private String itemDesc; private String itemDesc;
private String owner; private String owner;
} }

@ -22,26 +22,22 @@ import lombok.Data;
/** /**
* . * .
*
* @author chen.ma
* @date 2021/11/17 21:43
*/ */
@Data @Data
public class LogRecordQueryReqDTO extends Page { public class LogRecordQueryReqDTO extends Page {
/** /**
* * Biz no
*/ */
private String bizNo; private String bizNo;
/** /**
* * Category
*/ */
private String category; private String category;
/** /**
* * Operator
*/ */
private String operator; private String operator;
} }

@ -23,36 +23,33 @@ import lombok.Data;
import java.util.Date; import java.util.Date;
/** /**
* . * Log record resp DTO.
*
* @author chen.ma
* @date 2021/11/17 21:37
*/ */
@Data @Data
public class LogRecordRespDTO { public class LogRecordRespDTO {
/** /**
* * Biz no
*/ */
private String bizNo; private String bizNo;
/** /**
* * Action
*/ */
private String action; private String action;
/** /**
* * Operator
*/ */
private String operator; private String operator;
/** /**
* * Category
*/ */
private String category; private String category;
/** /**
* gmtCreate * Gmt create
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime; private Date createTime;

@ -25,9 +25,6 @@ import java.util.List;
/** /**
* Monitor active resp dto. * Monitor active resp dto.
*
* @author chen.ma
* @date 2021/12/12 17:18
*/ */
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@ -35,48 +32,47 @@ import java.util.List;
public class MonitorActiveRespDTO { public class MonitorActiveRespDTO {
/** /**
* times * Times
*/ */
private List<String> times; private List<String> times;
/** /**
* poolSizeList * Pool size list
*/ */
private List<Long> poolSizeList; private List<Long> poolSizeList;
/** /**
* activeSizeList * Active size list
*/ */
private List<Long> activeSizeList; private List<Long> activeSizeList;
/** /**
* queueSizeList * Queue size list
*/ */
private List<Long> queueSizeList; private List<Long> queueSizeList;
/** /**
* completedTaskCountList * Completed task count list
*/ */
private List<Long> completedTaskCountList; private List<Long> completedTaskCountList;
/** /**
* rejectCountList * Reject count list
*/ */
private List<Long> rejectCountList; private List<Long> rejectCountList;
/** /**
* queueRemainingCapacityList * Queue remaining capacity list
*/ */
private List<Long> queueRemainingCapacityList; private List<Long> queueRemainingCapacityList;
/** /**
* currentLoadList * Current load list
*/ */
private List<Long> currentLoadList; private List<Long> currentLoadList;
/** /**
* queueCapacityList * Queue capacity list
*/ */
private List<Long> queueCapacityList; private List<Long> queueCapacityList;
} }

@ -20,32 +20,28 @@ package cn.hippo4j.config.model.biz.monitor;
import lombok.Data; import lombok.Data;
/** /**
* Monitor query req dto. * Monitor query req DTO.
*
* @author chen.ma
* @date 2021/12/10 20:18
*/ */
@Data @Data
public class MonitorQueryReqDTO { public class MonitorQueryReqDTO {
/** /**
* id * Tenant id
*/ */
private String tenantId; private String tenantId;
/** /**
* id * Item id
*/ */
private String itemId; private String itemId;
/** /**
* 线id * Thread-pool id
*/ */
private String tpId; private String tpId;
/** /**
* id * Instance id
*/ */
private String instanceId; private String instanceId;
} }

@ -20,77 +20,73 @@ package cn.hippo4j.config.model.biz.monitor;
import lombok.Data; import lombok.Data;
/** /**
* Monitor resp dto. * Monitor resp DTO.
*
* @author chen.ma
* @date 2021/12/10 20:23
*/ */
@Data @Data
public class MonitorRespDTO { public class MonitorRespDTO {
/** /**
* id * Tenant id
*/ */
private String tenantId; private String tenantId;
/** /**
* id * Item id
*/ */
private String itemId; private String itemId;
/** /**
* id * Instance id
*/ */
private String instanceId; private String instanceId;
/** /**
* * Completed task count
*/ */
private String completedTaskCount; private String completedTaskCount;
/** /**
* 线id * Thread-pool id
*/ */
private String tpId; private String tpId;
/** /**
* * Current load
*/ */
private String currentLoad; private String currentLoad;
/** /**
* * Peak load
*/ */
private String peakLoad; private String peakLoad;
/** /**
* 线 * Pool size
*/ */
private String poolSize; private String poolSize;
/** /**
* 线 * Active size
*/ */
private String activeSize; private String activeSize;
/** /**
* * Queue capacity
*/ */
private String queueCapacity; private String queueCapacity;
/** /**
* * Queue size
*/ */
private String queueSize; private String queueSize;
/** /**
* * Queue remaining capacity
*/ */
private String queueRemainingCapacity; private String queueRemainingCapacity;
/** /**
* * Reject count
*/ */
private String rejectCount; private String rejectCount;
} }

@ -25,22 +25,18 @@ import java.util.List;
/** /**
* Notify list resp dto. * Notify list resp dto.
*
* @author chen.ma
* @date 2021/11/17 22:53
*/ */
@Data @Data
@AllArgsConstructor @AllArgsConstructor
public class NotifyListRespDTO { public class NotifyListRespDTO {
/** /**
* Key * Notify key
*/ */
private String notifyKey; private String notifyKey;
/** /**
* * Notify list
*/ */
private List<NotifyInfo> notifyList; private List<NotifyInfo> notifyList;
} }

@ -23,32 +23,28 @@ import lombok.Data;
import java.util.List; import java.util.List;
/** /**
* Notify query req dto. * Notify query req DTO.
*
* @author chen.ma
* @date 2021/11/17 22:52
*/ */
@Data @Data
public class NotifyQueryReqDTO extends Page { public class NotifyQueryReqDTO extends Page {
/** /**
* groupKeys * Group keys
*/ */
private List<String> groupKeys; private List<String> groupKeys;
/** /**
* id * Tenant id
*/ */
private String tenantId; private String tenantId;
/** /**
* id * Item id
*/ */
private String itemId; private String itemId;
/** /**
* 线id * Thread-pool id
*/ */
private String tpId; private String tpId;
} }

@ -20,7 +20,7 @@ package cn.hippo4j.config.model.biz.notify;
import lombok.Data; import lombok.Data;
/** /**
* . * Notify req DTO.
* *
* @author chen.ma * @author chen.ma
* @date 2021/11/18 20:15 * @date 2021/11/18 20:15
@ -29,63 +29,62 @@ import lombok.Data;
public class NotifyReqDTO { public class NotifyReqDTO {
/** /**
* id * ID
*/ */
private String id; private String id;
/** /**
* ids * Ids
*/ */
private String ids; private String ids;
/** /**
* id * Tenant id
*/ */
private String tenantId; private String tenantId;
/** /**
* id * Item id
*/ */
private String itemId; private String itemId;
/** /**
* 线id * Thread-pool id
*/ */
private String tpId; private String tpId;
/** /**
* * Platform
*/ */
private String platform; private String platform;
/** /**
* * Config type
*/ */
private Boolean configType; private Boolean configType;
/** /**
* * Alarm type
*/ */
private Boolean alarmType; private Boolean alarmType;
/** /**
* * Secret key
*/ */
private String secretKey; private String secretKey;
/** /**
* * Interval
*/ */
private Integer interval; private Integer interval;
/** /**
* * Receives
*/ */
private String receives; private String receives;
/** /**
* * Enable
*/ */
private Integer enable; private Integer enable;
} }

@ -23,87 +23,84 @@ import lombok.Data;
import java.util.Date; import java.util.Date;
/** /**
* . * Notify resp DTO.
*
* @author chen.ma
* @date 2021/11/18 20:07
*/ */
@Data @Data
public class NotifyRespDTO { public class NotifyRespDTO {
/** /**
* id * ID
*/ */
private String id; private String id;
/** /**
* ids * Ids
*/ */
private String ids; private String ids;
/** /**
* id * Tenant id
*/ */
private String tenantId; private String tenantId;
/** /**
* id * Item id
*/ */
private String itemId; private String itemId;
/** /**
* 线id * Thread-pool id
*/ */
private String tpId; private String tpId;
/** /**
* * Platform
*/ */
private String platform; private String platform;
/** /**
* * Type
*/ */
private String type; private String type;
/** /**
* * Config type
*/ */
private Boolean configType; private Boolean configType;
/** /**
* * Alarm type
*/ */
private Boolean alarmType; private Boolean alarmType;
/** /**
* * Secret key
*/ */
private String secretKey; private String secretKey;
/** /**
* * Interval
*/ */
private Integer interval; private Integer interval;
/** /**
* * Receives
*/ */
private String receives; private String receives;
/** /**
* * Enable
*/ */
private Integer enable; private Integer enable;
/** /**
* * gmtCreate
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtCreate; private Date gmtCreate;
/** /**
* * gmtModified
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtModified; private Date gmtModified;

@ -21,10 +21,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data; import lombok.Data;
/** /**
* Tenant query req dto. * Tenant query req DTO.
*
* @author chen.ma
* @date 2021/6/29 22:28
*/ */
@Data @Data
public class TenantQueryReqDTO extends Page { public class TenantQueryReqDTO extends Page {

@ -23,10 +23,7 @@ import lombok.Data;
import java.util.Date; import java.util.Date;
/** /**
* Tenant resp dto. * Tenant resp DTO.
*
* @author chen.ma
* @date 2021/6/29 21:16
*/ */
@Data @Data
public class TenantRespDTO { public class TenantRespDTO {
@ -37,33 +34,33 @@ public class TenantRespDTO {
private Integer id; private Integer id;
/** /**
* tenantId * Tenant id
*/ */
private String tenantId; private String tenantId;
/** /**
* tenantName * Tenant name
*/ */
private String tenantName; private String tenantName;
/** /**
* tenantDesc * Tenant desc
*/ */
private String tenantDesc; private String tenantDesc;
/** /**
* owner * Owner
*/ */
private String owner; private String owner;
/** /**
* gmtCreate * Gmt create
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtCreate; private Date gmtCreate;
/** /**
* gmtModified * Gmt modified
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtModified; private Date gmtModified;

@ -22,34 +22,30 @@ import lombok.Data;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
/** /**
* Tenant save req dto. * Tenant save req DTO.
*
* @author chen.ma
* @date 2021/6/29 20:40
*/ */
@Data @Data
public class TenantSaveReqDTO { public class TenantSaveReqDTO {
/** /**
* tenantId * Tenant id
*/ */
@Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号") @Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号")
private String tenantId; private String tenantId;
/** /**
* tenantName * Tenant mame
*/ */
@Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号") @Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号")
private String tenantName; private String tenantName;
/** /**
* tenantDesc * Tenant desc
*/ */
private String tenantDesc; private String tenantDesc;
/** /**
* owner * Owner
*/ */
private String owner; private String owner;
} }

@ -21,36 +21,33 @@ import cn.hippo4j.common.toolkit.JSONUtil;
import lombok.Data; import lombok.Data;
/** /**
* Tenant save req dto. * Tenant save req DTO.
*
* @author chen.ma
* @date 2021/6/29 20:40
*/ */
@Data @Data
public class TenantUpdateReqDTO { public class TenantUpdateReqDTO {
/** /**
* id * ID
*/ */
private Long id; private Long id;
/** /**
* tenantId * Tenant id
*/ */
private String tenantId; private String tenantId;
/** /**
* tenantName * Tenant name
*/ */
private String tenantName; private String tenantName;
/** /**
* tenantDesc * Tenant desc
*/ */
private String tenantDesc; private String tenantDesc;
/** /**
* owner * Owner
*/ */
private String owner; private String owner;
@ -58,5 +55,4 @@ public class TenantUpdateReqDTO {
public String toString() { public String toString() {
return JSONUtil.toJSONString(this); return JSONUtil.toJSONString(this);
} }
} }

@ -21,26 +21,22 @@ import lombok.Data;
/** /**
* ThreadPool del req dto. * ThreadPool del req dto.
*
* @author chen.ma
* @date 2021/11/11 21:40
*/ */
@Data @Data
public class ThreadPoolDelReqDTO { public class ThreadPoolDelReqDTO {
/** /**
* tenantId * Tenant id
*/ */
private String tenantId; private String tenantId;
/** /**
* itemId * Item id
*/ */
private String itemId; private String itemId;
/** /**
* tpId * Thread-pool id
*/ */
private String tpId; private String tpId;
} }

@ -22,9 +22,6 @@ import lombok.Data;
/** /**
* Thread pool query req DTO. * Thread pool query req DTO.
*
* @author chen.ma
* @date 2021/6/30 21:22
*/ */
@Data @Data
public class ThreadPoolQueryReqDTO extends Page { public class ThreadPoolQueryReqDTO extends Page {

@ -23,97 +23,94 @@ import lombok.Data;
import java.util.Date; import java.util.Date;
/** /**
* Thread pool resp dto. * Thread pool resp DTO.
*
* @author chen.ma
* @date 2021/6/30 21:23
*/ */
@Data @Data
public class ThreadPoolRespDTO { public class ThreadPoolRespDTO {
/** /**
* id * ID
*/ */
private String id; private String id;
/** /**
* tenantId * Tenant id
*/ */
private String tenantId; private String tenantId;
/** /**
* itemId * Iem id
*/ */
private String itemId; private String itemId;
/** /**
* tpId * Thread-pool id
*/ */
private String tpId; private String tpId;
/** /**
* coreSize * Core size
*/ */
private Integer coreSize; private Integer coreSize;
/** /**
* maxSize * Max size
*/ */
private Integer maxSize; private Integer maxSize;
/** /**
* queueType * Queue type
*/ */
private Integer queueType; private Integer queueType;
/** /**
* queueName * Queue name
*/ */
private String queueName; private String queueName;
/** /**
* capacity * Capacity
*/ */
private Integer capacity; private Integer capacity;
/** /**
* keepAliveTime * Keep alive time
*/ */
private Integer keepAliveTime; private Integer keepAliveTime;
/** /**
* isAlarm * Is alarm
*/ */
private Integer isAlarm; private Integer isAlarm;
/** /**
* capacityAlarm * Capacity alarm
*/ */
private Integer capacityAlarm; private Integer capacityAlarm;
/** /**
* livenessAlarm * Liveness alarm
*/ */
private Integer livenessAlarm; private Integer livenessAlarm;
/** /**
* rejectedType * Rejected type
*/ */
private Integer rejectedType; private Integer rejectedType;
/** /**
* allowCoreThreadTimeOut * AllowCore thread timeout
*/ */
private Integer allowCoreThreadTimeOut; private Integer allowCoreThreadTimeOut;
/** /**
* gmtCreate * Gmt create
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtCreate; private Date gmtCreate;
/** /**
* gmtModified * Gmt modified
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtModified; private Date gmtModified;

@ -22,80 +22,76 @@ import lombok.Data;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
/** /**
* Thread pool save or update req dto. * Thread pool save or update req DTO.
*
* @author chen.ma
* @date 2021/6/30 21:23
*/ */
@Data @Data
public class ThreadPoolSaveOrUpdateReqDTO { public class ThreadPoolSaveOrUpdateReqDTO {
/** /**
* tenantId * TenantId
*/ */
@Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号") @Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号")
private String tenantId; private String tenantId;
/** /**
* TpId * Thread-pool id
*/ */
@Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号") @Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号")
private String tpId; private String tpId;
/** /**
* ItemId * Item id
*/ */
@Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号") @Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号")
private String itemId; private String itemId;
/** /**
* coreSize * Core size
*/ */
private Integer coreSize; private Integer coreSize;
/** /**
* maxSize * Max size
*/ */
private Integer maxSize; private Integer maxSize;
/** /**
* queueType * Queue type
*/ */
private Integer queueType; private Integer queueType;
/** /**
* capacity * Capacity
*/ */
private Integer capacity; private Integer capacity;
/** /**
* keepAliveTime * Keep alive time
*/ */
private Integer keepAliveTime; private Integer keepAliveTime;
/** /**
* isAlarm * Is alarm
*/ */
private Integer isAlarm; private Integer isAlarm;
/** /**
* capacityAlarm * Capacity alarm
*/ */
private Integer capacityAlarm; private Integer capacityAlarm;
/** /**
* livenessAlarm * Liveness alarm
*/ */
private Integer livenessAlarm; private Integer livenessAlarm;
/** /**
* rejectedType * Rejected type
*/ */
private Integer rejectedType; private Integer rejectedType;
/** /**
* allowCoreThreadTimeOut * Allow core thread timeout
*/ */
private Integer allowCoreThreadTimeOut; private Integer allowCoreThreadTimeOut;
} }

@ -21,9 +21,6 @@ import cn.hippo4j.common.monitor.Message;
/** /**
* Abstract monitor data execute strategy. * Abstract monitor data execute strategy.
*
* @author chen.ma
* @date 2021/12/10 20:14
*/ */
public abstract class AbstractMonitorDataExecuteStrategy<T extends Message> { public abstract class AbstractMonitorDataExecuteStrategy<T extends Message> {
@ -40,5 +37,4 @@ public abstract class AbstractMonitorDataExecuteStrategy<T extends Message> {
* @param message * @param message
*/ */
public abstract void execute(T message); public abstract void execute(T message);
} }

@ -24,9 +24,6 @@ import org.springframework.stereotype.Component;
/** /**
* Default monitor data resolver. * Default monitor data resolver.
*
* @author chen.ma
* @date 2021/12/10 21:47
*/ */
@Slf4j @Slf4j
@Component @Component
@ -41,5 +38,4 @@ public class DefaultMonitorDataResolver extends AbstractMonitorDataExecuteStrate
public void execute(Message message) { public void execute(Message message) {
log.warn("There is no suitable monitoring data storage actuator."); log.warn("There is no suitable monitoring data storage actuator.");
} }
} }

@ -28,9 +28,6 @@ import java.util.Map;
/** /**
* Query monitor execute choose. * Query monitor execute choose.
*
* @author chen.ma
* @date 2021/12/10 20:12
*/ */
@Component @Component
public class QueryMonitorExecuteChoose implements CommandLineRunner { public class QueryMonitorExecuteChoose implements CommandLineRunner {
@ -79,8 +76,6 @@ public class QueryMonitorExecuteChoose implements CommandLineRunner {
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
Map<String, AbstractMonitorDataExecuteStrategy> monitorDataExecuteStrategyMap = Map<String, AbstractMonitorDataExecuteStrategy> monitorDataExecuteStrategyMap =
ApplicationContextHolder.getBeansOfType(AbstractMonitorDataExecuteStrategy.class); ApplicationContextHolder.getBeansOfType(AbstractMonitorDataExecuteStrategy.class);
monitorDataExecuteStrategyMap.values().forEach(each -> monitorDataExecuteStrategyChooseMap.put(each.mark(), each)); monitorDataExecuteStrategyMap.values().forEach(each -> monitorDataExecuteStrategyChooseMap.put(each.mark(), each));
} }
} }

@ -26,9 +26,6 @@ import org.springframework.stereotype.Component;
/** /**
* Runtime data resolver. * Runtime data resolver.
*
* @author chen.ma
* @date 2021/12/10 20:18
*/ */
@Slf4j @Slf4j
@Component @Component
@ -46,5 +43,4 @@ public class RuntimeDataResolver extends AbstractMonitorDataExecuteStrategy<Runt
public void execute(RuntimeMessage message) { public void execute(RuntimeMessage message) {
hisRunDataService.save(message); hisRunDataService.save(message);
} }
} }

@ -38,9 +38,6 @@ import static cn.hippo4j.common.constant.Constants.DEFAULT_GROUP;
/** /**
* Regularly clean up the historical running data of thread pool. * Regularly clean up the historical running data of thread pool.
*
* @author chen.ma
* @date 2021/12/17 20:13
*/ */
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
@ -58,10 +55,8 @@ public class TimeCleanHistoryDataTask implements Runnable, InitializingBean {
public void run() { public void run() {
Date currentDate = new Date(); Date currentDate = new Date();
DateTime offsetMinuteDateTime = DateUtil.offsetMinute(currentDate, -properties.getCleanHistoryDataPeriod()); DateTime offsetMinuteDateTime = DateUtil.offsetMinute(currentDate, -properties.getCleanHistoryDataPeriod());
LambdaQueryWrapper<HisRunDataInfo> queryWrapper = Wrappers.lambdaQuery(HisRunDataInfo.class) LambdaQueryWrapper<HisRunDataInfo> queryWrapper = Wrappers.lambdaQuery(HisRunDataInfo.class)
.le(HisRunDataInfo::getTimestamp, offsetMinuteDateTime.getTime()); .le(HisRunDataInfo::getTimestamp, offsetMinuteDateTime.getTime());
hisRunDataService.remove(queryWrapper); hisRunDataService.remove(queryWrapper);
} }
@ -73,5 +68,4 @@ public class TimeCleanHistoryDataTask implements Runnable, InitializingBean {
cleanHistoryDataExecutor.scheduleWithFixedDelay(this, 0, 1, TimeUnit.MINUTES); cleanHistoryDataExecutor.scheduleWithFixedDelay(this, 0, 1, TimeUnit.MINUTES);
} }
} }
} }

@ -18,14 +18,12 @@
package cn.hippo4j.config.netty; package cn.hippo4j.config.netty;
import cn.hippo4j.config.config.ServerBootstrapProperties; import cn.hippo4j.config.config.ServerBootstrapProperties;
import cn.hippo4j.config.monitor.QueryMonitorExecuteChoose;
import cn.hippo4j.config.service.biz.HisRunDataService; import cn.hippo4j.config.service.biz.HisRunDataService;
import io.netty.bootstrap.ServerBootstrap; import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoopGroup; import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.codec.serialization.ClassResolvers; import io.netty.handler.codec.serialization.ClassResolvers;
@ -35,18 +33,12 @@ import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler; import io.netty.handler.logging.LoggingHandler;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import java.util.concurrent.ThreadPoolExecutor;
/** /**
* Netty MonitorNettyServer * Netty monitor netty server.
*
* @author lk
* @date 2022/06/18
*/ */
@Slf4j @Slf4j
@AllArgsConstructor @AllArgsConstructor
@ -68,8 +60,8 @@ public class MonitorNettyServer {
serverBootstrap.group(bossGroup, workGroup) serverBootstrap.group(bossGroup, workGroup)
.channel(NioServerSocketChannel.class) .channel(NioServerSocketChannel.class)
.handler(new LoggingHandler(LogLevel.INFO)) .handler(new LoggingHandler(LogLevel.INFO))
// BossGroup the Thread group is responsible for connection events // BossGroup the Thread group is responsible for connection events.
// WorkGroup the thread group is responsible for read and write events // WorkGroup the thread group is responsible for read and write events.
.childHandler(new ChannelInitializer<SocketChannel>() { .childHandler(new ChannelInitializer<SocketChannel>() {
@Override @Override

@ -17,22 +17,15 @@
package cn.hippo4j.config.netty; package cn.hippo4j.config.netty;
import cn.hippo4j.common.monitor.Message;
import cn.hippo4j.common.monitor.MessageWrapper; import cn.hippo4j.common.monitor.MessageWrapper;
import cn.hippo4j.common.toolkit.MessageConvert;
import cn.hippo4j.config.monitor.QueryMonitorExecuteChoose;
import cn.hippo4j.config.service.biz.HisRunDataService; import cn.hippo4j.config.service.biz.HisRunDataService;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler; import io.netty.channel.SimpleChannelInboundHandler;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
/** /**
* ServerHandler * Server handler.
*
* @author lk
* @date 2022/06/18
*/ */
@Slf4j @Slf4j
@AllArgsConstructor @AllArgsConstructor

@ -30,9 +30,6 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
/** /**
* The default event publisher implementation. * The default event publisher implementation.
*
* @author chen.ma
* @date 2021/6/23 19:06
*/ */
@Slf4j @Slf4j
public class DefaultPublisher extends Thread implements EventPublisher { public class DefaultPublisher extends Thread implements EventPublisher {
@ -81,7 +78,7 @@ public class DefaultPublisher extends Thread implements EventPublisher {
private void openEventHandler() { private void openEventHandler() {
try { try {
int waitTimes = 60; int waitTimes = 60;
for (;;) { for (; ; ) {
if (shutdown || hasSubscriber() || waitTimes <= 0) { if (shutdown || hasSubscriber() || waitTimes <= 0) {
break; break;
} }
@ -92,8 +89,7 @@ public class DefaultPublisher extends Thread implements EventPublisher {
} }
waitTimes--; waitTimes--;
} }
for (; ; ) {
for (;;) {
if (shutdown) { if (shutdown) {
break; break;
} }
@ -148,5 +144,4 @@ public class DefaultPublisher extends Thread implements EventPublisher {
notifySubscriber(subscriber, event); notifySubscriber(subscriber, event);
} }
} }
} }

@ -30,9 +30,6 @@ import java.util.concurrent.locks.ReentrantLock;
/** /**
* Default share publisher. * Default share publisher.
*
* @author chen.ma
* @date 2021/6/23 19:05
*/ */
public class DefaultSharePublisher extends DefaultPublisher { public class DefaultSharePublisher extends DefaultPublisher {
@ -45,7 +42,6 @@ public class DefaultSharePublisher extends DefaultPublisher {
public void addSubscriber(AbstractSubscriber subscriber, Class<? extends AbstractEvent> subscribeType) { public void addSubscriber(AbstractSubscriber subscriber, Class<? extends AbstractEvent> subscribeType) {
Class<? extends AbstractSlowEvent> subSlowEventType = (Class<? extends AbstractSlowEvent>) subscribeType; Class<? extends AbstractSlowEvent> subSlowEventType = (Class<? extends AbstractSlowEvent>) subscribeType;
subscribers.add(subscriber); subscribers.add(subscriber);
lock.lock(); lock.lock();
try { try {
Set<AbstractSubscriber> sets = subMappings.get(subSlowEventType); Set<AbstractSubscriber> sets = subMappings.get(subSlowEventType);
@ -60,5 +56,4 @@ public class DefaultSharePublisher extends DefaultPublisher {
lock.unlock(); lock.unlock();
} }
} }
} }

@ -22,9 +22,6 @@ import cn.hippo4j.config.notify.listener.AbstractSubscriber;
/** /**
* Event publisher. * Event publisher.
*
* @author chen.ma
* @date 2021/6/23 18:58
*/ */
public interface EventPublisher { public interface EventPublisher {
@ -58,5 +55,4 @@ public interface EventPublisher {
* @param event * @param event
*/ */
void notifySubscriber(AbstractSubscriber subscriber, AbstractEvent event); void notifySubscriber(AbstractSubscriber subscriber, AbstractEvent event);
} }

@ -31,9 +31,6 @@ import java.util.function.BiFunction;
/** /**
* Unified event notify center. * Unified event notify center.
*
* @author chen.ma
* @date 2021/6/23 18:58
*/ */
@Slf4j @Slf4j
public class NotifyCenter { public class NotifyCenter {
@ -65,7 +62,6 @@ public class NotifyCenter {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
}; };
INSTANCE.sharePublisher = new DefaultSharePublisher(); INSTANCE.sharePublisher = new DefaultSharePublisher();
INSTANCE.sharePublisher.init(AbstractSlowEvent.class, shareBufferSize); INSTANCE.sharePublisher.init(AbstractSlowEvent.class, shareBufferSize);
} }
@ -81,13 +77,11 @@ public class NotifyCenter {
} }
return; return;
} }
final Class<? extends AbstractEvent> subscribeType = consumer.subscribeType(); final Class<? extends AbstractEvent> subscribeType = consumer.subscribeType();
if (ClassUtil.isAssignableFrom(AbstractSlowEvent.class, subscribeType)) { if (ClassUtil.isAssignableFrom(AbstractSlowEvent.class, subscribeType)) {
INSTANCE.sharePublisher.addSubscriber(consumer, subscribeType); INSTANCE.sharePublisher.addSubscriber(consumer, subscribeType);
return; return;
} }
addSubscriber(consumer, subscribeType); addSubscriber(consumer, subscribeType);
} }
@ -113,9 +107,7 @@ public class NotifyCenter {
if (ClassUtil.isAssignableFrom(AbstractSlowEvent.class, eventType)) { if (ClassUtil.isAssignableFrom(AbstractSlowEvent.class, eventType)) {
return INSTANCE.sharePublisher.publish(event); return INSTANCE.sharePublisher.publish(event);
} }
final String topic = ClassUtil.getCanonicalName(eventType); final String topic = ClassUtil.getCanonicalName(eventType);
EventPublisher publisher = INSTANCE.publisherMap.get(topic); EventPublisher publisher = INSTANCE.publisherMap.get(topic);
if (publisher != null) { if (publisher != null) {
return publisher.publish(event); return publisher.publish(event);
@ -128,12 +120,10 @@ public class NotifyCenter {
if (ClassUtil.isAssignableFrom(AbstractSlowEvent.class, eventType)) { if (ClassUtil.isAssignableFrom(AbstractSlowEvent.class, eventType)) {
return INSTANCE.sharePublisher; return INSTANCE.sharePublisher;
} }
final String topic = ClassUtil.getCanonicalName(eventType); final String topic = ClassUtil.getCanonicalName(eventType);
synchronized (NotifyCenter.class) { synchronized (NotifyCenter.class) {
MapUtil.computeIfAbsent(INSTANCE.publisherMap, topic, publisherFactory, eventType, queueMaxSize); MapUtil.computeIfAbsent(INSTANCE.publisherMap, topic, publisherFactory, eventType, queueMaxSize);
} }
return INSTANCE.publisherMap.get(topic); return INSTANCE.publisherMap.get(topic);
} }
} }

@ -23,9 +23,6 @@ import java.util.List;
/** /**
* Subscribers to multiple events can be listened to. * Subscribers to multiple events can be listened to.
*
* @author chen.ma
* @date 2021/6/23 19:02
*/ */
public abstract class AbstractSmartSubscriber extends AbstractSubscriber { public abstract class AbstractSmartSubscriber extends AbstractSubscriber {
@ -35,5 +32,4 @@ public abstract class AbstractSmartSubscriber extends AbstractSubscriber {
* @return * @return
*/ */
public abstract List<Class<? extends AbstractEvent>> subscribeTypes(); public abstract List<Class<? extends AbstractEvent>> subscribeTypes();
} }

@ -23,9 +23,6 @@ import java.util.concurrent.Executor;
/** /**
* An abstract subscriber class for subscriber interface. * An abstract subscriber class for subscriber interface.
*
* @author chen.ma
* @date 2021/6/23 19:02
*/ */
public abstract class AbstractSubscriber<T extends AbstractEvent> { public abstract class AbstractSubscriber<T extends AbstractEvent> {
@ -46,5 +43,4 @@ public abstract class AbstractSubscriber<T extends AbstractEvent> {
public Executor executor() { public Executor executor() {
return null; return null;
} }
} }

@ -131,7 +131,7 @@ public class LongPollingService {
}); });
} }
} catch (Exception ex) { } catch (Exception ex) {
log.error("Data change error :: {}", ex.getMessage(), ex); log.error("Data change error: {}", ex.getMessage(), ex);
} }
} }
} }
@ -217,7 +217,7 @@ public class LongPollingService {
sendResponse(null); sendResponse(null);
} }
} catch (Exception ex) { } catch (Exception ex) {
log.error("Long polling error :: {}", ex.getMessage(), ex); log.error("Long polling error: {}", ex.getMessage(), ex);
} }
}, timeoutTime, TimeUnit.MILLISECONDS); }, timeoutTime, TimeUnit.MILLISECONDS);
allSubs.add(this); allSubs.add(this);

@ -147,7 +147,7 @@ public class ThreadPoolAdapterService {
@Override @Override
public void accept(ObserverMessage<String> observerMessage) { public void accept(ObserverMessage<String> observerMessage) {
log.info("Clean up the thread-pool adapter cache. Key :: {}", observerMessage.message()); log.info("Clean up the thread-pool adapter cache. Key: {}", observerMessage.message());
remove(observerMessage.message()); remove(observerMessage.message());
} }
} }

@ -21,9 +21,6 @@ import cn.hippo4j.config.model.ConfigAllInfo;
/** /**
* Config service. * Config service.
*
* @author chen.ma
* @date 2021/6/20 15:18
*/ */
public interface ConfigService { public interface ConfigService {

@ -25,15 +25,11 @@ import cn.hippo4j.config.model.biz.monitor.MonitorActiveRespDTO;
import cn.hippo4j.config.model.biz.monitor.MonitorQueryReqDTO; import cn.hippo4j.config.model.biz.monitor.MonitorQueryReqDTO;
import cn.hippo4j.config.model.biz.monitor.MonitorRespDTO; import cn.hippo4j.config.model.biz.monitor.MonitorRespDTO;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List; import java.util.List;
/** /**
* His run data service. * His run data service.
*
* @author chen.ma
* @date 2021/12/10 21:28
*/ */
public interface HisRunDataService extends IService<HisRunDataInfo> { public interface HisRunDataService extends IService<HisRunDataInfo> {
@ -74,5 +70,4 @@ public interface HisRunDataService extends IService<HisRunDataInfo> {
* @param messageWrapper * @param messageWrapper
*/ */
Result<Void> dataCollect(MessageWrapper messageWrapper); Result<Void> dataCollect(MessageWrapper messageWrapper);
} }

@ -27,9 +27,6 @@ import java.util.List;
/** /**
* Item service. * Item service.
*
* @author chen.ma
* @date 2021/6/29 21:57
*/ */
public interface ItemService { public interface ItemService {
@ -79,5 +76,4 @@ public interface ItemService {
* @param itemId * @param itemId
*/ */
void deleteItem(String tenantId, String itemId); void deleteItem(String tenantId, String itemId);
} }

@ -26,15 +26,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List; import java.util.List;
/** /**
* . * Notify service.
*
* @author chen.ma
* @date 2021/11/17 22:01
*/ */
public interface NotifyService { public interface NotifyService {
/** /**
* . * List notify config.
* *
* @param reqDTO * @param reqDTO
* @return * @return
@ -42,7 +39,7 @@ public interface NotifyService {
List<NotifyListRespDTO> listNotifyConfig(NotifyQueryReqDTO reqDTO); List<NotifyListRespDTO> listNotifyConfig(NotifyQueryReqDTO reqDTO);
/** /**
* . * Query page.
* *
* @param reqDTO * @param reqDTO
* @return * @return
@ -50,32 +47,31 @@ public interface NotifyService {
IPage<NotifyRespDTO> queryPage(NotifyQueryReqDTO reqDTO); IPage<NotifyRespDTO> queryPage(NotifyQueryReqDTO reqDTO);
/** /**
* . * Save.
* *
* @param reqDTO * @param reqDTO
*/ */
void save(NotifyReqDTO reqDTO); void save(NotifyReqDTO reqDTO);
/** /**
* . * Update.
* *
* @param reqDTO * @param reqDTO
*/ */
void update(NotifyReqDTO reqDTO); void update(NotifyReqDTO reqDTO);
/** /**
* . * Delete.
* *
* @param reqDTO * @param reqDTO
*/ */
void delete(NotifyReqDTO reqDTO); void delete(NotifyReqDTO reqDTO);
/** /**
* . * Enable notify.
* *
* @param id * @param id
* @param status * @param status
*/ */
void enableNotify(String id, Integer status); void enableNotify(String id, Integer status);
} }

@ -25,9 +25,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
/** /**
* Tenant service. * Tenant service.
*
* @author chen.ma
* @date 2021/6/29 21:59
*/ */
public interface TenantService { public interface TenantService {
@ -75,5 +72,4 @@ public interface TenantService {
* @param tenantId * @param tenantId
*/ */
void deleteTenantById(String tenantId); void deleteTenantById(String tenantId);
} }

@ -27,9 +27,6 @@ import java.util.List;
/** /**
* Thread pool service. * Thread pool service.
*
* @author chen.ma
* @date 2021/6/30 21:26
*/ */
public interface ThreadPoolService { public interface ThreadPoolService {
@ -79,5 +76,4 @@ public interface ThreadPoolService {
* @param isAlarm * @param isAlarm
*/ */
void alarmEnable(String id, Integer isAlarm); void alarmEnable(String id, Integer isAlarm);
} }

@ -50,9 +50,6 @@ import static cn.hutool.core.date.DatePattern.NORM_TIME_PATTERN;
/** /**
* His run data service impl. * His run data service impl.
*
* @author chen.ma
* @date 2021/12/10 21:28
*/ */
@Service @Service
@AllArgsConstructor @AllArgsConstructor
@ -69,7 +66,6 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
Date currentDate = new Date(); Date currentDate = new Date();
DateTime dateTime = DateUtil.offsetMinute(currentDate, -properties.getCleanHistoryDataPeriod()); DateTime dateTime = DateUtil.offsetMinute(currentDate, -properties.getCleanHistoryDataPeriod());
long startTime = dateTime.getTime(); long startTime = dateTime.getTime();
List<HisRunDataInfo> hisRunDataInfos = this.lambdaQuery() List<HisRunDataInfo> hisRunDataInfos = this.lambdaQuery()
.eq(HisRunDataInfo::getTenantId, reqDTO.getTenantId()) .eq(HisRunDataInfo::getTenantId, reqDTO.getTenantId())
.eq(HisRunDataInfo::getItemId, reqDTO.getItemId()) .eq(HisRunDataInfo::getItemId, reqDTO.getItemId())
@ -78,7 +74,6 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
.between(HisRunDataInfo::getTimestamp, startTime, currentDate.getTime()) .between(HisRunDataInfo::getTimestamp, startTime, currentDate.getTime())
.orderByAsc(HisRunDataInfo::getTimestamp) .orderByAsc(HisRunDataInfo::getTimestamp)
.list(); .list();
return BeanUtil.convert(hisRunDataInfos, MonitorRespDTO.class); return BeanUtil.convert(hisRunDataInfos, MonitorRespDTO.class);
} }
@ -87,7 +82,6 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
Date currentDate = new Date(); Date currentDate = new Date();
DateTime dateTime = DateUtil.offsetMinute(currentDate, -properties.getCleanHistoryDataPeriod()); DateTime dateTime = DateUtil.offsetMinute(currentDate, -properties.getCleanHistoryDataPeriod());
long startTime = dateTime.getTime(); long startTime = dateTime.getTime();
List<HisRunDataInfo> hisRunDataInfos = this.lambdaQuery() List<HisRunDataInfo> hisRunDataInfos = this.lambdaQuery()
.eq(HisRunDataInfo::getTenantId, reqDTO.getTenantId()) .eq(HisRunDataInfo::getTenantId, reqDTO.getTenantId())
.eq(HisRunDataInfo::getItemId, reqDTO.getItemId()) .eq(HisRunDataInfo::getItemId, reqDTO.getItemId())
@ -96,7 +90,6 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
.between(HisRunDataInfo::getTimestamp, startTime, currentDate.getTime()) .between(HisRunDataInfo::getTimestamp, startTime, currentDate.getTime())
.orderByAsc(HisRunDataInfo::getTimestamp) .orderByAsc(HisRunDataInfo::getTimestamp)
.list(); .list();
List<String> times = Lists.newArrayList(); List<String> times = Lists.newArrayList();
List<Long> poolSizeList = Lists.newArrayList(); List<Long> poolSizeList = Lists.newArrayList();
List<Long> activeSizeList = Lists.newArrayList(); List<Long> activeSizeList = Lists.newArrayList();
@ -106,7 +99,6 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
List<Long> rejectCountList = Lists.newArrayList(); List<Long> rejectCountList = Lists.newArrayList();
List<Long> queueRemainingCapacityList = Lists.newArrayList(); List<Long> queueRemainingCapacityList = Lists.newArrayList();
List<Long> currentLoadList = Lists.newArrayList(); List<Long> currentLoadList = Lists.newArrayList();
long countTemp = 0L; long countTemp = 0L;
AtomicBoolean firstFlag = new AtomicBoolean(Boolean.TRUE); AtomicBoolean firstFlag = new AtomicBoolean(Boolean.TRUE);
for (HisRunDataInfo each : hisRunDataInfos) { for (HisRunDataInfo each : hisRunDataInfos) {
@ -119,20 +111,17 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
queueRemainingCapacityList.add(each.getQueueRemainingCapacity()); queueRemainingCapacityList.add(each.getQueueRemainingCapacity());
currentLoadList.add(each.getCurrentLoad()); currentLoadList.add(each.getCurrentLoad());
queueCapacityList.add(each.getQueueCapacity()); queueCapacityList.add(each.getQueueCapacity());
if (firstFlag.get()) { if (firstFlag.get()) {
completedTaskCountList.add(0L); completedTaskCountList.add(0L);
firstFlag.set(Boolean.FALSE); firstFlag.set(Boolean.FALSE);
countTemp = each.getCompletedTaskCount(); countTemp = each.getCompletedTaskCount();
continue; continue;
} }
long completedTaskCount = each.getCompletedTaskCount(); long completedTaskCount = each.getCompletedTaskCount();
long countTask = completedTaskCount - countTemp; long countTask = completedTaskCount - countTemp;
completedTaskCountList.add(countTask); completedTaskCountList.add(countTask);
countTemp = each.getCompletedTaskCount(); countTemp = each.getCompletedTaskCount();
} }
return new MonitorActiveRespDTO(times, poolSizeList, activeSizeList, queueSizeList, completedTaskCountList, rejectCountList, queueRemainingCapacityList, currentLoadList, queueCapacityList); return new MonitorActiveRespDTO(times, poolSizeList, activeSizeList, queueSizeList, completedTaskCountList, rejectCountList, queueRemainingCapacityList, currentLoadList, queueCapacityList);
} }
@ -141,7 +130,6 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
Date currentDate = new Date(); Date currentDate = new Date();
DateTime dateTime = DateUtil.offsetMinute(currentDate, -properties.getCleanHistoryDataPeriod()); DateTime dateTime = DateUtil.offsetMinute(currentDate, -properties.getCleanHistoryDataPeriod());
long startTime = dateTime.getTime(); long startTime = dateTime.getTime();
HisRunDataInfo hisRunDataInfo = this.lambdaQuery() HisRunDataInfo hisRunDataInfo = this.lambdaQuery()
.eq(HisRunDataInfo::getTenantId, reqDTO.getTenantId()) .eq(HisRunDataInfo::getTenantId, reqDTO.getTenantId())
.eq(HisRunDataInfo::getItemId, reqDTO.getItemId()) .eq(HisRunDataInfo::getItemId, reqDTO.getItemId())
@ -151,7 +139,6 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
.between(HisRunDataInfo::getTimestamp, startTime, currentDate.getTime()) .between(HisRunDataInfo::getTimestamp, startTime, currentDate.getTime())
.last("LIMIT 1") .last("LIMIT 1")
.one(); .one();
return BeanUtil.convert(hisRunDataInfo, MonitorRespDTO.class); return BeanUtil.convert(hisRunDataInfo, MonitorRespDTO.class);
} }
@ -160,19 +147,15 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
public void save(Message message) { public void save(Message message) {
List<RuntimeMessage> runtimeMessages = message.getMessages(); List<RuntimeMessage> runtimeMessages = message.getMessages();
List<HisRunDataInfo> hisRunDataInfos = Lists.newArrayList(); List<HisRunDataInfo> hisRunDataInfos = Lists.newArrayList();
runtimeMessages.forEach(each -> { runtimeMessages.forEach(each -> {
HisRunDataInfo hisRunDataInfo = BeanUtil.convert(each, HisRunDataInfo.class); HisRunDataInfo hisRunDataInfo = BeanUtil.convert(each, HisRunDataInfo.class);
String[] parseKey = GroupKey.parseKey(each.getGroupKey()); String[] parseKey = GroupKey.parseKey(each.getGroupKey());
hisRunDataInfo.setTpId(parseKey[0]); hisRunDataInfo.setTpId(parseKey[0]);
hisRunDataInfo.setItemId(parseKey[1]); hisRunDataInfo.setItemId(parseKey[1]);
hisRunDataInfo.setTenantId(parseKey[2]); hisRunDataInfo.setTenantId(parseKey[2]);
hisRunDataInfo.setInstanceId(parseKey[3]); hisRunDataInfo.setInstanceId(parseKey[3]);
hisRunDataInfos.add(hisRunDataInfo); hisRunDataInfos.add(hisRunDataInfo);
}); });
this.saveBatch(hisRunDataInfos); this.saveBatch(hisRunDataInfos);
} }
@ -189,5 +172,4 @@ public class HisRunDataServiceImpl extends ServiceImpl<HisRunDataMapper, HisRunD
} }
return Results.success(); return Results.success();
} }
} }

@ -43,9 +43,6 @@ import java.util.List;
/** /**
* Item service impl. * Item service impl.
*
* @author chen.ma
* @date 2021/6/29 21:58
*/ */
@Service @Service
@AllArgsConstructor @AllArgsConstructor
@ -73,7 +70,6 @@ public class ItemServiceImpl implements ItemService {
.lambdaQuery(ItemInfo.class) .lambdaQuery(ItemInfo.class)
.eq(ItemInfo::getTenantId, tenantId) .eq(ItemInfo::getTenantId, tenantId)
.eq(ItemInfo::getItemId, itemId); .eq(ItemInfo::getItemId, itemId);
ItemInfo itemInfo = itemInfoMapper.selectOne(queryWrapper); ItemInfo itemInfo = itemInfoMapper.selectOne(queryWrapper);
ItemRespDTO result = BeanUtil.convert(itemInfo, ItemRespDTO.class); ItemRespDTO result = BeanUtil.convert(itemInfo, ItemRespDTO.class);
return result; return result;
@ -84,7 +80,6 @@ public class ItemServiceImpl implements ItemService {
LambdaQueryWrapper<ItemInfo> wrapper = Wrappers.lambdaQuery(ItemInfo.class) LambdaQueryWrapper<ItemInfo> wrapper = Wrappers.lambdaQuery(ItemInfo.class)
.eq(!StringUtils.isEmpty(reqDTO.getItemId()), ItemInfo::getItemId, reqDTO.getItemId()) .eq(!StringUtils.isEmpty(reqDTO.getItemId()), ItemInfo::getItemId, reqDTO.getItemId())
.eq(!StringUtils.isEmpty(reqDTO.getTenantId()), ItemInfo::getTenantId, reqDTO.getTenantId()); .eq(!StringUtils.isEmpty(reqDTO.getTenantId()), ItemInfo::getTenantId, reqDTO.getTenantId());
List<ItemInfo> itemInfos = itemInfoMapper.selectList(wrapper); List<ItemInfo> itemInfos = itemInfoMapper.selectList(wrapper);
return BeanUtil.convert(itemInfos, ItemRespDTO.class); return BeanUtil.convert(itemInfos, ItemRespDTO.class);
} }
@ -93,15 +88,12 @@ public class ItemServiceImpl implements ItemService {
public void saveItem(ItemSaveReqDTO reqDTO) { public void saveItem(ItemSaveReqDTO reqDTO) {
LambdaQueryWrapper<ItemInfo> queryWrapper = Wrappers.lambdaQuery(ItemInfo.class) LambdaQueryWrapper<ItemInfo> queryWrapper = Wrappers.lambdaQuery(ItemInfo.class)
.eq(ItemInfo::getItemId, reqDTO.getItemId()); .eq(ItemInfo::getItemId, reqDTO.getItemId());
// It is currently a single application, and it will support switching distributed locks during cluster deployment in the future.
// 当前为单体应用, 后续支持集群部署时切换分布式锁.
synchronized (ItemService.class) { synchronized (ItemService.class) {
ItemInfo existItemInfo = itemInfoMapper.selectOne(queryWrapper); ItemInfo existItemInfo = itemInfoMapper.selectOne(queryWrapper);
Assert.isNull(existItemInfo, "项目配置已存在."); Assert.isNull(existItemInfo, "项目配置已存在.");
ItemInfo itemInfo = BeanUtil.convert(reqDTO, ItemInfo.class); ItemInfo itemInfo = BeanUtil.convert(reqDTO, ItemInfo.class);
int insertResult = itemInfoMapper.insert(itemInfo); int insertResult = itemInfoMapper.insert(itemInfo);
boolean retBool = SqlHelper.retBool(insertResult); boolean retBool = SqlHelper.retBool(insertResult);
if (!retBool) { if (!retBool) {
throw new RuntimeException("Save error"); throw new RuntimeException("Save error");
@ -116,7 +108,6 @@ public class ItemServiceImpl implements ItemService {
Wrappers.lambdaUpdate(ItemInfo.class) Wrappers.lambdaUpdate(ItemInfo.class)
.eq(ItemInfo::getTenantId, reqDTO.getTenantId()) .eq(ItemInfo::getTenantId, reqDTO.getTenantId())
.eq(ItemInfo::getItemId, reqDTO.getItemId())); .eq(ItemInfo::getItemId, reqDTO.getItemId()));
boolean retBool = SqlHelper.retBool(updateResult); boolean retBool = SqlHelper.retBool(updateResult);
if (!retBool) { if (!retBool) {
throw new RuntimeException("Update error."); throw new RuntimeException("Update error.");
@ -129,17 +120,14 @@ public class ItemServiceImpl implements ItemService {
if (CollectionUtils.isNotEmpty(itemList)) { if (CollectionUtils.isNotEmpty(itemList)) {
throw new RuntimeException("项目包含线程池引用, 删除失败."); throw new RuntimeException("项目包含线程池引用, 删除失败.");
} }
int updateResult = itemInfoMapper.update(new ItemInfo(), int updateResult = itemInfoMapper.update(new ItemInfo(),
Wrappers.lambdaUpdate(ItemInfo.class) Wrappers.lambdaUpdate(ItemInfo.class)
.eq(ItemInfo::getTenantId, namespace) .eq(ItemInfo::getTenantId, namespace)
.eq(ItemInfo::getItemId, itemId) .eq(ItemInfo::getItemId, itemId)
.set(ItemInfo::getDelFlag, DelEnum.DELETE.getIntCode())); .set(ItemInfo::getDelFlag, DelEnum.DELETE.getIntCode()));
boolean retBool = SqlHelper.retBool(updateResult); boolean retBool = SqlHelper.retBool(updateResult);
if (!retBool) { if (!retBool) {
throw new RuntimeException("Delete error."); throw new RuntimeException("Delete error.");
} }
} }
} }

@ -44,10 +44,7 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
/** /**
* . * Notify service impl.
*
* @author chen.ma
* @date 2021/11/17 22:02
*/ */
@Service @Service
@AllArgsConstructor @AllArgsConstructor

@ -32,9 +32,6 @@ import org.springframework.stereotype.Service;
/** /**
* Operation log service impl. * Operation log service impl.
*
* @author chen.ma
* @date 2021/11/17 21:50
*/ */
@Service @Service
@AllArgsConstructor @AllArgsConstructor

@ -44,9 +44,6 @@ import java.util.List;
/** /**
* Tenant service impl. * Tenant service impl.
*
* @author chen.ma
* @date 2021/6/29 21:12
*/ */
@Service @Service
@AllArgsConstructor @AllArgsConstructor
@ -89,10 +86,8 @@ public class TenantServiceImpl implements TenantService {
synchronized (TenantService.class) { synchronized (TenantService.class) {
TenantInfo existTenantInfo = tenantInfoMapper.selectOne(queryWrapper); TenantInfo existTenantInfo = tenantInfoMapper.selectOne(queryWrapper);
Assert.isNull(existTenantInfo, "租户配置已存在."); Assert.isNull(existTenantInfo, "租户配置已存在.");
TenantInfo tenantInfo = BeanUtil.convert(reqDTO, TenantInfo.class); TenantInfo tenantInfo = BeanUtil.convert(reqDTO, TenantInfo.class);
int insertResult = tenantInfoMapper.insert(tenantInfo); int insertResult = tenantInfoMapper.insert(tenantInfo);
boolean retBool = SqlHelper.retBool(insertResult); boolean retBool = SqlHelper.retBool(insertResult);
if (!retBool) { if (!retBool) {
throw new RuntimeException("Save Error."); throw new RuntimeException("Save Error.");

@ -26,22 +26,16 @@ import org.springframework.stereotype.Component;
/** /**
* Client close hook remove config cache. * Client close hook remove config cache.
*
* @author chen.ma
* @date 2022/1/6 22:20
*/ */
@Slf4j @Slf4j
@Component @Component
public class ClientCloseHookRemoveConfigCache implements ClientCloseHookExecute { public class ClientCloseHookRemoveConfigCache implements ClientCloseHookExecute {
@Override @Override
public void closeHook(ClientCloseHookReq req) { public void closeHook(ClientCloseHookReq requestParam) {
log.info( log.info("Remove Config Cache, Execute client hook function. Request :: {}", JSONUtil.toJSONString(requestParam));
"Remove Config Cache, Execute client hook function. Req :: {}",
JSONUtil.toJSONString(req));
try { try {
String groupKey = req.getGroupKey(); String groupKey = requestParam.getGroupKey();
if (StrUtil.isNotBlank(groupKey)) { if (StrUtil.isNotBlank(groupKey)) {
ConfigCacheService.removeConfigCache(groupKey); ConfigCacheService.removeConfigCache(groupKey);
} }
@ -49,5 +43,4 @@ public class ClientCloseHookRemoveConfigCache implements ClientCloseHookExecute
log.error("Failed to remove config cache hook.", ex); log.error("Failed to remove config cache hook.", ex);
} }
} }
} }

@ -23,10 +23,7 @@ import com.github.dozermapper.core.Mapper;
import java.util.*; import java.util.*;
/** /**
* Bean util * Bean util.
*
* @author chen.ma
* @date 2021/3/19 15:40
*/ */
public class BeanUtil { public class BeanUtil {
@ -67,5 +64,4 @@ public class BeanUtil {
}) })
.orElse(null); .orElse(null);
} }
} }

@ -21,9 +21,6 @@ import java.util.Objects;
/** /**
* Class util. * Class util.
*
* @author chen.ma
* @date 2021/6/23 19:03
*/ */
public class ClassUtil { public class ClassUtil {
@ -36,5 +33,4 @@ public class ClassUtil {
Objects.requireNonNull(cls, "cls"); Objects.requireNonNull(cls, "cls");
return cls.getCanonicalName(); return cls.getCanonicalName();
} }
} }

@ -27,9 +27,6 @@ import static cn.hippo4j.common.constant.Constants.DEFAULT_GROUP;
/** /**
* Config executor. * Config executor.
*
* @author chen.ma
* @date 2021/6/23 18:33
*/ */
public class ConfigExecutor { public class ConfigExecutor {
@ -47,5 +44,4 @@ public class ConfigExecutor {
public static void scheduleLongPolling(Runnable runnable, long initialDelay, long period, TimeUnit unit) { public static void scheduleLongPolling(Runnable runnable, long initialDelay, long period, TimeUnit unit) {
LONG_POLLING_EXECUTOR.scheduleWithFixedDelay(runnable, initialDelay, period, unit); LONG_POLLING_EXECUTOR.scheduleWithFixedDelay(runnable, initialDelay, period, unit);
} }
} }

@ -24,9 +24,6 @@ import java.util.Objects;
/** /**
* Env Util. * Env Util.
*
* @author chen.ma
* @date 2022/2/9 07:46
*/ */
public class EnvUtil { public class EnvUtil {
@ -49,10 +46,8 @@ public class EnvUtil {
if (StringUtils.isBlank(hippo4jHome)) { if (StringUtils.isBlank(hippo4jHome)) {
hippo4jHome = Paths.get(System.getProperty("user.home"), "hippo4j").toString(); hippo4jHome = Paths.get(System.getProperty("user.home"), "hippo4j").toString();
} }
return hippo4jHome; return hippo4jHome;
} }
return HIPPO4J_HOME_PATH; return HIPPO4J_HOME_PATH;
} }
@ -65,8 +60,6 @@ public class EnvUtil {
if (Objects.isNull(IS_STANDALONE)) { if (Objects.isNull(IS_STANDALONE)) {
IS_STANDALONE = Boolean.getBoolean(STANDALONE_MODE_PROPERTY_NAME); IS_STANDALONE = Boolean.getBoolean(STANDALONE_MODE_PROPERTY_NAME);
} }
return IS_STANDALONE; return IS_STANDALONE;
} }
} }

@ -27,9 +27,6 @@ import java.util.function.BiFunction;
/** /**
* Map util. * Map util.
*
* @author chen.ma
* @date 2021/6/23 19:09
*/ */
public class MapUtil { public class MapUtil {
@ -39,7 +36,6 @@ public class MapUtil {
Objects.requireNonNull(mappingFunction, "mappingFunction"); Objects.requireNonNull(mappingFunction, "mappingFunction");
Objects.requireNonNull(param1, "param1"); Objects.requireNonNull(param1, "param1");
Objects.requireNonNull(param2, "param2"); Objects.requireNonNull(param2, "param2");
Object val = target.get(key); Object val = target.get(key);
if (val == null) { if (val == null) {
Object ret = mappingFunction.apply(param1, param2); Object ret = mappingFunction.apply(param1, param2);
@ -50,7 +46,7 @@ public class MapUtil {
} }
/** /**
* Key . * Fuzzy matching based on Key.
* *
* @param sourceMap * @param sourceMap
* @param filters * @param filters
@ -61,18 +57,16 @@ public class MapUtil {
if (CollUtil.isEmpty(sourceMap)) { if (CollUtil.isEmpty(sourceMap)) {
return resultList; return resultList;
} }
sourceMap.forEach((key, val) -> { sourceMap.forEach((key, val) -> {
if (checkKey(key, filters)) { if (checkKey(key, filters)) {
resultList.add(key); resultList.add(key);
} }
}); });
return resultList; return resultList;
} }
/** /**
* . * Match the characters you want to query.
* *
* @param key * @param key
* @param filters * @param filters
@ -85,5 +79,4 @@ public class MapUtil {
return false; return false;
} }
} }
} }

@ -36,9 +36,6 @@ import static cn.hippo4j.common.constant.Constants.WORD_SEPARATOR;
/** /**
* Md5 config util. * Md5 config util.
*
* @author chen.ma
* @date 2021/6/21 18:32
*/ */
public class Md5ConfigUtil { public class Md5ConfigUtil {
@ -72,13 +69,11 @@ public class Md5ConfigUtil {
changedGroupKeys.add(key); changedGroupKeys.add(key);
} }
}); });
return changedGroupKeys; return changedGroupKeys;
} }
public static Map<String, String> getClientMd5Map(String configKeysString) { public static Map<String, String> getClientMd5Map(String configKeysString) {
Map<String, String> md5Map = new HashMap(5); Map<String, String> md5Map = new HashMap(5);
if (null == configKeysString || "".equals(configKeysString)) { if (null == configKeysString || "".equals(configKeysString)) {
return md5Map; return md5Map;
} }
@ -99,12 +94,10 @@ public class Md5ConfigUtil {
endValue = configKeysString.substring(start, i); endValue = configKeysString.substring(start, i);
} }
start = i + 1; start = i + 1;
String groupKey = getKey(tmpList.get(0), tmpList.get(1), tmpList.get(2), tmpList.get(3)); String groupKey = getKey(tmpList.get(0), tmpList.get(1), tmpList.get(2), tmpList.get(3));
groupKey = SingletonRepository.DataIdGroupIdCache.getSingleton(groupKey); groupKey = SingletonRepository.DataIdGroupIdCache.getSingleton(groupKey);
md5Map.put(groupKey, endValue); md5Map.put(groupKey, endValue);
tmpList.clear(); tmpList.clear();
// Protect malformed messages // Protect malformed messages
if (md5Map.size() > 10000) { if (md5Map.size() > 10000) {
throw new IllegalArgumentException("invalid protocol, too much listener"); throw new IllegalArgumentException("invalid protocol, too much listener");
@ -132,7 +125,6 @@ public class Md5ConfigUtil {
GroupKey.urlEncode(tenant, sb); GroupKey.urlEncode(tenant, sb);
sb.append("+").append(identify); sb.append("+").append(identify);
} }
return sb.toString(); return sb.toString();
} }
@ -140,9 +132,7 @@ public class Md5ConfigUtil {
if (null == changedGroupKeys) { if (null == changedGroupKeys) {
return ""; return "";
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (String groupKey : changedGroupKeys) { for (String groupKey : changedGroupKeys) {
String[] dataIdGroupId = GroupKey.parseKey(groupKey); String[] dataIdGroupId = GroupKey.parseKey(groupKey);
sb.append(dataIdGroupId[0]); sb.append(dataIdGroupId[0]);
@ -157,8 +147,6 @@ public class Md5ConfigUtil {
} }
sb.append(LINE_SEPARATOR); sb.append(LINE_SEPARATOR);
} }
return URLEncoder.encode(sb.toString(), "UTF-8"); return URLEncoder.encode(sb.toString(), "UTF-8");
} }
} }

@ -25,9 +25,6 @@ import static cn.hippo4j.common.constant.Constants.LONG_PULLING_CLIENT_IDENTIFIC
/** /**
* Request util. * Request util.
*
* @author chen.ma
* @date 2021/6/23 18:28
*/ */
public class RequestUtil { public class RequestUtil {
@ -41,5 +38,4 @@ public class RequestUtil {
String identify = request.getHeader(LONG_PULLING_CLIENT_IDENTIFICATION); String identify = request.getHeader(LONG_PULLING_CLIENT_IDENTIFICATION);
return StrUtil.isBlank(identify) ? "" : identify; return StrUtil.isBlank(identify) ? "" : identify;
} }
} }

@ -19,9 +19,6 @@ package cn.hippo4j.config.toolkit;
/** /**
* Simple read write lock. * Simple read write lock.
*
* @author chen.ma
* @date 2021/6/24 21:26
*/ */
public class SimpleReadWriteLock { public class SimpleReadWriteLock {
@ -60,5 +57,4 @@ public class SimpleReadWriteLock {
private boolean isFree() { private boolean isFree() {
return status == 0; return status == 0;
} }
} }

@ -21,9 +21,6 @@ import java.util.concurrent.ConcurrentHashMap;
/** /**
* Singleton repository. * Singleton repository.
*
* @author chen.ma
* @date 2021/6/24 21:28
*/ */
public class SingletonRepository<T> { public class SingletonRepository<T> {
@ -54,5 +51,4 @@ public class SingletonRepository<T> {
static SingletonRepository<String> cache = new SingletonRepository<String>(); static SingletonRepository<String> cache = new SingletonRepository<String>();
} }
} }

Loading…
Cancel
Save