Optimize the comments and logs of the dynamic configuration module.

pull/161/head
chen.ma 3 years ago
parent ea6d0c9a95
commit df3119d249

@ -5,7 +5,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
/** /**
* . * Common config.
* *
* @author chen.ma * @author chen.ma
* @date 2021/7/19 21:03 * @date 2021/7/19 21:03

@ -9,7 +9,7 @@ import org.springframework.stereotype.Component;
import java.util.Date; import java.util.Date;
/** /**
* Meta Object Handler. * Meta object handler.
* *
* @author chen.ma * @author chen.ma
* @date 2021/7/1 22:43 * @date 2021/7/1 22:43
@ -17,6 +17,7 @@ import java.util.Date;
@Slf4j @Slf4j
@Component @Component
public class MyMetaObjectHandler implements MetaObjectHandler { public class MyMetaObjectHandler implements MetaObjectHandler {
@Override @Override
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());
@ -29,4 +30,5 @@ 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());
} }
} }

@ -7,7 +7,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
/** /**
* Mybatis Plus Config. * Mybatis plus config.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/29 20:22 * @date 2021/6/29 20:22

@ -19,7 +19,7 @@ import java.net.URLDecoder;
import java.util.Map; import java.util.Map;
/** /**
* * Server configuration controller.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/20 13:53 * @date 2021/6/20 13:53

@ -9,12 +9,12 @@ package com.github.dynamic.threadpool.config.enums;
public enum DelEnum { public enum DelEnum {
/** /**
* * Normal state
*/ */
NORMAL("0"), NORMAL("0"),
/** /**
* * Deleted state
*/ */
DELETE("1"); DELETE("1");

@ -3,7 +3,7 @@ package com.github.dynamic.threadpool.config.event;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
* Config Data Change Event. * Config data change event.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/24 23:35 * @date 2021/6/24 23:35
@ -20,7 +20,7 @@ public class ConfigDataChangeEvent extends Event {
public ConfigDataChangeEvent(String tenantId, String itemId, String tpId, Long gmtModified) { public ConfigDataChangeEvent(String tenantId, String itemId, String tpId, Long gmtModified) {
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;
@ -28,4 +28,5 @@ public class ConfigDataChangeEvent extends Event {
this.tpId = tpId; this.tpId = tpId;
this.lastModifiedTs = gmtModified; this.lastModifiedTs = gmtModified;
} }
} }

@ -23,4 +23,5 @@ public abstract class Event implements Serializable {
public long sequence() { public long sequence() {
return sequence; return sequence;
} }
} }

@ -1,7 +1,7 @@
package com.github.dynamic.threadpool.config.event; package com.github.dynamic.threadpool.config.event;
/** /**
* Local Data Change Event. * Local data change event.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/23 19:13 * @date 2021/6/23 19:13
@ -13,4 +13,5 @@ public class LocalDataChangeEvent extends Event {
public LocalDataChangeEvent(String groupKey) { public LocalDataChangeEvent(String groupKey) {
this.groupKey = groupKey; this.groupKey = groupKey;
} }
} }

@ -1,7 +1,7 @@
package com.github.dynamic.threadpool.config.event; package com.github.dynamic.threadpool.config.event;
/** /**
* Slow Event. * Slow event.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/23 19:05 * @date 2021/6/23 19:05

@ -5,7 +5,7 @@ import com.github.dynamic.threadpool.config.model.ConfigAllInfo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**
* Config Info Mapper. * Config info mapper.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/29 22:44 * @date 2021/6/29 22:44

@ -5,7 +5,7 @@ import com.github.dynamic.threadpool.config.model.ItemInfo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**
* Item Info Mapper. * Item info mapper.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/29 21:53 * @date 2021/6/29 21:53

@ -5,7 +5,7 @@ import com.github.dynamic.threadpool.config.model.TenantInfo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**
* Tenant Info Mapper. * Tenant info mapper.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/29 22:44 * @date 2021/6/29 22:44

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

@ -11,7 +11,7 @@ import lombok.Data;
import java.util.Date; import java.util.Date;
/** /**
* * Config all info.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/20 15:14 * @date 2021/6/20 15:14
@ -23,28 +23,28 @@ public class ConfigAllInfo extends ConfigInfo implements PoolParameter {
private static final long serialVersionUID = -2417394244017463665L; private static final long serialVersionUID = -2417394244017463665L;
/** /**
* * desc
*/ */
@JSONField(serialize = false) @JSONField(serialize = false)
@TableField(exist = false, fill = FieldFill.UPDATE) @TableField(exist = false, fill = FieldFill.UPDATE)
private String desc; private String desc;
/** /**
* * gmtCreate
*/ */
@JSONField(serialize = false) @JSONField(serialize = false)
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private Date gmtCreate; private Date gmtCreate;
/** /**
* * gmtModified
*/ */
@JSONField(serialize = false) @JSONField(serialize = false)
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT_UPDATE)
private Date gmtModified; private Date gmtModified;
/** /**
* * delFlag
*/ */
@TableLogic @TableLogic
@JSONField(serialize = false) @JSONField(serialize = false)

