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.
*
* @author chen.ma
* @date 2021/7/19 21:03
*/
@Configuration
public class CommonConfig {
@ -53,5 +50,4 @@ public class CommonConfig {
monitorThreadPool.setAwaitTerminationMillis(5000);
return monitorThreadPool;
}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -26,9 +26,6 @@ import org.springframework.stereotype.Component;
/**
* Runtime data resolver.
*
* @author chen.ma
* @date 2021/12/10 20:18
*/
@Slf4j
@Component
@ -46,5 +43,4 @@ public class RuntimeDataResolver extends AbstractMonitorDataExecuteStrategy<Runt
public void execute(RuntimeMessage 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.
*
* @author chen.ma
* @date 2021/12/17 20:13
*/
@Component
@RequiredArgsConstructor
@ -58,10 +55,8 @@ public class TimeCleanHistoryDataTask implements Runnable, InitializingBean {
public void run() {
Date currentDate = new Date();
DateTime offsetMinuteDateTime = DateUtil.offsetMinute(currentDate, -properties.getCleanHistoryDataPeriod());
LambdaQueryWrapper<HisRunDataInfo> queryWrapper = Wrappers.lambdaQuery(HisRunDataInfo.class)
.le(HisRunDataInfo::getTimestamp, offsetMinuteDateTime.getTime());
hisRunDataService.remove(queryWrapper);
}
@ -73,5 +68,4 @@ public class TimeCleanHistoryDataTask implements Runnable, InitializingBean {
cleanHistoryDataExecutor.scheduleWithFixedDelay(this, 0, 1, TimeUnit.MINUTES);
}
}
}

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

@ -17,22 +17,15 @@
package cn.hippo4j.config.netty;
import cn.hippo4j.common.monitor.Message;
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 io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
/**
* ServerHandler
*
* @author lk
* @date 2022/06/18
* Server handler.
*/
@Slf4j
@AllArgsConstructor

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

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

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

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

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

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

@ -131,7 +131,7 @@ public class LongPollingService {
});
}
} 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);
}
} catch (Exception ex) {
log.error("Long polling error :: {}", ex.getMessage(), ex);
log.error("Long polling error: {}", ex.getMessage(), ex);
}
}, timeoutTime, TimeUnit.MILLISECONDS);
allSubs.add(this);

@ -147,7 +147,7 @@ public class ThreadPoolAdapterService {
@Override
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());
}
}

@ -21,9 +21,6 @@ import cn.hippo4j.config.model.ConfigAllInfo;
/**
* Config service.
*
* @author chen.ma
* @date 2021/6/20 15:18
*/
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.MonitorRespDTO;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* His run data service.
*
* @author chen.ma
* @date 2021/12/10 21:28
*/
public interface HisRunDataService extends IService<HisRunDataInfo> {
@ -74,5 +70,4 @@ public interface HisRunDataService extends IService<HisRunDataInfo> {
* @param messageWrapper
*/
Result<Void> dataCollect(MessageWrapper messageWrapper);
}

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

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

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

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

@ -43,9 +43,6 @@ import java.util.List;
/**
* Item service impl.
*
* @author chen.ma
* @date 2021/6/29 21:58
*/
@Service
@AllArgsConstructor
@ -73,7 +70,6 @@ public class ItemServiceImpl implements ItemService {
.lambdaQuery(ItemInfo.class)
.eq(ItemInfo::getTenantId, tenantId)
.eq(ItemInfo::getItemId, itemId);
ItemInfo itemInfo = itemInfoMapper.selectOne(queryWrapper);
ItemRespDTO result = BeanUtil.convert(itemInfo, ItemRespDTO.class);
return result;
@ -84,7 +80,6 @@ public class ItemServiceImpl implements ItemService {
LambdaQueryWrapper<ItemInfo> wrapper = Wrappers.lambdaQuery(ItemInfo.class)
.eq(!StringUtils.isEmpty(reqDTO.getItemId()), ItemInfo::getItemId, reqDTO.getItemId())
.eq(!StringUtils.isEmpty(reqDTO.getTenantId()), ItemInfo::getTenantId, reqDTO.getTenantId());
List<ItemInfo> itemInfos = itemInfoMapper.selectList(wrapper);
return BeanUtil.convert(itemInfos, ItemRespDTO.class);
}
@ -93,15 +88,12 @@ public class ItemServiceImpl implements ItemService {
public void saveItem(ItemSaveReqDTO reqDTO) {
LambdaQueryWrapper<ItemInfo> queryWrapper = Wrappers.lambdaQuery(ItemInfo.class)
.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) {
ItemInfo existItemInfo = itemInfoMapper.selectOne(queryWrapper);
Assert.isNull(existItemInfo, "项目配置已存在.");
ItemInfo itemInfo = BeanUtil.convert(reqDTO, ItemInfo.class);
int insertResult = itemInfoMapper.insert(itemInfo);
boolean retBool = SqlHelper.retBool(insertResult);
if (!retBool) {
throw new RuntimeException("Save error");
@ -116,7 +108,6 @@ public class ItemServiceImpl implements ItemService {
Wrappers.lambdaUpdate(ItemInfo.class)
.eq(ItemInfo::getTenantId, reqDTO.getTenantId())
.eq(ItemInfo::getItemId, reqDTO.getItemId()));
boolean retBool = SqlHelper.retBool(updateResult);
if (!retBool) {
throw new RuntimeException("Update error.");
@ -129,17 +120,14 @@ public class ItemServiceImpl implements ItemService {
if (CollectionUtils.isNotEmpty(itemList)) {
throw new RuntimeException("项目包含线程池引用, 删除失败.");
}
int updateResult = itemInfoMapper.update(new ItemInfo(),
Wrappers.lambdaUpdate(ItemInfo.class)
.eq(ItemInfo::getTenantId, namespace)
.eq(ItemInfo::getItemId, itemId)
.set(ItemInfo::getDelFlag, DelEnum.DELETE.getIntCode()));
boolean retBool = SqlHelper.retBool(updateResult);
if (!retBool) {
throw new RuntimeException("Delete error.");
}
}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save