From d545b93511ae7b5dea0ef74c66386b2c524bb600 Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Thu, 23 Dec 2021 23:14:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20hippo4j=20starter=20?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/hippo4j/starter/core/CacheData.java | 3 +-- .../cn/hippo4j/starter/core/ClientWorker.java | 12 +++++----- .../starter/core/ConfigEmptyException.java | 6 +++++ .../hippo4j/starter/core/DiscoveryClient.java | 18 +++++--------- .../DynamicExecutorConfigurationSupport.java | 4 ++-- .../core/DynamicThreadPoolPostProcessor.java | 15 ++++++------ .../core/ThreadPoolDynamicRefresh.java | 2 +- .../starter/event/MonitorEventExecutor.java | 2 +- .../monitor/ReportingEventExecutor.java | 6 ++--- .../starter/remote/AbstractHealthCheck.java | 4 ++-- .../starter/remote/ServerHttpAgent.java | 2 +- .../starter/toolkit/CalculateUtil.java | 7 ++++++ .../starter/toolkit/HttpClientUtil.java | 18 +++++++------- .../AbstractBuildThreadPoolTemplate.java | 14 +++++------ .../thread/FastThreadPoolExecutor.java | 2 +- .../toolkit/thread/RejectedPolicies.java | 2 +- .../starter/toolkit/thread/TaskQueue.java | 1 + .../toolkit/thread/ThreadFactoryBuilder.java | 14 +++++------ .../toolkit/thread/ThreadPoolBuilder.java | 12 +++++----- .../thread/ThreadPoolExecutorTemplate.java | 2 +- .../wrapper/DynamicThreadPoolWrapper.java | 24 +++++++++++++++---- .../wrapper/ManagerListenerWrapper.java | 17 ++++++++----- 22 files changed, 107 insertions(+), 80 deletions(-) diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/CacheData.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/CacheData.java index cf4ae1fd..942af71c 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/CacheData.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/CacheData.java @@ -42,12 +42,11 @@ public class CacheData { this.content = ContentUtil.getPoolContent(GlobalThreadPoolManage.getPoolParameter(tpId)); this.md5 = getMd5String(content); this.listeners = new CopyOnWriteArrayList(); - } public void addListener(Listener listener) { if (null == listener) { - throw new IllegalArgumentException("listener is null"); + throw new IllegalArgumentException("Listener is null."); } ManagerListenerWrapper managerListenerWrap = new ManagerListenerWrapper(md5, listener); diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ClientWorker.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ClientWorker.java index ca482539..a71076d1 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ClientWorker.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ClientWorker.java @@ -62,7 +62,7 @@ public class ClientWorker { }); this.executorService = Executors.newSingleThreadScheduledExecutor( - ThreadFactoryBuilder.builder().prefix("client-long-polling-executor").daemon(true).build() + ThreadFactoryBuilder.builder().prefix("client.long.polling.executor").daemon(true).build() ); log.info("Client identity :: {}", identification); @@ -71,7 +71,7 @@ public class ClientWorker { try { checkConfigInfo(); } catch (Throwable e) { - log.error("[Sub check] rotate check error", e); + log.error("Sub check rotate check error.", e); } }, 1L, 10L, TimeUnit.MILLISECONDS); } @@ -176,7 +176,7 @@ public class ClientWorker { } } catch (Exception ex) { setHealthServer(false); - log.error("[Check update] get changed dataId exception. error message :: {}", ex.getMessage()); + log.error("Check update get changed dataId exception. error message :: {}", ex.getMessage()); } return Collections.emptyList(); @@ -194,7 +194,7 @@ public class ClientWorker { return JSONUtil.toJSONString(result.getData()); } - log.error("[Sub server] namespace :: {}, itemId :: {}, tpId :: {}, result code :: {}", + log.error("Sub server namespace :: {}, itemId :: {}, tpId :: {}, result code :: {}", namespace, itemId, tpId, result.getCode()); return NULL; } @@ -207,7 +207,7 @@ public class ClientWorker { try { response = URLDecoder.decode(response, "UTF-8"); } catch (Exception e) { - log.error("[Polling resp] decode modifiedDataIdsString error", e); + log.error("Polling resp decode modifiedDataIdsString error.", e); } @@ -222,7 +222,7 @@ public class ClientWorker { updateList.add(GroupKey.getKeyTenant(dataId, group, tenant)); log.info("Refresh thread pool changed. [{}]", dataId); } else { - log.error("[{}] [Polling resp] invalid dataIdAndGroup error.", dataIdAndGroup); + log.error("[{}] Polling resp invalid dataIdAndGroup error.", dataIdAndGroup); } } } diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ConfigEmptyException.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ConfigEmptyException.java index 21110a10..aaa5218a 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ConfigEmptyException.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ConfigEmptyException.java @@ -13,8 +13,14 @@ import lombok.Data; @AllArgsConstructor public class ConfigEmptyException extends RuntimeException { + /** + * description + */ private String description; + /** + * action + */ private String action; } diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DiscoveryClient.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DiscoveryClient.java index 2e31284d..a342a2fb 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DiscoveryClient.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DiscoveryClient.java @@ -7,7 +7,6 @@ import cn.hippo4j.common.web.base.Results; import cn.hippo4j.common.web.exception.ErrorCodeEnum; import cn.hippo4j.starter.remote.HttpAgent; import cn.hippo4j.starter.toolkit.thread.ThreadFactoryBuilder; -import cn.hippo4j.starter.toolkit.thread.ThreadPoolBuilder; import cn.hutool.core.text.StrBuilder; import cn.hutool.core.util.StrUtil; import com.google.common.collect.Maps; @@ -15,9 +14,12 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.DisposableBean; import java.util.Map; -import java.util.concurrent.*; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; -import static cn.hippo4j.common.constant.Constants.*; +import static cn.hippo4j.common.constant.Constants.BASE_PATH; +import static cn.hippo4j.common.constant.Constants.GROUP_KEY; /** * Discovery client. @@ -28,8 +30,6 @@ import static cn.hippo4j.common.constant.Constants.*; @Slf4j public class DiscoveryClient implements DisposableBean { - private final ThreadPoolExecutor heartbeatExecutor; - private final ScheduledExecutorService scheduler; private final HttpAgent httpAgent; @@ -46,16 +46,10 @@ public class DiscoveryClient implements DisposableBean { this.httpAgent = httpAgent; this.instanceInfo = instanceInfo; this.appPathIdentifier = instanceInfo.getAppName().toUpperCase() + "/" + instanceInfo.getInstanceId(); - this.heartbeatExecutor = ThreadPoolBuilder.builder() - .poolThreadSize(1, 5) - .keepAliveTime(0, TimeUnit.SECONDS) - .workQueue(new SynchronousQueue()) - .threadFactory("DiscoveryClient-HeartbeatExecutor", true) - .build(); this.scheduler = new ScheduledThreadPoolExecutor( new Integer(1), - ThreadFactoryBuilder.builder().daemon(true).prefix("DiscoveryClient-Scheduler").build() + ThreadFactoryBuilder.builder().daemon(true).prefix("client.discovery.scheduler").build() ); register(); diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DynamicExecutorConfigurationSupport.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DynamicExecutorConfigurationSupport.java index d15ca71b..ddc3d6a7 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DynamicExecutorConfigurationSupport.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DynamicExecutorConfigurationSupport.java @@ -127,13 +127,13 @@ public abstract class DynamicExecutorConfigurationSupport extends ThreadPoolExec if (!executor.awaitTermination(this.awaitTerminationMillis, TimeUnit.MILLISECONDS)) { if (log.isWarnEnabled()) { log.warn("Timed out while waiting for executor" + - (this.threadPoolId != null ? " '" + this.threadPoolId + "'" : "") + " to terminate"); + (this.threadPoolId != null ? " '" + this.threadPoolId + "'" : "") + " to terminate."); } } } catch (InterruptedException ex) { if (log.isWarnEnabled()) { log.warn("Interrupted while waiting for executor" + - (this.threadPoolId != null ? " '" + this.threadPoolId + "'" : "") + " to terminate"); + (this.threadPoolId != null ? " '" + this.threadPoolId + "'" : "") + " to terminate."); } Thread.currentThread().interrupt(); } diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DynamicThreadPoolPostProcessor.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DynamicThreadPoolPostProcessor.java index 50116275..2303dc5a 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DynamicThreadPoolPostProcessor.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DynamicThreadPoolPostProcessor.java @@ -15,7 +15,6 @@ import cn.hippo4j.starter.toolkit.thread.ThreadPoolBuilder; import cn.hippo4j.starter.wrapper.DynamicThreadPoolWrapper; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import lombok.var; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.core.task.TaskDecorator; @@ -54,24 +53,24 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor { .workQueue(QueueTypeEnum.ARRAY_BLOCKING_QUEUE) .capacity(1024) .allowCoreThreadTimeOut(true) - .threadFactory("dynamic-threadPool-change-config") + .threadFactory("client.dynamic.threadPool.change.config") .rejected(new ThreadPoolExecutor.AbortPolicy()) .build(); @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof DynamicThreadPoolExecutor) { - var dynamicThreadPool = ApplicationContextHolder.findAnnotationOnBean(beanName, DynamicThreadPool.class); + DynamicThreadPool dynamicThreadPool = ApplicationContextHolder.findAnnotationOnBean(beanName, DynamicThreadPool.class); if (Objects.isNull(dynamicThreadPool)) { return bean; } - var dynamicExecutor = (DynamicThreadPoolExecutor) bean; - var wrap = new DynamicThreadPoolWrapper(dynamicExecutor.getThreadPoolId(), dynamicExecutor); - var remoteExecutor = fillPoolAndRegister(wrap); + DynamicThreadPoolExecutor dynamicExecutor = (DynamicThreadPoolExecutor) bean; + DynamicThreadPoolWrapper wrap = new DynamicThreadPoolWrapper(dynamicExecutor.getThreadPoolId(), dynamicExecutor); + ThreadPoolExecutor remoteExecutor = fillPoolAndRegister(wrap); subscribeConfig(wrap); return remoteExecutor; } else if (bean instanceof DynamicThreadPoolWrapper) { - var wrap = (DynamicThreadPoolWrapper) bean; + DynamicThreadPoolWrapper wrap = (DynamicThreadPoolWrapper) bean; registerAndSubscribe(wrap); } @@ -136,7 +135,7 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor { poolExecutor = dynamicThreadPoolWrap.getExecutor() != null ? dynamicThreadPoolWrap.getExecutor() : CommonDynamicThreadPool.getInstance(tpId); dynamicThreadPoolWrap.setExecutor(poolExecutor); - log.error("[Init pool] Failed to initialize thread pool configuration. error message :: {}", ex.getMessage()); + log.error("Failed to initialize thread pool configuration. error message :: {}", ex.getMessage()); } finally { if (Objects.isNull(dynamicThreadPoolWrap.getExecutor())) { dynamicThreadPoolWrap.setExecutor(CommonDynamicThreadPool.getInstance(tpId)); diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ThreadPoolDynamicRefresh.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ThreadPoolDynamicRefresh.java index 5ceae652..55d4c368 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ThreadPoolDynamicRefresh.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ThreadPoolDynamicRefresh.java @@ -72,7 +72,7 @@ public class ThreadPoolDynamicRefresh { ResizableCapacityLinkedBlockIngQueue queue = (ResizableCapacityLinkedBlockIngQueue) executor.getQueue(); queue.setCapacity(parameter.getCapacity()); } else { - log.warn("[Pool change] The queue length cannot be modified. Queue type mismatch. Current queue type :: {}", executor.getQueue().getClass().getSimpleName()); + log.warn("The queue length cannot be modified. Queue type mismatch. Current queue type :: {}", executor.getQueue().getClass().getSimpleName()); } } diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/event/MonitorEventExecutor.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/event/MonitorEventExecutor.java index b29274b2..a7995bcf 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/event/MonitorEventExecutor.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/event/MonitorEventExecutor.java @@ -21,7 +21,7 @@ import static cn.hippo4j.common.constant.Constants.AVAILABLE_PROCESSORS; public class MonitorEventExecutor { private static final ExecutorService EVENT_EXECUTOR = ThreadPoolBuilder.builder() - .threadFactory("monitor-event-executor") + .threadFactory("client.monitor.event.executor") .corePoolSize(AVAILABLE_PROCESSORS) .maxPoolNum(AVAILABLE_PROCESSORS) .workQueue(QueueTypeEnum.LINKED_BLOCKING_QUEUE) diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/monitor/ReportingEventExecutor.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/monitor/ReportingEventExecutor.java index 94bf76ec..f02a68c0 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/monitor/ReportingEventExecutor.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/monitor/ReportingEventExecutor.java @@ -80,7 +80,7 @@ public class ReportingEventExecutor implements Runnable, CommandLineRunner, Disp Integer bufferSize = properties.getTaskBufferSize(); messageCollectVessel = new ArrayBlockingQueue(bufferSize); - String collectVesselTaskName = "collect-data-scheduled"; + String collectVesselTaskName = "client.scheduled.collect.data"; collectVesselExecutor = new ScheduledThreadPoolExecutor( new Integer(1), ThreadFactoryBuilder.builder().daemon(true).prefix(collectVesselTaskName).build() @@ -95,7 +95,7 @@ public class ReportingEventExecutor implements Runnable, CommandLineRunner, Disp ); // 启动上报监控数据线程 - String reportingTaskName = "reporting-task"; + String reportingTaskName = "client.thread.reporting.task"; ThreadUtil.newThread(this, reportingTaskName, Boolean.TRUE).start(); // 获取所有数据采集组件, 目前仅有历史运行数据采集 @@ -111,7 +111,7 @@ public class ReportingEventExecutor implements Runnable, CommandLineRunner, Disp } /** - * 采集动态线程池数据, 并添加缓冲队列 + * 采集动态线程池数据, 并添加缓冲队列. */ private void runTimeGatherTask() { boolean healthStatus = serverHealthCheck.isHealthStatus(); diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/remote/AbstractHealthCheck.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/remote/AbstractHealthCheck.java index f2e25f03..4ad83156 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/remote/AbstractHealthCheck.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/remote/AbstractHealthCheck.java @@ -44,11 +44,11 @@ public abstract class AbstractHealthCheck implements ServerHealthCheck, Initiali private final Condition healthCondition = healthMainLock.newCondition(); /** - * Health check executor. + * Health check executor */ private final ScheduledThreadPoolExecutor healthCheckExecutor = new ScheduledThreadPoolExecutor( new Integer(1), - ThreadFactoryBuilder.builder().daemon(true).prefix("health-check-scheduled").build() + ThreadFactoryBuilder.builder().daemon(true).prefix("client.scheduled.health.check").build() ); /** diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/remote/ServerHttpAgent.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/remote/ServerHttpAgent.java index 3bc63a17..a0b258a5 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/remote/ServerHttpAgent.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/remote/ServerHttpAgent.java @@ -46,7 +46,7 @@ public class ServerHttpAgent implements HttpAgent { this.securityProxy.applyToken(this.serverListManager.getServerUrls()); this.executorService = new ScheduledThreadPoolExecutor( new Integer(1), - ThreadFactoryBuilder.builder().daemon(true).prefix("token-security-updater").build() + ThreadFactoryBuilder.builder().daemon(true).prefix("client.scheduled.token.security.updater").build() ); this.executorService.scheduleWithFixedDelay( diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/CalculateUtil.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/CalculateUtil.java index d64a540f..c9c22dc3 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/CalculateUtil.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/CalculateUtil.java @@ -8,6 +8,13 @@ package cn.hippo4j.starter.toolkit; */ public class CalculateUtil { + /** + * Divide. + * + * @param num1 + * @param num2 + * @return + */ public static int divide(int num1, int num2) { return ((int) (Double.parseDouble(num1 + "") / Double.parseDouble(num2 + "") * 100)); } diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/HttpClientUtil.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/HttpClientUtil.java index c5218472..35c25d07 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/HttpClientUtil.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/HttpClientUtil.java @@ -27,7 +27,7 @@ public class HttpClientUtil { private static int HTTP_OK_CODE = 200; /** - * Get 请求 + * Get 请求. * * @param url * @return @@ -43,7 +43,7 @@ public class HttpClientUtil { } /** - * Get 请求, 支持添加查询字符串 + * Get 请求, 支持添加查询字符串. * * @param url * @param queryString 查询字符串 @@ -55,7 +55,7 @@ public class HttpClientUtil { } /** - * 获取 Json 后直接反序列化 + * 获取 Json 后直接反序列化. * * @param url * @param clazz @@ -67,7 +67,7 @@ public class HttpClientUtil { } /** - * 调用健康检查 + * 调用健康检查. * * @param url * @param clazz @@ -81,7 +81,7 @@ public class HttpClientUtil { } /** - * Get 请求, 支持查询字符串 + * Get 请求, 支持查询字符串. * * @param url * @param queryString @@ -96,7 +96,7 @@ public class HttpClientUtil { } /** - * Rest 接口 Post 调用 + * Rest 接口 Post 调用. * * @param url * @param body @@ -112,8 +112,8 @@ public class HttpClientUtil { } /** - * Rest 接口 Post 调用 - * 对返回值直接反序列化 + * Rest 接口 Post 调用. + * 对返回值直接反序列化. * * @param url * @param body @@ -125,7 +125,7 @@ public class HttpClientUtil { } /** - * 根据查询字符串构造完整的 Url + * 根据查询字符串构造完整的 Url. * * @param url * @param queryString diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/AbstractBuildThreadPoolTemplate.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/AbstractBuildThreadPoolTemplate.java index b1d05a46..7a1dc20a 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/AbstractBuildThreadPoolTemplate.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/AbstractBuildThreadPoolTemplate.java @@ -21,9 +21,9 @@ import java.util.concurrent.locks.AbstractQueuedSynchronizer; public class AbstractBuildThreadPoolTemplate { /** - * 线程池构建初始化参数 + * 线程池构建初始化参数. *

- * 此处本身是模版设计方法, 但是考虑创建简洁性, 移除 abstract + * 此处本身是模版设计方法, 但是考虑创建简洁性, 移除 abstract. * 异常参考 {@link AbstractQueuedSynchronizer#tryAcquire} * * @return @@ -33,7 +33,7 @@ public class AbstractBuildThreadPoolTemplate { } /** - * 构建线程池 + * 构建线程池. * * @return */ @@ -43,7 +43,7 @@ public class AbstractBuildThreadPoolTemplate { } /** - * 构建线程池 + * 构建线程池. * * @return */ @@ -67,7 +67,7 @@ public class AbstractBuildThreadPoolTemplate { } /** - * 构建快速执行线程池 + * 构建快速执行线程池. * * @return */ @@ -77,7 +77,7 @@ public class AbstractBuildThreadPoolTemplate { } /** - * 构建快速执行线程池 + * 构建快速执行线程池. * * @return */ @@ -102,7 +102,7 @@ public class AbstractBuildThreadPoolTemplate { } /** - * 构建动态线程池 + * 构建动态线程池. * * @param initParam * @return diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/FastThreadPoolExecutor.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/FastThreadPoolExecutor.java index ff6d6f83..d898bde5 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/FastThreadPoolExecutor.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/FastThreadPoolExecutor.java @@ -48,7 +48,7 @@ public class FastThreadPoolExecutor extends ThreadPoolExecutorTemplate { try { if (!queue.retryOffer(command, 0, TimeUnit.MILLISECONDS)) { submittedTaskCount.decrementAndGet(); - throw new RejectedExecutionException("队列容量已满.", rx); + throw new RejectedExecutionException("The blocking queue capacity is full.", rx); } } catch (InterruptedException x) { submittedTaskCount.decrementAndGet(); diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/RejectedPolicies.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/RejectedPolicies.java index ff1f4bd6..9cd515ef 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/RejectedPolicies.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/RejectedPolicies.java @@ -49,7 +49,7 @@ public class RejectedPolicies { try { executor.getQueue().put(r); } catch (InterruptedException e) { - log.error("线程池添加队列任务失败", e); + log.error("Adding Queue task to thread pool failed.", e); } }; } diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/TaskQueue.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/TaskQueue.java index 71ba07fe..f1de9ede 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/TaskQueue.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/TaskQueue.java @@ -47,4 +47,5 @@ public class TaskQueue extends LinkedBlockingQueue } return super.offer(o, timeout, unit); } + } diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/ThreadFactoryBuilder.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/ThreadFactoryBuilder.java index 1eab3f90..725c526e 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/ThreadFactoryBuilder.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/ThreadFactoryBuilder.java @@ -40,7 +40,7 @@ public class ThreadFactoryBuilder implements Builder { private Thread.UncaughtExceptionHandler uncaughtExceptionHandler; /** - * 设置用于创建基础线程的线程工厂 + * 设置用于创建基础线程的线程工厂. * * @param backingThreadFactory 用于创建基础线程的线程工厂 * @return this @@ -51,7 +51,7 @@ public class ThreadFactoryBuilder implements Builder { } /** - * 设置线程名前缀, 例如设置前缀为 mb-thread- 则线程名为 mb-thread-1 之类 + * 设置线程名前缀, 例如设置前缀为 mb-thread- 则线程名为 mb-thread-1 之类. * * @param namePrefix 线程名前缀 * @return this @@ -62,7 +62,7 @@ public class ThreadFactoryBuilder implements Builder { } /** - * 设置是否守护线程 + * 设置是否守护线程. * * @param daemon 是否守护线程 * @return this @@ -73,7 +73,7 @@ public class ThreadFactoryBuilder implements Builder { } /** - * 设置线程优先级 + * 设置线程优先级. * * @param priority 优先级 * @return this @@ -93,7 +93,7 @@ public class ThreadFactoryBuilder implements Builder { } /** - * 设置未捕获异常的处理方式 + * 设置未捕获异常的处理方式. * * @param uncaughtExceptionHandler {@link Thread.UncaughtExceptionHandler} */ @@ -102,7 +102,7 @@ public class ThreadFactoryBuilder implements Builder { } /** - * 构建 + * 构建. * * @return */ @@ -121,7 +121,7 @@ public class ThreadFactoryBuilder implements Builder { } /** - * 构建 + * 构建. * * @param builder {@link ThreadFactoryBuilder} * @return {@link ThreadFactory} diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/ThreadPoolBuilder.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/ThreadPoolBuilder.java index 2115f9df..ed6c21e9 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/ThreadPoolBuilder.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/ThreadPoolBuilder.java @@ -245,7 +245,7 @@ public class ThreadPoolBuilder implements Builder { } /** - * 构建 + * 构建. * * @return */ @@ -258,7 +258,7 @@ public class ThreadPoolBuilder implements Builder { } /** - * 创建 + * 创建. * * @return */ @@ -267,7 +267,7 @@ public class ThreadPoolBuilder implements Builder { } /** - * 构建普通线程池 + * 构建普通线程池. * * @param builder * @return @@ -277,7 +277,7 @@ public class ThreadPoolBuilder implements Builder { } /** - * 构建快速消费线程池 + * 构建快速消费线程池. * * @param builder * @return @@ -287,7 +287,7 @@ public class ThreadPoolBuilder implements Builder { } /** - * 构建动态线程池 + * 构建动态线程池. * * @param builder * @return @@ -297,7 +297,7 @@ public class ThreadPoolBuilder implements Builder { } /** - * 构建初始化参数 + * 构建初始化参数. * * @param builder * @return diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/ThreadPoolExecutorTemplate.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/ThreadPoolExecutorTemplate.java index 36227191..2b9ec640 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/ThreadPoolExecutorTemplate.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/ThreadPoolExecutorTemplate.java @@ -23,7 +23,7 @@ public class ThreadPoolExecutorTemplate extends ThreadPoolExecutor { } private Exception clientTrace() { - return new Exception("tread task root stack trace"); + return new Exception("Tread task root stack trace."); } @Override diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/wrapper/DynamicThreadPoolWrapper.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/wrapper/DynamicThreadPoolWrapper.java index c9152684..438e6829 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/wrapper/DynamicThreadPoolWrapper.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/wrapper/DynamicThreadPoolWrapper.java @@ -18,14 +18,30 @@ import java.util.concurrent.ThreadPoolExecutor; @Data public class DynamicThreadPoolWrapper implements DisposableBean { + /** + * Tenant id + */ private String tenantId; + /** + * Item id + */ private String itemId; + /** + * Thread pool id + */ private String tpId; + /** + * Subscribe flag + */ private boolean subscribeFlag; + /** + * executor + * {@link cn.hippo4j.starter.core.DynamicThreadPoolExecutor} + */ private ThreadPoolExecutor executor; /** @@ -38,7 +54,7 @@ public class DynamicThreadPoolWrapper implements DisposableBean { } /** - * 首选服务端线程池, 为空使用 threadPoolExecutor + * 首选服务端线程池, 为空使用 threadPoolExecutor. * * @param threadPoolId * @param threadPoolExecutor @@ -49,7 +65,7 @@ public class DynamicThreadPoolWrapper implements DisposableBean { } /** - * 提交任务 + * 提交任务. * * @param command */ @@ -58,7 +74,7 @@ public class DynamicThreadPoolWrapper implements DisposableBean { } /** - * 提交任务 + * 提交任务. * * @param task * @return @@ -68,7 +84,7 @@ public class DynamicThreadPoolWrapper implements DisposableBean { } /** - * 提交任务 + * 提交任务. * * @param task * @param diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/wrapper/ManagerListenerWrapper.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/wrapper/ManagerListenerWrapper.java index c6af3afb..6ec9b9d8 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/wrapper/ManagerListenerWrapper.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/wrapper/ManagerListenerWrapper.java @@ -1,7 +1,9 @@ package cn.hippo4j.starter.wrapper; import cn.hippo4j.starter.core.Listener; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; /** @@ -12,15 +14,18 @@ import lombok.Setter; */ @Getter @Setter +@NoArgsConstructor +@AllArgsConstructor public class ManagerListenerWrapper { + /** + * Last call md5 + */ private String lastCallMd5; - final Listener listener; - - public ManagerListenerWrapper(String md5, Listener listener) { - this.lastCallMd5 = md5; - this.listener = listener; - } + /** + * Listener + */ + private Listener listener; }