@ -3,7 +3,7 @@ package com.github.dynamic.threadpool.config.model;
import lombok.Data; import lombok.Data;
/** /**
* * Config info.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/20 15:59 * @date 2021/6/20 15:59

@ -8,7 +8,7 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
/** /**
* * Config info base.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/20 14:05 * @date 2021/6/20 14:05
@ -40,47 +40,47 @@ public class ConfigInfoBase implements Serializable {
private String itemId; private String itemId;
/** /**
* 线 * coreSize
*/ */
private Integer coreSize; private Integer coreSize;
/** /**
* 线 * maxSize
*/ */
private Integer maxSize; private Integer maxSize;
/** /**
* * queueType
*/ */
private Integer queueType; private Integer queueType;
/** /**
* * capacity
*/ */
private Integer capacity; private Integer capacity;
/** /**
* 线 * keepAliveTime
*/ */
private Integer keepAliveTime; private Integer keepAliveTime;
/** /**
* * rejectedType
*/ */
private Integer rejectedType; private Integer rejectedType;
/** /**
* * isAlarm
*/ */
private Integer isAlarm; private Integer isAlarm;
/** /**
* * capacityAlarm
*/ */
private Integer capacityAlarm; private Integer capacityAlarm;
/** /**
* * livenessAlarm
*/ */
private Integer livenessAlarm; private Integer livenessAlarm;
@ -91,8 +91,9 @@ public class ConfigInfoBase implements Serializable {
private String md5; private String md5;
/** /**
* * content
*/ */
@JSONField(serialize = false) @JSONField(serialize = false)
private String content; private String content;
} }

@ -6,7 +6,7 @@ import lombok.Data;
import java.util.Date; import java.util.Date;
/** /**
* Item Info. * Item info.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/29 21:53 * @date 2021/6/29 21:53
@ -22,44 +22,44 @@ public class ItemInfo {
private Integer id; private Integer id;
/** /**
* ID * tenantId
*/ */
private String tenantId; private String tenantId;
/** /**
* ID * itemId
*/ */
private String itemId; private String itemId;
/** /**
* * itemName
*/ */
private String itemName; private String itemName;
/** /**
* * itemDesc
*/ */
private String itemDesc; private String itemDesc;
/** /**
* * owner
*/ */
private String owner; private String owner;
/** /**
* * gmtCreate
*/ */
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private Date gmtCreate; private Date gmtCreate;
/** /**
* * gmtModified
*/ */
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT_UPDATE)
private Date gmtModified; private Date gmtModified;
/** /**
* * delFlag
*/ */
@TableLogic @TableLogic
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)

@ -6,7 +6,7 @@ import lombok.Data;
import java.util.Date; import java.util.Date;
/** /**
* 线 * Tenant info.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/29 22:04 * @date 2021/6/29 22:04
@ -22,39 +22,39 @@ public class TenantInfo {
private Integer id; private Integer id;
/** /**
* ID * tenantId
*/ */
private String tenantId; private String tenantId;
/** /**
* * tenantName
*/ */
private String tenantName; private String tenantName;
/** /**
* * tenantDesc
*/ */
private String tenantDesc; private String tenantDesc;
/** /**
* * owner
*/ */
private String owner; private String owner;
/** /**
* * gmtCreate
*/ */
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private Date gmtCreate; private Date gmtCreate;
/** /**
* * gmtModified
*/ */
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT_UPDATE)
private Date gmtModified; private Date gmtModified;
/** /**
* * delFlag
*/ */
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private Integer delFlag; private Integer delFlag;

@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data; import lombok.Data;
/** /**
* Item Query Req DTO. * Item query req dto.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/29 22:28 * @date 2021/6/29 22:28
@ -12,11 +12,24 @@ import lombok.Data;
@Data @Data
public class ItemQueryReqDTO extends Page { public class ItemQueryReqDTO extends Page {
/**
* tenantId
*/
private String tenantId; private String tenantId;
/**
* itemId
*/
private String itemId; private String itemId;
/**
* itemName
*/
private String itemName; private String itemName;
/**
* owner
*/
private String owner; private String owner;
} }

@ -6,7 +6,7 @@ import lombok.Data;
import java.util.Date; import java.util.Date;
/** /**
* * Item resp dto.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/29 21:15 * @date 2021/6/29 21:15
@ -20,38 +20,38 @@ public class ItemRespDTO {
private Integer id; private Integer id;
/** /**
* ID * tenantId
*/ */
private String tenantId; private String tenantId;
/** /**
* ID * itemId
*/ */
private String itemId; private String itemId;
/** /**
* * itemName
*/ */
private String itemName; private String itemName;
/** /**
* * itemDesc
*/ */
private String itemDesc; private String itemDesc;
/** /**
* * owner
*/ */
private String owner; private String owner;
/** /**
* * 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;

@ -3,7 +3,7 @@ package com.github.dynamic.threadpool.config.model.biz.item;
import lombok.Data; import lombok.Data;
/** /**
* Item Save Req DTO. * Item save req dto.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/29 22:05 * @date 2021/6/29 22:05
@ -12,27 +12,27 @@ import lombok.Data;
public class ItemSaveReqDTO { public class ItemSaveReqDTO {
/** /**
* ID * tenantId
*/ */
private String tenantId; private String tenantId;
/** /**
* ID * itemId
*/ */
private String itemId; private String itemId;
/** /**
* * itemName
*/ */
private String itemName; private String itemName;
/** /**
* * itemDesc
*/ */
private String itemDesc; private String itemDesc;
/** /**
* * owner
*/ */
private String owner; private String owner;

@ -3,7 +3,7 @@ package com.github.dynamic.threadpool.config.model.biz.item;
import lombok.Data; import lombok.Data;
/** /**
* Item Update Req DTO. * Item update req dto.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/29 22:05 * @date 2021/6/29 22:05

@ -4,7 +4,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 * @author chen.ma
* @date 2021/6/29 22:28 * @date 2021/6/29 22:28
@ -12,9 +12,19 @@ import lombok.Data;
@Data @Data
public class TenantQueryReqDTO extends Page { public class TenantQueryReqDTO extends Page {
/**
* tenantId
*/
private String tenantId; private String tenantId;
/**
* tenantName
*/
private String tenantName; private String tenantName;
/**
* owner
*/
private String owner; private String owner;
} }

@ -6,7 +6,7 @@ import lombok.Data;
import java.util.Date; import java.util.Date;
/** /**
* 线 * Tenant resp dto.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/29 21:16 * @date 2021/6/29 21:16
@ -20,33 +20,33 @@ public class TenantRespDTO {
private Integer id; private Integer id;
/** /**
* ID * tenantId
*/ */
private String tenantId; private String tenantId;
/** /**
* * tenantName
*/ */
private String tenantName; private String tenantName;
/** /**
* * tenantDesc
*/ */
private String tenantDesc; private String tenantDesc;
/** /**
* * owner
*/ */
private String owner; private String owner;
/** /**
* * 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;

@ -3,7 +3,7 @@ package com.github.dynamic.threadpool.config.model.biz.tenant;
import lombok.Data; import lombok.Data;
/** /**
* Tenant Save Req DTO. * Tenant save req dto.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/29 20:40 * @date 2021/6/29 20:40
@ -12,22 +12,22 @@ import lombok.Data;
public class TenantSaveReqDTO { public class TenantSaveReqDTO {
/** /**
* ID * tenantId
*/ */
private String tenantId; private String tenantId;
/** /**
* * tenantName
*/ */
private String tenantName; private String tenantName;
/** /**
* * tenantDesc
*/ */
private String tenantDesc; private String tenantDesc;
/** /**
* * owner
*/ */
private String owner; private String owner;

@ -3,7 +3,7 @@ package com.github.dynamic.threadpool.config.model.biz.tenant;
import lombok.Data; import lombok.Data;
/** /**
* Tenant Save Req DTO. * Tenant save req dto.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/29 20:40 * @date 2021/6/29 20:40
@ -12,22 +12,22 @@ import lombok.Data;
public class TenantUpdateReqDTO { public class TenantUpdateReqDTO {
/** /**
* ID * tenantId
*/ */
private String tenantId; private String tenantId;
/** /**
* * tenantName
*/ */
private String tenantName; private String tenantName;
/** /**
* * tenantDesc
*/ */
private String tenantDesc; private String tenantDesc;
/** /**
* * owner
*/ */
private String owner; private String owner;

@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data; import lombok.Data;
/** /**
* Thread Pool Query Req DTO. * Thread pool query req dto.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/30 21:22 * @date 2021/6/30 21:22
@ -13,17 +13,17 @@ import lombok.Data;
public class ThreadPoolQueryReqDTO extends Page { public class ThreadPoolQueryReqDTO extends Page {
/** /**
* ID * tenantId
*/ */
private String tenantId; private String tenantId;
/** /**
* ID * itemId
*/ */
private String itemId; private String itemId;
/** /**
* 线 ID * tpId
*/ */
private String tpId; private String tpId;

@ -6,7 +6,7 @@ import lombok.Data;
import java.util.Date; import java.util.Date;
/** /**
* Thread Pool Resp DTO. * Thread pool resp dto.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/30 21:23 * @date 2021/6/30 21:23
@ -15,73 +15,73 @@ import java.util.Date;
public class ThreadPoolRespDTO { public class ThreadPoolRespDTO {
/** /**
* * tenantId
*/ */
private String tenantId; private String tenantId;
/** /**
* Id * itemId
*/ */
private String itemId; private String itemId;
/** /**
* 线 Id * tpId
*/ */
private String tpId; private String tpId;
/** /**
* * content
*/ */
private String content; private String content;
/** /**
* 线 * coreSize
*/ */
private Integer coreSize; private Integer coreSize;
/** /**
* 线 * maxSize
*/ */
private Integer maxSize; private Integer maxSize;
/** /**
* * queueType
*/ */
private Integer queueType; private Integer queueType;
/** /**
* * capacity
*/ */
private Integer capacity; private Integer capacity;
/** /**
* 线 * keepAliveTime
*/ */
private Integer keepAliveTime; private Integer keepAliveTime;
/** /**
* * isAlarm
*/ */
private Integer isAlarm; private Integer isAlarm;
/** /**
* * capacityAlarm
*/ */
private Integer capacityAlarm; private Integer capacityAlarm;
/** /**
* * livenessAlarm
*/ */
private Integer livenessAlarm; private Integer livenessAlarm;
/** /**
* * 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;

@ -3,7 +3,7 @@ package com.github.dynamic.threadpool.config.model.biz.threadpool;
import lombok.Data; import lombok.Data;
/** /**
* Thread Pool Save Or Update Req DTO. * Thread pool save or update req dto.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/30 21:23 * @date 2021/6/30 21:23
@ -27,42 +27,42 @@ public class ThreadPoolSaveOrUpdateReqDTO {
private String itemId; private String itemId;
/** /**
* 线 * coreSize
*/ */
private Integer coreSize; private Integer coreSize;
/** /**
* 线 * maxSize
*/ */
private Integer maxSize; private Integer maxSize;
/** /**
* * queueType
*/ */
private Integer queueType; private Integer queueType;
/** /**
* * capacity
*/ */
private Integer capacity; private Integer capacity;
/** /**
* 线 * keepAliveTime
*/ */
private Integer keepAliveTime; private Integer keepAliveTime;
/** /**
* * isAlarm
*/ */
private Integer isAlarm; private Integer isAlarm;
/** /**
* * capacityAlarm
*/ */
private Integer capacityAlarm; private Integer capacityAlarm;
/** /**
* * livenessAlarm
*/ */
private Integer livenessAlarm; private Integer livenessAlarm;

@ -85,7 +85,7 @@ public class DefaultPublisher extends Thread implements EventPublisher {
UPDATER.compareAndSet(this, lastEventSequence, Math.max(lastEventSequence, event.sequence())); UPDATER.compareAndSet(this, lastEventSequence, Math.max(lastEventSequence, event.sequence()));
} }
} catch (Throwable ex) { } catch (Throwable ex) {
log.error("Event listener exception : {}", ex); log.error("Event listener exception :: {}", ex);
} }
} }
@ -98,7 +98,7 @@ public class DefaultPublisher extends Thread implements EventPublisher {
public boolean publish(Event event) { public boolean publish(Event event) {
boolean success = this.queue.offer(event); boolean success = this.queue.offer(event);
if (!success) { if (!success) {
log.warn("Unable to plug in due to interruption, synchronize sending time, event : {}", event); log.warn("Unable to plug in due to interruption, synchronize sending time, event :: {}", event);
receiveEvent(event); receiveEvent(event);
return true; return true;
} }
@ -117,7 +117,7 @@ public class DefaultPublisher extends Thread implements EventPublisher {
try { try {
job.run(); job.run();
} catch (Throwable e) { } catch (Throwable e) {
log.error("Event callback exception : {}", e); log.error("Event callback exception :: {}", e);
} }
} }
} }

@ -12,7 +12,7 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
/** /**
* Default Share Publisher. * Default share publisher.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/23 19:05 * @date 2021/6/23 19:05
@ -43,4 +43,5 @@ public class DefaultSharePublisher extends DefaultPublisher {
lock.unlock(); lock.unlock();
} }
} }
} }

@ -11,12 +11,35 @@ import com.github.dynamic.threadpool.config.event.Event;
*/ */
public interface EventPublisher { public interface EventPublisher {
/**
* Init.
*
* @param type
* @param bufferSize
*/
void init(Class<? extends Event> type, int bufferSize); void init(Class<? extends Event> type, int bufferSize);
/**
* Add subscriber.
*
* @param subscriber
*/
void addSubscriber(Subscriber subscriber); void addSubscriber(Subscriber subscriber);
/**
* Publish.
*
* @param event
* @return
*/
boolean publish(Event event); boolean publish(Event event);
/**
* Notify subscriber.
*
* @param subscriber
* @param event
*/
void notifySubscriber(Subscriber subscriber, Event event); void notifySubscriber(Subscriber subscriber, Event event);
} }

@ -13,7 +13,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiFunction; import java.util.function.BiFunction;
/** /**
* Unified Event Notify Center. * Unified event notify center.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/23 18:58 * @date 2021/6/23 18:58
@ -44,7 +44,7 @@ public class NotifyCenter {
publisher.init(cls, buffer); publisher.init(cls, buffer);
return publisher; return publisher;
} catch (Throwable ex) { } catch (Throwable ex) {
log.error("Service class newInstance has error : {}", ex); log.error("Service class newInstance has error :: {}", ex);
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
}; };
@ -87,7 +87,7 @@ public class NotifyCenter {
try { try {
return publishEvent(event.getClass(), event); return publishEvent(event.getClass(), event);
} catch (Throwable ex) { } catch (Throwable ex) {
log.error("There was an exception to the message publishing : {}", ex); log.error("There was an exception to the message publishing :: {}", ex);
return false; return false;
} }
} }
@ -118,4 +118,5 @@ public class NotifyCenter {
} }
return INSTANCE.publisherMap.get(topic); return INSTANCE.publisherMap.get(topic);
} }
} }

@ -12,5 +12,11 @@ import java.util.List;
*/ */
public abstract class SmartSubscriber extends Subscriber { public abstract class SmartSubscriber extends Subscriber {
/**
* Subscribe types.
*
* @return
*/
public abstract List<Class<? extends Event>> subscribeTypes(); public abstract List<Class<? extends Event>> subscribeTypes();
} }

@ -29,4 +29,5 @@ public abstract class Subscriber<T extends Event> {
public Executor executor() { public Executor executor() {
return null; return null;
} }
} }

@ -14,7 +14,7 @@ import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
/** /**
* Config Cache Service. * Config cache service.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/24 21:19 * @date 2021/6/24 21:19
@ -31,8 +31,8 @@ public class ConfigCacheService {
} }
/** /**
* Md5 * Get Md5.
* TODO IP, IP 线 * TODOAdd IP, different IP thread pool rewrite
* TODOgroupKey && Md5 Cache * TODOgroupKey && Md5 Cache
* *
* @param groupKey * @param groupKey
@ -92,4 +92,5 @@ public class ConfigCacheService {
item = CACHE.putIfAbsent(groupKey, tmp); item = CACHE.putIfAbsent(groupKey, tmp);
return (null == item) ? tmp : item; return (null == item) ? tmp : item;
} }
} }

@ -4,7 +4,7 @@ import com.github.dynamic.threadpool.config.event.LocalDataChangeEvent;
import com.github.dynamic.threadpool.config.notify.NotifyCenter; import com.github.dynamic.threadpool.config.notify.NotifyCenter;
/** /**
* Config Change Publisher. * Config change publisher.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/24 23:34 * @date 2021/6/24 23:34
@ -12,7 +12,7 @@ import com.github.dynamic.threadpool.config.notify.NotifyCenter;
public class ConfigChangePublisher { public class ConfigChangePublisher {
/** /**
* Notify ConfigChange. * Notify configChange.
* *
* @param event * @param event
*/ */

@ -8,7 +8,7 @@ import javax.servlet.http.HttpServletResponse;
import java.util.Map; import java.util.Map;
/** /**
* Config Servlet Inner. * Config servlet inner.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/22 23:13 * @date 2021/6/22 23:13
@ -26,4 +26,5 @@ public class ConfigServletInner {
} }
return HttpServletResponse.SC_OK + ""; return HttpServletResponse.SC_OK + "";
} }
} }

@ -24,7 +24,7 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
* * Long polling service.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/22 23:14 * @date 2021/6/22 23:14
@ -206,7 +206,6 @@ public class LongPollingService {
} }
private void sendResponse(List<String> changedGroups) { private void sendResponse(List<String> changedGroups) {
// Cancel time out task. // Cancel time out task.
if (null != asyncTimeoutFuture) { if (null != asyncTimeoutFuture) {
asyncTimeoutFuture.cancel(false); asyncTimeoutFuture.cancel(false);
@ -245,12 +244,6 @@ public class LongPollingService {
return retainIps; return retainIps;
} }
/**
*
*
* @param response
* @param changedGroups
*/
private void generateResponse(HttpServletResponse response, List<String> changedGroups) { private void generateResponse(HttpServletResponse response, List<String> changedGroups) {
if (!CollectionUtils.isEmpty(changedGroups)) { if (!CollectionUtils.isEmpty(changedGroups)) {
try { try {
@ -266,4 +259,5 @@ public class LongPollingService {
} }
} }
} }
} }

@ -7,7 +7,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
* SwitchService. * Switch service.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/23 18:23 * @date 2021/6/23 18:23
@ -47,4 +47,5 @@ public class SwitchService {
} }
return rtn; return rtn;
} }
} }

@ -3,7 +3,7 @@ package com.github.dynamic.threadpool.config.service.biz;
import com.github.dynamic.threadpool.config.model.ConfigAllInfo; import com.github.dynamic.threadpool.config.model.ConfigAllInfo;
/** /**
* * Config service.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/20 15:18 * @date 2021/6/20 15:18
@ -11,19 +11,20 @@ import com.github.dynamic.threadpool.config.model.ConfigAllInfo;
public interface ConfigService { public interface ConfigService {
/** /**
* * Find config all info.
* *
* @param tpId tpId * @param tpId tpId
* @param itemId itemId * @param itemId itemId
* @param tenantId tenantId * @param tenantId tenantId
* @return * @return all config
*/ */
ConfigAllInfo findConfigAllInfo(String tpId, String itemId, String tenantId); ConfigAllInfo findConfigAllInfo(String tpId, String itemId, String tenantId);
/** /**
* * Insert or update.
* *
* @param configAllInfo * @param configAllInfo
*/ */
void insertOrUpdate(ConfigAllInfo configAllInfo); void insertOrUpdate(ConfigAllInfo configAllInfo);
} }

@ -17,7 +17,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
/** /**
* * Config service impl.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/20 15:21 * @date 2021/6/20 15:21

@ -9,7 +9,7 @@ import com.github.dynamic.threadpool.config.model.biz.item.ItemUpdateReqDTO;
import java.util.List; import java.util.List;
/** /**
* Item Service. * Item service.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/29 21:57 * @date 2021/6/29 21:57
@ -17,7 +17,7 @@ import java.util.List;
public interface ItemService { public interface ItemService {
/** /**
* * Query item page.
* *
* @param reqDTO * @param reqDTO
* @return * @return
@ -25,7 +25,7 @@ public interface ItemService {
IPage<ItemRespDTO> queryItemPage(ItemQueryReqDTO reqDTO); IPage<ItemRespDTO> queryItemPage(ItemQueryReqDTO reqDTO);
/** /**
* Id * Query item by id.
* *
* @param tenantId * @param tenantId
* @param itemId * @param itemId
@ -34,7 +34,7 @@ public interface ItemService {
ItemRespDTO queryItemById(String tenantId, String itemId); ItemRespDTO queryItemById(String tenantId, String itemId);
/** /**
* * Query item.
* *
* @param reqDTO * @param reqDTO
* @return * @return
@ -42,24 +42,25 @@ public interface ItemService {
List<ItemRespDTO> queryItem(ItemQueryReqDTO reqDTO); List<ItemRespDTO> queryItem(ItemQueryReqDTO reqDTO);
/** /**
* * Save item.
* *
* @param reqDTO * @param reqDTO
*/ */
void saveItem(ItemSaveReqDTO reqDTO); void saveItem(ItemSaveReqDTO reqDTO);
/** /**
* * Update item.
* *
* @param reqDTO * @param reqDTO
*/ */
void updateItem(ItemUpdateReqDTO reqDTO); void updateItem(ItemUpdateReqDTO reqDTO);
/** /**
* * Delete item.
* *
* @param tenantId * @param tenantId
* @param itemId * @param itemId
*/ */
void deleteItem(String tenantId, String itemId); void deleteItem(String tenantId, String itemId);
} }

@ -23,7 +23,7 @@ import javax.annotation.Resource;
import java.util.List; import java.util.List;
/** /**
* Item Service Impl. * Item service impl.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/29 21:58 * @date 2021/6/29 21:58
@ -78,7 +78,7 @@ public class ItemServiceImpl implements ItemService {
boolean retBool = SqlHelper.retBool(insertResult); boolean retBool = SqlHelper.retBool(insertResult);
if (!retBool) { if (!retBool) {
throw new RuntimeException("插入失败."); throw new RuntimeException("Save error");
} }
} }
@ -92,7 +92,7 @@ public class ItemServiceImpl implements ItemService {
boolean retBool = SqlHelper.retBool(updateResult); boolean retBool = SqlHelper.retBool(updateResult);
if (!retBool) { if (!retBool) {
throw new RuntimeException("修改失败."); throw new RuntimeException("Update error.");
} }
} }
@ -100,7 +100,7 @@ public class ItemServiceImpl implements ItemService {
public void deleteItem(String namespace, String itemId) { public void deleteItem(String namespace, String itemId) {
List<ThreadPoolRespDTO> itemList = threadPoolService.getThreadPoolByItemId(itemId); List<ThreadPoolRespDTO> itemList = threadPoolService.getThreadPoolByItemId(itemId);
if (CollectionUtils.isNotEmpty(itemList)) { if (CollectionUtils.isNotEmpty(itemList)) {
throw new RuntimeException("项目包含线程池引用, 删除失败."); throw new RuntimeException("The project contains a thread pool reference, and the deletion failed.");
} }
int updateResult = itemInfoMapper.update(new ItemInfo(), int updateResult = itemInfoMapper.update(new ItemInfo(),
@ -110,7 +110,7 @@ public class ItemServiceImpl implements ItemService {
.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("删除失败."); throw new RuntimeException("Delete error.");
} }
} }

@ -7,7 +7,7 @@ import com.github.dynamic.threadpool.config.model.biz.tenant.TenantSaveReqDTO;
import com.github.dynamic.threadpool.config.model.biz.tenant.TenantUpdateReqDTO; import com.github.dynamic.threadpool.config.model.biz.tenant.TenantUpdateReqDTO;
/** /**
* * Tenant service.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/29 21:59 * @date 2021/6/29 21:59
@ -15,7 +15,7 @@ import com.github.dynamic.threadpool.config.model.biz.tenant.TenantUpdateReqDTO;
public interface TenantService { public interface TenantService {
/** /**
* Id * Get tenant by id.
* *
* @param tenantIdId * @param tenantIdId
* @return * @return
@ -23,7 +23,7 @@ public interface TenantService {
TenantRespDTO getTenantById(String tenantIdId); TenantRespDTO getTenantById(String tenantIdId);
/** /**
* * Query tenant page.
* *
* @param reqDTO * @param reqDTO
* @return * @return
@ -31,21 +31,21 @@ public interface TenantService {
IPage<TenantRespDTO> queryTenantPage(TenantQueryReqDTO reqDTO); IPage<TenantRespDTO> queryTenantPage(TenantQueryReqDTO reqDTO);
/** /**
* * Save tenant.
* *
* @param reqDTO * @param reqDTO
*/ */
void saveTenant(TenantSaveReqDTO reqDTO); void saveTenant(TenantSaveReqDTO reqDTO);
/** /**
* * Update tenant.
* *
* @param reqDTO * @param reqDTO
*/ */
void updateTenant(TenantUpdateReqDTO reqDTO); void updateTenant(TenantUpdateReqDTO reqDTO);
/** /**
* Id * Delete tenant by id.
* *
* @param tenantId * @param tenantId
*/ */

@ -24,7 +24,7 @@ import javax.annotation.Resource;
import java.util.List; import java.util.List;
/** /**
* * Tenant service impl.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/29 21:12 * @date 2021/6/29 21:12
@ -66,7 +66,7 @@ public class TenantServiceImpl implements TenantService {
boolean retBool = SqlHelper.retBool(insertResult); boolean retBool = SqlHelper.retBool(insertResult);
if (!retBool) { if (!retBool) {
throw new RuntimeException("插入失败."); throw new RuntimeException("Save Error.");
} }
} }
@ -77,7 +77,7 @@ public class TenantServiceImpl implements TenantService {
.lambdaUpdate(TenantInfo.class).eq(TenantInfo::getTenantId, reqDTO.getTenantId())); .lambdaUpdate(TenantInfo.class).eq(TenantInfo::getTenantId, reqDTO.getTenantId()));
boolean retBool = SqlHelper.retBool(updateResult); boolean retBool = SqlHelper.retBool(updateResult);
if (!retBool) { if (!retBool) {
throw new RuntimeException("修改失败."); throw new RuntimeException("Update Error.");
} }
} }
@ -87,7 +87,7 @@ public class TenantServiceImpl implements TenantService {
reqDTO.setTenantId(tenantId); reqDTO.setTenantId(tenantId);
List<ItemRespDTO> itemList = itemService.queryItem(reqDTO); List<ItemRespDTO> itemList = itemService.queryItem(reqDTO);
if (CollectionUtils.isNotEmpty(itemList)) { if (CollectionUtils.isNotEmpty(itemList)) {
throw new RuntimeException("业务线包含项目引用, 删除失败."); throw new RuntimeException("The line of business contains project references, and the deletion failed.");
} }
int updateResult = tenantInfoMapper.update(new TenantInfo(), int updateResult = tenantInfoMapper.update(new TenantInfo(),
@ -96,7 +96,7 @@ public class TenantServiceImpl implements TenantService {
.set(TenantInfo::getDelFlag, DelEnum.DELETE.getIntCode())); .set(TenantInfo::getDelFlag, DelEnum.DELETE.getIntCode()));
boolean retBool = SqlHelper.retBool(updateResult); boolean retBool = SqlHelper.retBool(updateResult);
if (!retBool) { if (!retBool) {
throw new RuntimeException("删除失败."); throw new RuntimeException("Delete error.");
} }
} }
} }

@ -8,7 +8,7 @@ import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolSaveO
import java.util.List; import java.util.List;
/** /**
* Thread Pool Service. * Thread pool service.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/30 21:26 * @date 2021/6/30 21:26
@ -16,7 +16,7 @@ import java.util.List;
public interface ThreadPoolService { public interface ThreadPoolService {
/** /**
* 线 * Query thread pool page.
* *
* @param reqDTO * @param reqDTO
* @return * @return
@ -24,7 +24,7 @@ public interface ThreadPoolService {
IPage<ThreadPoolRespDTO> queryThreadPoolPage(ThreadPoolQueryReqDTO reqDTO); IPage<ThreadPoolRespDTO> queryThreadPoolPage(ThreadPoolQueryReqDTO reqDTO);
/** /**
* 线 * Get thread pool.
* *
* @param reqDTO * @param reqDTO
* @return * @return
@ -32,7 +32,7 @@ public interface ThreadPoolService {
ThreadPoolRespDTO getThreadPool(ThreadPoolQueryReqDTO reqDTO); ThreadPoolRespDTO getThreadPool(ThreadPoolQueryReqDTO reqDTO);
/** /**
* ItemId 线 * Get thread pool by item id.
* *
* @param itemId * @param itemId
* @return * @return
@ -40,7 +40,7 @@ public interface ThreadPoolService {
List<ThreadPoolRespDTO> getThreadPoolByItemId(String itemId); List<ThreadPoolRespDTO> getThreadPoolByItemId(String itemId);
/** /**
* 线 * Save or update thread pool config.
* *
* @param reqDTO * @param reqDTO
*/ */

