refactor: 调整动态线程池 Starter 包级目录.

pull/161/head
chen.ma 3 years ago
parent 0d36621af4
commit a477d015dc

@ -1,4 +1,4 @@
package io.dynamic.threadpool.starter.config; package io.dynamic.threadpool.starter.common;
import io.dynamic.threadpool.starter.toolkit.thread.QueueTypeEnum; import io.dynamic.threadpool.starter.toolkit.thread.QueueTypeEnum;
import io.dynamic.threadpool.starter.toolkit.thread.ThreadPoolBuilder; import io.dynamic.threadpool.starter.toolkit.thread.ThreadPoolBuilder;

@ -3,7 +3,7 @@ package io.dynamic.threadpool.starter.controller;
import io.dynamic.threadpool.common.model.PoolRunStateInfo; import io.dynamic.threadpool.common.model.PoolRunStateInfo;
import io.dynamic.threadpool.common.web.base.Result; import io.dynamic.threadpool.common.web.base.Result;
import io.dynamic.threadpool.common.web.base.Results; import io.dynamic.threadpool.common.web.base.Results;
import io.dynamic.threadpool.starter.core.ThreadPoolRunStateHandler; import io.dynamic.threadpool.starter.handler.ThreadPoolRunStateHandler;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;

@ -1,4 +1,4 @@
package io.dynamic.threadpool.starter.listener; package io.dynamic.threadpool.starter.core;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
@ -7,7 +7,6 @@ import io.dynamic.threadpool.common.model.PoolParameterInfo;
import io.dynamic.threadpool.common.toolkit.ContentUtil; import io.dynamic.threadpool.common.toolkit.ContentUtil;
import io.dynamic.threadpool.common.toolkit.GroupKey; import io.dynamic.threadpool.common.toolkit.GroupKey;
import io.dynamic.threadpool.common.web.base.Result; import io.dynamic.threadpool.common.web.base.Result;
import io.dynamic.threadpool.starter.core.CacheData;
import io.dynamic.threadpool.starter.remote.HttpAgent; import io.dynamic.threadpool.starter.remote.HttpAgent;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;

