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;
/**
* .
* Common config.
*
* @author chen.ma
* @date 2021/7/19 21:03

@ -9,7 +9,7 @@ import org.springframework.stereotype.Component;
import java.util.Date;
/**
* Meta Object Handler.
* Meta object handler.
*
* @author chen.ma
* @date 2021/7/1 22:43
@ -17,6 +17,7 @@ import java.util.Date;
@Slf4j
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
this.strictInsertFill(metaObject, "gmtCreate", Date.class, new Date());
@ -29,4 +30,5 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
public void updateFill(MetaObject metaObject) {
this.strictInsertFill(metaObject, "gmtModified", Date.class, new Date());
}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -85,7 +85,7 @@ public class DefaultPublisher extends Thread implements EventPublisher {
UPDATER.compareAndSet(this, lastEventSequence, Math.max(lastEventSequence, event.sequence()));
}
} 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) {
boolean success = this.queue.offer(event);
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);
return true;
}
@ -117,7 +117,7 @@ public class DefaultPublisher extends Thread implements EventPublisher {
try {
job.run();
} 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;
/**
* Default Share Publisher.
* Default share publisher.
*
* @author chen.ma
* @date 2021/6/23 19:05
@ -43,4 +43,5 @@ public class DefaultSharePublisher extends DefaultPublisher {
lock.unlock();
}
}
}

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

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

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

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

@ -14,7 +14,7 @@ import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
/**
* Config Cache Service.
* Config cache service.
*
* @author chen.ma
* @date 2021/6/24 21:19
@ -31,8 +31,8 @@ public class ConfigCacheService {
}
/**
* Md5
* TODO IP, IP 线
* Get Md5.
* TODOAdd IP, different IP thread pool rewrite
* TODOgroupKey && Md5 Cache
*
* @param groupKey
@ -92,4 +92,5 @@ public class ConfigCacheService {
item = CACHE.putIfAbsent(groupKey, tmp);
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;
/**
* Config Change Publisher.
* Config change publisher.
*
* @author chen.ma
* @date 2021/6/24 23:34
@ -12,7 +12,7 @@ import com.github.dynamic.threadpool.config.notify.NotifyCenter;
public class ConfigChangePublisher {
/**
* Notify ConfigChange.
* Notify configChange.
*
* @param event
*/

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

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

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

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

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

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

@ -23,7 +23,7 @@ import javax.annotation.Resource;
import java.util.List;
/**
* Item Service Impl.
* Item service impl.
*
* @author chen.ma
* @date 2021/6/29 21:58
@ -78,7 +78,7 @@ public class ItemServiceImpl implements ItemService {
boolean retBool = SqlHelper.retBool(insertResult);
if (!retBool) {
throw new RuntimeException("插入失败.");
throw new RuntimeException("Save error");
}
}
@ -92,7 +92,7 @@ public class ItemServiceImpl implements ItemService {
boolean retBool = SqlHelper.retBool(updateResult);
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) {
List<ThreadPoolRespDTO> itemList = threadPoolService.getThreadPoolByItemId(itemId);
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(),
@ -110,7 +110,7 @@ public class ItemServiceImpl implements ItemService {
.set(ItemInfo::getDelFlag, DelEnum.DELETE.getIntCode()));
boolean retBool = SqlHelper.retBool(updateResult);
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;
/**
*
* Tenant service.
*
* @author chen.ma
* @date 2021/6/29 21:59
@ -15,7 +15,7 @@ import com.github.dynamic.threadpool.config.model.biz.tenant.TenantUpdateReqDTO;
public interface TenantService {
/**
* Id
* Get tenant by id.
*
* @param tenantIdId
* @return
@ -23,7 +23,7 @@ public interface TenantService {
TenantRespDTO getTenantById(String tenantIdId);
/**
*
* Query tenant page.
*
* @param reqDTO
* @return
@ -31,21 +31,21 @@ public interface TenantService {
IPage<TenantRespDTO> queryTenantPage(TenantQueryReqDTO reqDTO);
/**
*
* Save tenant.
*
* @param reqDTO
*/
void saveTenant(TenantSaveReqDTO reqDTO);
/**
*
* Update tenant.
*
* @param reqDTO
*/
void updateTenant(TenantUpdateReqDTO reqDTO);
/**
* Id
* Delete tenant by id.
*
* @param tenantId
*/

@ -24,7 +24,7 @@ import javax.annotation.Resource;
import java.util.List;
/**
*
* Tenant service impl.
*
* @author chen.ma
* @date 2021/6/29 21:12
@ -66,7 +66,7 @@ public class TenantServiceImpl implements TenantService {
boolean retBool = SqlHelper.retBool(insertResult);
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()));
boolean retBool = SqlHelper.retBool(updateResult);
if (!retBool) {
throw new RuntimeException("修改失败.");
throw new RuntimeException("Update Error.");
}
}
@ -87,7 +87,7 @@ public class TenantServiceImpl implements TenantService {
reqDTO.setTenantId(tenantId);
List<ItemRespDTO> itemList = itemService.queryItem(reqDTO);
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(),
@ -96,7 +96,7 @@ public class TenantServiceImpl implements TenantService {
.set(TenantInfo::getDelFlag, DelEnum.DELETE.getIntCode()));
boolean retBool = SqlHelper.retBool(updateResult);
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;
/**
* Thread Pool Service.
* Thread pool service.
*
* @author chen.ma
* @date 2021/6/30 21:26
@ -16,7 +16,7 @@ import java.util.List;
public interface ThreadPoolService {
/**
* 线
* Query thread pool page.
*
* @param reqDTO
* @return
@ -24,7 +24,7 @@ public interface ThreadPoolService {
IPage<ThreadPoolRespDTO> queryThreadPoolPage(ThreadPoolQueryReqDTO reqDTO);
/**
* 线
* Get thread pool.
*
* @param reqDTO
* @return
@ -32,7 +32,7 @@ public interface ThreadPoolService {
ThreadPoolRespDTO getThreadPool(ThreadPoolQueryReqDTO reqDTO);
/**
* ItemId 线
* Get thread pool by item id.
*
* @param itemId
* @return
@ -40,7 +40,7 @@ public interface ThreadPoolService {
List<ThreadPoolRespDTO> getThreadPoolByItemId(String itemId);
/**
* 线
* Save or update thread pool config.
*
* @param reqDTO
*/

@ -17,7 +17,7 @@ import javax.annotation.Resource;
import java.util.List;
/**
* Thread Pool Service Impl.
* Thread pool service impl.
*
* @author chen.ma
* @date 2021/6/30 21:26
@ -57,4 +57,5 @@ public class ThreadPoolServiceImpl implements ThreadPoolService {
public void saveOrUpdateThreadPoolConfig(ThreadPoolSaveOrUpdateReqDTO reqDTO) {
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.Mapper;
import com.github.dozermapper.core.loader.api.BeanMappingBuilder;
import java.lang.reflect.Array;
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
* @date 2021/3/19 15:40
@ -28,30 +23,12 @@ public class BeanUtil {
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) {
return Optional.ofNullable(source)
.map(each -> BEAN_MAPPER_BUILDER.map(each, clazz))
.orElse(null);
}
/**
*
*
* @param sources
* @param clazz
* @param <T>
* @param <S>
* @return
*/
public static <T, S> List<T> convert(List<S> sources, Class<T> clazz) {
return Optional.ofNullable(sources)
.map(each -> {
@ -63,15 +40,6 @@ public class BeanUtil {
.orElse(null);
}
/**
*
*
* @param sources
* @param clazz
* @param <T>
* @param <S>
* @return
*/
public static <T, S> Set<T> convert(Set<S> sources, Class<T> clazz) {
return Optional.ofNullable(sources)
.map(each -> {
@ -83,60 +51,4 @@ public class BeanUtil {
.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;
/**
* Class Util.
* Class util.
*
* @author chen.ma
* @date 2021/6/23 19:03
@ -19,4 +19,5 @@ public class ClassUtil {
Objects.requireNonNull(cls, "cls");
return cls.getCanonicalName();
}
}

@ -7,7 +7,7 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
/**
* Config Executor.
* Config executor.
*
* @author chen.ma
* @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) {
LONG_POLLING_EXECUTOR.scheduleWithFixedDelay(runnable, initialDelay, period, unit);
}
}

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

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

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

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

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

Loading…
Cancel
Save