@ -17,7 +17,7 @@ import javax.annotation.Resource;
import java.util.List; import java.util.List;
/** /**
* Thread Pool Service Impl. * Thread pool service impl.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/30 21:26 * @date 2021/6/30 21:26
@ -57,4 +57,5 @@ public class ThreadPoolServiceImpl implements ThreadPoolService {
public void saveOrUpdateThreadPoolConfig(ThreadPoolSaveOrUpdateReqDTO reqDTO) { public void saveOrUpdateThreadPoolConfig(ThreadPoolSaveOrUpdateReqDTO reqDTO) {
configService.insertOrUpdate(BeanUtil.convert(reqDTO, ConfigAllInfo.class)); configService.insertOrUpdate(BeanUtil.convert(reqDTO, ConfigAllInfo.class));
} }
} }

@ -2,16 +2,11 @@ package com.github.dynamic.threadpool.config.toolkit;
import com.github.dozermapper.core.DozerBeanMapperBuilder; import com.github.dozermapper.core.DozerBeanMapperBuilder;
import com.github.dozermapper.core.Mapper; import com.github.dozermapper.core.Mapper;
import com.github.dozermapper.core.loader.api.BeanMappingBuilder;
import java.lang.reflect.Array;
import java.util.*; import java.util.*;
import static com.github.dozermapper.core.loader.api.TypeMappingOptions.mapEmptyString;
import static com.github.dozermapper.core.loader.api.TypeMappingOptions.mapNull;
/** /**
* * Bean util
* *
* @author chen.ma * @author chen.ma
* @date 2021/3/19 15:40 * @date 2021/3/19 15:40
@ -28,30 +23,12 @@ public class BeanUtil {
BEAN_MAPPER_BUILDER = DozerBeanMapperBuilder.buildDefault(); BEAN_MAPPER_BUILDER = DozerBeanMapperBuilder.buildDefault();
} }
/**
*
*
* @param source
* @param clazz
* @param <T>
* @param <S>
* @return
*/
public static <T, S> T convert(S source, Class<T> clazz) { public static <T, S> T convert(S source, Class<T> clazz) {
return Optional.ofNullable(source) return Optional.ofNullable(source)
.map(each -> BEAN_MAPPER_BUILDER.map(each, clazz)) .map(each -> BEAN_MAPPER_BUILDER.map(each, clazz))
.orElse(null); .orElse(null);
} }
/**
*
*
* @param sources
* @param clazz
* @param <T>
* @param <S>
* @return
*/
public static <T, S> List<T> convert(List<S> sources, Class<T> clazz) { public static <T, S> List<T> convert(List<S> sources, Class<T> clazz) {
return Optional.ofNullable(sources) return Optional.ofNullable(sources)
.map(each -> { .map(each -> {
@ -63,15 +40,6 @@ public class BeanUtil {
.orElse(null); .orElse(null);
} }
/**
*
*
* @param sources
* @param clazz
* @param <T>
* @param <S>
* @return
*/
public static <T, S> Set<T> convert(Set<S> sources, Class<T> clazz) { public static <T, S> Set<T> convert(Set<S> sources, Class<T> clazz) {
return Optional.ofNullable(sources) return Optional.ofNullable(sources)
.map(each -> { .map(each -> {
@ -83,60 +51,4 @@ public class BeanUtil {
.orElse(null); .orElse(null);
} }
/**
*
*
* @param sources
* @param clazz
* @param <T>
* @param <S>
* @return
*/
public static <T, S> T[] convert(S[] sources, Class<T> clazz) {
return Optional.ofNullable(sources)
.map(each -> {
@SuppressWarnings("unchecked")
T[] targetArray = (T[]) Array.newInstance(clazz, sources.length);
for (int i = 0; i < targetArray.length; i++) {
targetArray[i] = BEAN_MAPPER_BUILDER.map(sources[i], clazz);
}
return targetArray;
})
.orElse(null);
}
/**
*
*
* @param source
* @param target
*/
public static void convertIgnoreNullAndBlank(Object source, Object target) {
DozerBeanMapperBuilder dozerBeanMapperBuilder = DozerBeanMapperBuilder.create();
Mapper mapper = dozerBeanMapperBuilder.withMappingBuilders(new BeanMappingBuilder() {
@Override
protected void configure() {
mapping(source.getClass(), target.getClass(), mapNull(false), mapEmptyString(false));
}
}).build();
mapper.map(source, target);
}
/**
*
*
* @param source
* @param target
*/
public static void convertIgnoreNull(Object source, Object target) {
DozerBeanMapperBuilder dozerBeanMapperBuilder = DozerBeanMapperBuilder.create();
Mapper mapper = dozerBeanMapperBuilder.withMappingBuilders(new BeanMappingBuilder() {
@Override
protected void configure() {
mapping(source.getClass(), target.getClass(), mapNull(false));
}
}).build();
mapper.map(source, target);
}
} }

@ -3,7 +3,7 @@ package com.github.dynamic.threadpool.config.toolkit;
import java.util.Objects; import java.util.Objects;
/** /**
* Class Util. * Class util.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/23 19:03 * @date 2021/6/23 19:03
@ -19,4 +19,5 @@ public class ClassUtil {
Objects.requireNonNull(cls, "cls"); Objects.requireNonNull(cls, "cls");
return cls.getCanonicalName(); return cls.getCanonicalName();
} }
} }

@ -7,7 +7,7 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
* Config Executor. * Config executor.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/23 18:33 * @date 2021/6/23 18:33
@ -29,4 +29,5 @@ 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);
} }
} }

@ -5,7 +5,7 @@ import java.util.Objects;
import java.util.function.BiFunction; import java.util.function.BiFunction;
/** /**
* Map Util. * Map util.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/23 19:09 * @date 2021/6/23 19:09
@ -27,4 +27,5 @@ public class MapUtil {
} }
return val; return val;
} }
} }

@ -19,7 +19,7 @@ import static com.github.dynamic.threadpool.common.constant.Constants.WORD_SEPAR
/** /**
* Md5 * Md5 config util.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/21 18:32 * @date 2021/6/21 18:32
@ -31,7 +31,7 @@ public class Md5ConfigUtil {
static final char LINE_SEPARATOR_CHAR = (char) 1; static final char LINE_SEPARATOR_CHAR = (char) 1;
/** /**
* ThreadPool Md5 * Get thread pool content md5
* *
* @param config * @param config
* @return * @return
@ -41,7 +41,7 @@ public class Md5ConfigUtil {
} }
/** /**
* Md5 * Compare whether the client Md5 is consistent with the server.
* *
* @param request * @param request
* @param clientMd5Map * @param clientMd5Map
@ -149,4 +149,5 @@ public class Md5ConfigUtil {
return URLEncoder.encode(sb.toString(), "UTF-8"); return URLEncoder.encode(sb.toString(), "UTF-8");
} }
} }

@ -5,7 +5,7 @@ import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
/** /**
* Request Util. * Request util.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/23 18:28 * @date 2021/6/23 18:28
@ -26,4 +26,5 @@ public class RequestUtil {
String nginxHeader = request.getHeader(X_REAL_IP); String nginxHeader = request.getHeader(X_REAL_IP);
return StringUtils.isEmpty(nginxHeader) ? request.getRemoteAddr() : nginxHeader; return StringUtils.isEmpty(nginxHeader) ? request.getRemoteAddr() : nginxHeader;
} }
} }

@ -1,13 +1,15 @@
package com.github.dynamic.threadpool.config.toolkit; package com.github.dynamic.threadpool.config.toolkit;
/** /**
* . * Simple read write lock.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/24 21:26 * @date 2021/6/24 21:26
*/ */
public class SimpleReadWriteLock { public class SimpleReadWriteLock {
private int status = 0;
public synchronized boolean tryReadLock() { public synchronized boolean tryReadLock() {
if (isWriteLocked()) { if (isWriteLocked()) {
return false; return false;
@ -42,5 +44,4 @@ public class SimpleReadWriteLock {
return status == 0; return status == 0;
} }
private int status = 0;
} }

@ -3,7 +3,7 @@ package com.github.dynamic.threadpool.config.toolkit;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
/** /**
* Singleton Repository. * Singleton repository.
* *
* @author chen.ma * @author chen.ma
* @date 2021/6/24 21:28 * @date 2021/6/24 21:28
@ -37,4 +37,5 @@ public class SingletonRepository<T> {
static SingletonRepository<String> cache = new SingletonRepository<String>(); static SingletonRepository<String> cache = new SingletonRepository<String>();
} }
} }

Loading…
Cancel
Save