@ -1,7 +1,5 @@
package io.dynamic.threadpool.starter.core; package io.dynamic.threadpool.starter.core;
import io.dynamic.threadpool.starter.listener.Listener;
/** /**
* *
* *

@ -1,4 +1,4 @@
package io.dynamic.threadpool.starter.listener; package io.dynamic.threadpool.starter.core;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;

@ -3,8 +3,6 @@ package io.dynamic.threadpool.starter.core;
import io.dynamic.threadpool.starter.config.DynamicThreadPoolProperties; import io.dynamic.threadpool.starter.config.DynamicThreadPoolProperties;
import io.dynamic.threadpool.starter.remote.HttpAgent; import io.dynamic.threadpool.starter.remote.HttpAgent;
import io.dynamic.threadpool.starter.remote.ServerHttpAgent; import io.dynamic.threadpool.starter.remote.ServerHttpAgent;
import io.dynamic.threadpool.starter.listener.ClientWorker;
import io.dynamic.threadpool.starter.listener.Listener;
import java.util.Arrays; import java.util.Arrays;

@ -1,7 +1,6 @@
package io.dynamic.threadpool.starter.core; package io.dynamic.threadpool.starter.core;
import io.dynamic.threadpool.starter.config.DynamicThreadPoolProperties; import io.dynamic.threadpool.starter.config.DynamicThreadPoolProperties;
import io.dynamic.threadpool.starter.listener.Listener;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;

@ -1,14 +1,12 @@
package io.dynamic.threadpool.starter.listener; package io.dynamic.threadpool.starter.core;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import io.dynamic.threadpool.common.config.ApplicationContextHolder; import io.dynamic.threadpool.common.config.ApplicationContextHolder;
import io.dynamic.threadpool.common.constant.Constants; import io.dynamic.threadpool.common.constant.Constants;
import io.dynamic.threadpool.common.model.PoolParameterInfo; import io.dynamic.threadpool.common.model.PoolParameterInfo;
import io.dynamic.threadpool.common.web.base.Result; import io.dynamic.threadpool.common.web.base.Result;
import io.dynamic.threadpool.starter.config.CommonThreadPool; import io.dynamic.threadpool.starter.common.CommonThreadPool;
import io.dynamic.threadpool.starter.config.DynamicThreadPoolBanner;
import io.dynamic.threadpool.starter.config.DynamicThreadPoolProperties; import io.dynamic.threadpool.starter.config.DynamicThreadPoolProperties;
import io.dynamic.threadpool.starter.core.GlobalThreadPoolManage;
import io.dynamic.threadpool.starter.remote.HttpAgent; import io.dynamic.threadpool.starter.remote.HttpAgent;
import io.dynamic.threadpool.starter.remote.ServerHttpAgent; import io.dynamic.threadpool.starter.remote.ServerHttpAgent;
import io.dynamic.threadpool.starter.toolkit.thread.QueueTypeEnum; import io.dynamic.threadpool.starter.toolkit.thread.QueueTypeEnum;
@ -44,8 +42,6 @@ public class ThreadPoolRunListener {
@PostConstruct @PostConstruct
@Order(Ordered.LOWEST_PRECEDENCE - 1024) @Order(Ordered.LOWEST_PRECEDENCE - 1024)
public void run() { public void run() {
DynamicThreadPoolBanner.printBanner(properties.isBanner());
Map<String, DynamicThreadPoolWrap> executorMap = ApplicationContextHolder.getBeansOfType(DynamicThreadPoolWrap.class); Map<String, DynamicThreadPoolWrap> executorMap = ApplicationContextHolder.getBeansOfType(DynamicThreadPoolWrap.class);
executorMap.forEach((key, val) -> { executorMap.forEach((key, val) -> {
String tpId = val.getTpId(); String tpId = val.getTpId();

@ -1,29 +1,44 @@
package io.dynamic.threadpool.starter.config; package io.dynamic.threadpool.starter.handler;
import io.dynamic.threadpool.starter.config.DynamicThreadPoolProperties;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.ansi.AnsiColor; import org.springframework.boot.ansi.AnsiColor;
import org.springframework.boot.ansi.AnsiOutput; import org.springframework.boot.ansi.AnsiOutput;
import org.springframework.boot.ansi.AnsiStyle; import org.springframework.boot.ansi.AnsiStyle;
/** /**
* 线 Banner * 线 Banner.
* *
* @author chen.ma * @author chen.ma
* @date 2021/7/4 15:58 * @date 2021/6/20 16:34
*/ */
public class DynamicThreadPoolBanner { @Slf4j
@RequiredArgsConstructor
public class ThreadPoolBannerHandler implements InitializingBean {
private static final String DYNAMIC_THREAD_POOL = " :: Dynamic ThreadPool :: "; @NonNull
private final DynamicThreadPoolProperties properties;
private static final int STRAP_LINE_SIZE = 50; private final String DYNAMIC_THREAD_POOL = " :: Dynamic ThreadPool :: ";
public static void printBanner(boolean isBanner) { private final int STRAP_LINE_SIZE = 50;
@Override
public void afterPropertiesSet() {
printBanner();
}
private void printBanner() {
String banner = "\n___ _ _____ ___ \n" + String banner = "\n___ _ _____ ___ \n" +
"| \\ _ _ _ _ __ _ _ __ (_)__ |_ _| _ \\\n" + "| \\ _ _ _ _ __ _ _ __ (_)__ |_ _| _ \\\n" +
"| |) | || | ' \\/ _` | ' \\| / _| | | | _/\n" + "| |) | || | ' \\/ _` | ' \\| / _| | | | _/\n" +
"|___/ \\_, |_||_\\__,_|_|_|_|_\\__| |_| |_| \n" + "|___/ \\_, |_||_\\__,_|_|_|_|_\\__| |_| |_| \n" +
" |__/ \n"; " |__/ \n";
if (isBanner) { if (properties.isBanner()) {
String version = getVersion(); String version = getVersion();
version = (version != null) ? " (v" + version + ")" : "no version."; version = (version != null) ? " (v" + version + ")" : "no version.";
@ -38,7 +53,7 @@ public class DynamicThreadPoolBanner {
} }
public static String getVersion() { public static String getVersion() {
final Package pkg = DynamicThreadPoolBanner.class.getPackage(); final Package pkg = ThreadPoolBannerHandler.class.getPackage();
return pkg != null ? pkg.getImplementationVersion() : ""; return pkg != null ? pkg.getImplementationVersion() : "";
} }

@ -1,6 +1,7 @@
package io.dynamic.threadpool.starter.core; package io.dynamic.threadpool.starter.handler;
import io.dynamic.threadpool.common.model.PoolRunStateInfo; import io.dynamic.threadpool.common.model.PoolRunStateInfo;
import io.dynamic.threadpool.starter.core.GlobalThreadPoolManage;
import io.dynamic.threadpool.starter.toolkit.thread.CustomThreadPoolExecutor; import io.dynamic.threadpool.starter.toolkit.thread.CustomThreadPoolExecutor;
import io.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrap; import io.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrap;

@ -1,6 +1,6 @@
package io.dynamic.threadpool.starter.wrap; package io.dynamic.threadpool.starter.wrap;
import io.dynamic.threadpool.starter.config.CommonThreadPool; import io.dynamic.threadpool.starter.common.CommonThreadPool;
import lombok.Data; import lombok.Data;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;

@ -1,6 +1,6 @@
package io.dynamic.threadpool.starter.wrap; package io.dynamic.threadpool.starter.wrap;
import io.dynamic.threadpool.starter.listener.Listener; import io.dynamic.threadpool.starter.core.Listener;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;

Loading…
Cancel
Save