feat: 修改 pom & 修改文件包名.

pull/161/head
chen.ma 4 years ago
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

@ -4,12 +4,12 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>io.dynamic-thread-pool</groupId> <groupId>io.dynamic-threadpool</groupId>
<artifactId>dtp-parent</artifactId> <artifactId>parent</artifactId>
<version>${revision}</version> <version>${revision}</version>
</parent> </parent>
<artifactId>dtp-spring-boot-starter</artifactId> <artifactId>dynamic-threadpool-spring-boot-starter</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>${project.artifactId}</name> <name>${project.artifactId}</name>
@ -27,7 +27,7 @@
<dependency> <dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-core</artifactId> <artifactId>hutool-all</artifactId>
</dependency> </dependency>
<dependency> <dependency>

@ -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.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,4 +1,4 @@
package io.dtp.starter.model; package io.dynamic.threadpool.starter.model;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
@ -61,13 +61,4 @@ public class PoolParameterInfo implements Serializable {
* 线 * 线
*/ */
private Integer keepAliveTime; private Integer keepAliveTime;
public void setContent(String content) {
JSONObject poolParam = JSON.parseObject(content);
this.coreSize = poolParam.getInteger("coreSize");
this.maxSize = poolParam.getInteger("maxSize");
this.capacity = poolParam.getInteger("capacity");
this.queueType = poolParam.getInteger("queueType");
this.keepAliveTime = poolParam.getInteger("keepAliveTime");
}
} }

@ -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;

@ -1,6 +1,6 @@
package io.dtp.starter.wrap; package io.dynamic.threadpool.starter.wrap;
import io.dtp.starter.common.CommonThreadPool; import io.dynamic.threadpool.starter.common.CommonThreadPool;
import lombok.Data; import lombok.Data;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -32,9 +32,7 @@ public class DynamicThreadPoolWrap {
* @param threadPoolId * @param threadPoolId
*/ */
public DynamicThreadPoolWrap(String tenant, String itemId, String threadPoolId) { public DynamicThreadPoolWrap(String tenant, String itemId, String threadPoolId) {
this.tenant = tenant; this(tenant, itemId, threadPoolId, null);
this.itemId = itemId;
this.tpId = threadPoolId;
} }
/** /**
@ -46,6 +44,8 @@ public class DynamicThreadPoolWrap {
* @param threadPoolExecutor * @param threadPoolExecutor
*/ */
public DynamicThreadPoolWrap(String tenant, String itemId, String threadPoolId, ThreadPoolExecutor threadPoolExecutor) { public DynamicThreadPoolWrap(String tenant, String itemId, String threadPoolId, ThreadPoolExecutor threadPoolExecutor) {
this.tenant = tenant;
this.itemId = itemId;
this.tpId = threadPoolId; this.tpId = threadPoolId;
this.pool = threadPoolExecutor; this.pool = threadPoolExecutor;
} }

@ -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;

@ -4,15 +4,15 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>io.dynamic-thread-pool</groupId> <groupId>io.dynamic-threadpool</groupId>
<artifactId>dtp-parent</artifactId> <artifactId>parent</artifactId>
<version>${revision}</version> <version>${revision}</version>
</parent> </parent>
<artifactId>dtp-example</artifactId> <artifactId>dynamic-threadpool-example</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>dtp-example</name> <name>${project.artifactId}</name>
<description>Demo project for Spring Boot</description> <description>Demo project for Spring Boot</description>
<properties> <properties>

@ -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;

@ -3,8 +3,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>io.dynamic-thread-pool</groupId> <groupId>io.dynamic-threadpool</groupId>
<artifactId>dtp-parent</artifactId> <artifactId>parent</artifactId>
<version>${revision}</version> <version>${revision}</version>
<packaging>pom</packaging> <packaging>pom</packaging>
@ -23,9 +23,9 @@
</properties> </properties>
<modules> <modules>
<module>dtp-server</module> <module>server</module>
<module>dtp-example</module> <module>example</module>
<module>dtp-spring-boot-starter</module> <module>dynamic-threadpool-spring-boot-starter</module>
</modules> </modules>
<dependencyManagement> <dependencyManagement>
@ -53,9 +53,15 @@
<dependency> <dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-core</artifactId> <artifactId>hutool-all</artifactId>
<version>${hutool-core.version}</version> <version>${hutool-core.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>

@ -4,12 +4,12 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>io.dynamic-thread-pool</groupId> <groupId>io.dynamic-threadpool</groupId>
<artifactId>dtp-parent</artifactId> <artifactId>parent</artifactId>
<version>${revision}</version> <version>${revision}</version>
</parent> </parent>
<artifactId>dtp-server</artifactId> <artifactId>dynamic-threadpool-server</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>${project.artifactId}</name> <name>${project.artifactId}</name>
@ -36,6 +36,11 @@
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

@ -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,6 +1,6 @@
package io.dtp.server.mapper; package io.dynamic.threadpool.server.mapper;
import io.dtp.server.model.ConfigAllInfo; import io.dynamic.threadpool.server.model.ConfigAllInfo;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -12,13 +12,11 @@ import java.sql.SQLException;
* @author chen.ma * @author chen.ma
* @date 2021/6/20 15:57 * @date 2021/6/20 15:57
*/ */
public final class RowMapperManager { public final class RowMapperManager {
public static final ConfigAllInfoRowMapper CONFIG_ALL_INFO_ROW_MAPPER = new ConfigAllInfoRowMapper(); public static final ConfigAllInfoRowMapper CONFIG_ALL_INFO_ROW_MAPPER = new ConfigAllInfoRowMapper();
public static class ConfigAllInfoRowMapper implements RowMapper<ConfigAllInfo> { public static class ConfigAllInfoRowMapper implements RowMapper<ConfigAllInfo> {
@Override @Override
public ConfigAllInfo mapRow(ResultSet rs, int rowNum) throws SQLException { public ConfigAllInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
ConfigAllInfo configAllInfo = new ConfigAllInfo(); ConfigAllInfo configAllInfo = new ConfigAllInfo();
@ -26,6 +24,14 @@ public final class RowMapperManager {
configAllInfo.setItemId(rs.getString("item_id")); configAllInfo.setItemId(rs.getString("item_id"));
configAllInfo.setTenant(rs.getString("tenant_id")); configAllInfo.setTenant(rs.getString("tenant_id"));
configAllInfo.setContent(rs.getString("content")); configAllInfo.setContent(rs.getString("content"));
configAllInfo.setCoreSize(rs.getInt("core_size"));
configAllInfo.setMaxSize(rs.getInt("max_size"));
configAllInfo.setQueueType(rs.getInt("queue_type"));
configAllInfo.setCapacity(rs.getInt("capacity"));
configAllInfo.setKeepAliveTime(rs.getInt("keep_alive_time"));
configAllInfo.setIsAlarm(rs.getInt("is_alarm"));
configAllInfo.setCapacityAlarm(rs.getInt("capacity_alarm"));
configAllInfo.setLivenessAlarm(rs.getInt("liveness_alarm"));
configAllInfo.setMd5(rs.getString("md5")); configAllInfo.setMd5(rs.getString("md5"));
configAllInfo.setCreateTime(rs.getTimestamp("gmt_modified").getTime()); configAllInfo.setCreateTime(rs.getTimestamp("gmt_modified").getTime());
configAllInfo.setModifyTime(rs.getTimestamp("gmt_modified").getTime()); configAllInfo.setModifyTime(rs.getTimestamp("gmt_modified").getTime());

@ -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…
Cancel
Save