mirror of https://github.com/longtai-cn/hippo4j
parent
3644f97a78
commit
e12b34c2e2
@ -1,37 +0,0 @@
|
|||||||
package io.dtp.server.model;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基础配置信息
|
|
||||||
*
|
|
||||||
* @author chen.ma
|
|
||||||
* @date 2021/6/20 14:05
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class ConfigInfoBase implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -1892597426099265730L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TpId
|
|
||||||
*/
|
|
||||||
private String tpId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ItemId
|
|
||||||
*/
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 内容
|
|
||||||
*/
|
|
||||||
private String content;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MD5
|
|
||||||
*/
|
|
||||||
private String md5;
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=io.dtp.starter.config.CommonConfiguration, \
|
|
||||||
io.dtp.starter.config.OkHttpClientConfig
|
|
@ -1,4 +1,4 @@
|
|||||||
package io.dtp.starter.common;
|
package io.dynamic.threadpool.starter.common;
|
||||||
|
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package io.dtp.starter.common;
|
package io.dynamic.threadpool.starter.common;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
@ -1,4 +1,4 @@
|
|||||||
package io.dtp.starter.config;
|
package io.dynamic.threadpool.starter.config;
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
@ -1,6 +1,6 @@
|
|||||||
package io.dtp.starter.config;
|
package io.dynamic.threadpool.starter.config;
|
||||||
|
|
||||||
import io.dtp.starter.core.ThreadPoolRunListener;
|
import io.dynamic.threadpool.starter.core.ThreadPoolRunListener;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
package io.dtp.starter.config;
|
package io.dynamic.threadpool.starter.config;
|
||||||
|
|
||||||
import io.dtp.starter.toolkit.HttpClientUtil;
|
import io.dynamic.threadpool.starter.toolkit.HttpClientUtil;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
@ -1,6 +1,6 @@
|
|||||||
package io.dtp.starter.core;
|
package io.dynamic.threadpool.starter.core;
|
||||||
|
|
||||||
import io.dtp.starter.wrap.DynamicThreadPoolWrap;
|
import io.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrap;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
@ -1,4 +1,4 @@
|
|||||||
package io.dtp.starter.core;
|
package io.dynamic.threadpool.starter.core;
|
||||||
|
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
@ -1,11 +1,11 @@
|
|||||||
package io.dtp.starter.core;
|
package io.dynamic.threadpool.starter.core;
|
||||||
|
|
||||||
import io.dtp.starter.common.CommonThreadPool;
|
import io.dynamic.threadpool.starter.common.CommonThreadPool;
|
||||||
import io.dtp.starter.config.ApplicationContextHolder;
|
import io.dynamic.threadpool.starter.config.ApplicationContextHolder;
|
||||||
import io.dtp.starter.model.PoolParameterInfo;
|
import io.dynamic.threadpool.starter.model.PoolParameterInfo;
|
||||||
import io.dtp.starter.toolkit.BlockingQueueUtil;
|
import io.dynamic.threadpool.starter.toolkit.BlockingQueueUtil;
|
||||||
import io.dtp.starter.toolkit.HttpClientUtil;
|
import io.dynamic.threadpool.starter.toolkit.HttpClientUtil;
|
||||||
import io.dtp.starter.wrap.DynamicThreadPoolWrap;
|
import io.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrap;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
@ -0,0 +1,10 @@
|
|||||||
|
package io.dynamic.threadpool.starter.listener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户端监听
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2021/6/20 18:34
|
||||||
|
*/
|
||||||
|
public class ClientWorker {
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package io.dynamic.threadpool.starter.listener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 长轮询执行
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2021/6/20 18:37
|
||||||
|
*/
|
||||||
|
public class LongPollingRunnable implements Runnable {
|
||||||
|
|
||||||
|
private final int taskId;
|
||||||
|
|
||||||
|
public LongPollingRunnable(Integer taskId) {
|
||||||
|
this.taskId = taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package io.dtp.starter.monitor;
|
package io.dynamic.threadpool.starter.monitor;
|
||||||
|
|
||||||
import io.dtp.starter.core.GlobalThreadPoolManage;
|
import io.dynamic.threadpool.starter.core.GlobalThreadPoolManage;
|
||||||
import io.dtp.starter.core.ResizableCapacityLinkedBlockIngQueue;
|
import io.dynamic.threadpool.starter.core.ResizableCapacityLinkedBlockIngQueue;
|
||||||
import io.dtp.starter.wrap.DynamicThreadPoolWrap;
|
import io.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrap;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
@ -1,6 +1,6 @@
|
|||||||
package io.dtp.starter.toolkit;
|
package io.dynamic.threadpool.starter.toolkit;
|
||||||
|
|
||||||
import io.dtp.starter.core.ResizableCapacityLinkedBlockIngQueue;
|
import io.dynamic.threadpool.starter.core.ResizableCapacityLinkedBlockIngQueue;
|
||||||
|
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
@ -1,4 +1,4 @@
|
|||||||
package io.dtp.starter.toolkit;
|
package io.dynamic.threadpool.starter.toolkit;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
@ -0,0 +1,2 @@
|
|||||||
|
org.springframework.boot.autoconfigure.EnableAutoConfiguration=io.dynamic.threadpool.starter.config.CommonConfiguration, \
|
||||||
|
io.dynamic.threadpool.starter.config.OkHttpClientConfig
|
@ -1,6 +1,6 @@
|
|||||||
package io.dtp.starter.test;
|
package io.dynamic.threadpool.starter.test;
|
||||||
|
|
||||||
import io.dtp.starter.core.ResizableCapacityLinkedBlockIngQueue;
|
import io.dynamic.threadpool.starter.core.ResizableCapacityLinkedBlockIngQueue;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
@ -1,4 +1,4 @@
|
|||||||
package io.dtp.example;
|
package io.dynamic.threadpool.example;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
@ -1,4 +1,4 @@
|
|||||||
package io.dtp.example.config;
|
package io.dynamic.threadpool.example.config;
|
||||||
|
|
||||||
import io.dtp.starter.wrap.DynamicThreadPoolWrap;
|
import io.dtp.starter.wrap.DynamicThreadPoolWrap;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
@ -1,4 +1,4 @@
|
|||||||
package io.dtp.example;
|
package io.dynamic.threadpool.example;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
@ -1,4 +1,4 @@
|
|||||||
package io.dtp.server;
|
package io.dynamic.threadpool.server;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
@ -1,4 +1,4 @@
|
|||||||
package io.dtp.server.constant;
|
package io.dynamic.threadpool.server.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务端常量类
|
* 服务端常量类
|
@ -1,8 +1,8 @@
|
|||||||
package io.dtp.server.controller;
|
package io.dynamic.threadpool.server.controller;
|
||||||
|
|
||||||
import io.dtp.server.constant.Constants;
|
import io.dynamic.threadpool.server.constant.Constants;
|
||||||
import io.dtp.server.model.ConfigInfoBase;
|
import io.dynamic.threadpool.server.model.ConfigInfoBase;
|
||||||
import io.dtp.server.service.ConfigService;
|
import io.dynamic.threadpool.server.service.ConfigService;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
@ -1,4 +1,4 @@
|
|||||||
package io.dtp.server.model;
|
package io.dynamic.threadpool.server.model;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package io.dtp.server.model;
|
package io.dynamic.threadpool.server.model;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -0,0 +1,77 @@
|
|||||||
|
package io.dynamic.threadpool.server.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基础配置信息
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2021/6/20 14:05
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ConfigInfoBase implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -1892597426099265730L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TpId
|
||||||
|
*/
|
||||||
|
private String tpId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ItemId
|
||||||
|
*/
|
||||||
|
private String itemId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 核心线程数
|
||||||
|
*/
|
||||||
|
private Integer coreSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最大线程数
|
||||||
|
*/
|
||||||
|
private Integer maxSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 队列类型
|
||||||
|
*/
|
||||||
|
private Integer queueType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 队列长度
|
||||||
|
*/
|
||||||
|
private Integer capacity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 线程存活时长
|
||||||
|
*/
|
||||||
|
private Integer keepAliveTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否告警
|
||||||
|
*/
|
||||||
|
private Integer isAlarm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 容量告警
|
||||||
|
*/
|
||||||
|
private Integer capacityAlarm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活跃度告警
|
||||||
|
*/
|
||||||
|
private Integer livenessAlarm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MD5
|
||||||
|
*/
|
||||||
|
private String md5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package io.dtp.server.service;
|
package io.dynamic.threadpool.server.service;
|
||||||
|
|
||||||
import io.dtp.server.model.ConfigAllInfo;
|
import io.dynamic.threadpool.server.model.ConfigAllInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务端配置接口
|
* 服务端配置接口
|
@ -1,8 +1,8 @@
|
|||||||
package io.dtp.server.service.impl;
|
package io.dynamic.threadpool.server.service.impl;
|
||||||
|
|
||||||
import io.dtp.server.mapper.RowMapperManager;
|
import io.dynamic.threadpool.server.mapper.RowMapperManager;
|
||||||
import io.dtp.server.model.ConfigAllInfo;
|
import io.dynamic.threadpool.server.model.ConfigAllInfo;
|
||||||
import io.dtp.server.service.ConfigService;
|
import io.dynamic.threadpool.server.service.ConfigService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
@ -0,0 +1,34 @@
|
|||||||
|
package io.dynamic.threadpool.server.toolkit;
|
||||||
|
|
||||||
|
import cn.hutool.crypto.digest.DigestUtil;
|
||||||
|
import io.dynamic.threadpool.server.model.ConfigAllInfo;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Md5 配置组件
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2021/6/21 18:32
|
||||||
|
*/
|
||||||
|
public class Md5ConfigUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 ThreadPool 相关内容 Md5 值
|
||||||
|
*
|
||||||
|
* @param config
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getTpContentMd5(ConfigAllInfo config) {
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
String targetStr = stringBuilder.append(config.getCoreSize())
|
||||||
|
.append(config.getMaxSize())
|
||||||
|
.append(config.getQueueType())
|
||||||
|
.append(config.getCapacity())
|
||||||
|
.append(config.getKeepAliveTime())
|
||||||
|
.append(config.getIsAlarm())
|
||||||
|
.append(config.getCapacityAlarm())
|
||||||
|
.append(config.getLivenessAlarm())
|
||||||
|
.toString();
|
||||||
|
return DigestUtil.md5Hex(targetStr);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue