refactor 1171: optimize @Deprecated coreSize and maxSize

pull/1219/head
yangsanity 2 years ago
parent 9a1089f640
commit a066e01a93

@ -58,8 +58,8 @@ public class AlibabaDubboThreadPoolAdapter implements ThreadPoolAdapter, Applica
return threadPoolAdapterState;
}
threadPoolAdapterState.setThreadPoolKey(identify);
threadPoolAdapterState.setCoreSize(executor.getCorePoolSize());
threadPoolAdapterState.setMaximumSize(executor.getMaximumPoolSize());
threadPoolAdapterState.setCorePoolSize(executor.getCorePoolSize());
threadPoolAdapterState.setMaximumPoolSize(executor.getMaximumPoolSize());
return threadPoolAdapterState;
}

@ -46,14 +46,14 @@ public class ThreadPoolAdapterState {
private String clientAddress;
/**
* Core size
* Core pool size
*/
private Integer coreSize;
private Integer corePoolSize;
/**
* Maximum size
* Maximum pool size
*/
private Integer maximumSize;
private Integer maximumPoolSize;
/**
* Blocking queue type

@ -62,8 +62,8 @@ public class DubboThreadPoolAdapter implements ThreadPoolAdapter, ApplicationLis
return threadPoolAdapterState;
}
threadPoolAdapterState.setThreadPoolKey(identify);
threadPoolAdapterState.setCoreSize(executor.getCorePoolSize());
threadPoolAdapterState.setMaximumSize(executor.getMaximumPoolSize());
threadPoolAdapterState.setCorePoolSize(executor.getCorePoolSize());
threadPoolAdapterState.setMaximumPoolSize(executor.getMaximumPoolSize());
return threadPoolAdapterState;
}

@ -70,8 +70,8 @@ public abstract class AbstractHystrixThreadPoolAdapter implements ThreadPoolAdap
if (threadPoolExecutor != null) {
BlockingQueue<Runnable> blockingQueue = threadPoolExecutor.getQueue();
result.setThreadPoolKey(identify);
result.setCoreSize(threadPoolExecutor.getCorePoolSize());
result.setMaximumSize(threadPoolExecutor.getMaximumPoolSize());
result.setCorePoolSize(threadPoolExecutor.getCorePoolSize());
result.setMaximumPoolSize(threadPoolExecutor.getMaximumPoolSize());
result.setBlockingQueueCapacity(blockingQueue.size() + blockingQueue.remainingCapacity());
return result;
}

@ -65,11 +65,11 @@ public class KafkaThreadPoolAdapter implements ThreadPoolAdapter, ApplicationLis
result.setThreadPoolKey(identify);
if (listenerContainer instanceof ConcurrentMessageListenerContainer) {
result.setCoreSize(((ConcurrentMessageListenerContainer<?, ?>) listenerContainer).getConcurrency());
result.setMaximumSize(result.getCoreSize());
result.setCorePoolSize(((ConcurrentMessageListenerContainer<?, ?>) listenerContainer).getConcurrency());
result.setMaximumPoolSize(result.getCorePoolSize());
} else {
result.setCoreSize(1);
result.setMaximumSize(1);
result.setCorePoolSize(1);
result.setMaximumPoolSize(1);
}
return result;
}

@ -64,8 +64,8 @@ public class RabbitMQThreadPoolAdapter implements ThreadPoolAdapter, Application
ThreadPoolExecutor threadPoolTaskExecutor = rabbitmqThreadPoolTaskExecutor.get(identify);
threadPoolAdapterState.setThreadPoolKey(identify);
if (Objects.nonNull(threadPoolTaskExecutor)) {
threadPoolAdapterState.setCoreSize(threadPoolTaskExecutor.getCorePoolSize());
threadPoolAdapterState.setMaximumSize(threadPoolTaskExecutor.getMaximumPoolSize());
threadPoolAdapterState.setCorePoolSize(threadPoolTaskExecutor.getCorePoolSize());
threadPoolAdapterState.setMaximumPoolSize(threadPoolTaskExecutor.getMaximumPoolSize());
}
return threadPoolAdapterState;
}

@ -57,8 +57,8 @@ public class RocketMQThreadPoolAdapter implements ThreadPoolAdapter, Application
ThreadPoolExecutor rocketMQConsumeExecutor = rocketmqConsumeExecutor.get(identify);
if (rocketMQConsumeExecutor != null) {
result.setThreadPoolKey(identify);
result.setCoreSize(rocketMQConsumeExecutor.getCorePoolSize());
result.setMaximumSize(rocketMQConsumeExecutor.getMaximumPoolSize());
result.setCorePoolSize(rocketMQConsumeExecutor.getCorePoolSize());
result.setMaximumPoolSize(rocketMQConsumeExecutor.getMaximumPoolSize());
return result;
}
log.warn("[{}] RocketMQ consuming thread pool not found.", identify);

@ -64,17 +64,17 @@ public class SpringCloudStreamRabbitMQThreadPoolAdapter implements ThreadPoolAda
result.setThreadPoolKey(identify);
if (messageListenerContainer instanceof SimpleMessageListenerContainer) {
int concurrentConsumers = (int) ReflectUtil.getFieldValue(messageListenerContainer, "concurrentConsumers");
result.setCoreSize(concurrentConsumers);
result.setCorePoolSize(concurrentConsumers);
Object maxConcurrentConsumers = ReflectUtil.getFieldValue(messageListenerContainer, "maxConcurrentConsumers");
if (maxConcurrentConsumers != null) {
result.setMaximumSize((Integer) maxConcurrentConsumers);
result.setMaximumPoolSize((Integer) maxConcurrentConsumers);
} else {
result.setMaximumSize(concurrentConsumers);
result.setMaximumPoolSize(concurrentConsumers);
}
} else if (messageListenerContainer instanceof DirectMessageListenerContainer) {
int consumersPerQueue = (int) ReflectUtil.getFieldValue(messageListenerContainer, "consumersPerQueue");
result.setCoreSize(consumersPerQueue);
result.setMaximumSize(consumersPerQueue);
result.setCorePoolSize(consumersPerQueue);
result.setMaximumPoolSize(consumersPerQueue);
}
return result;
}

@ -65,8 +65,8 @@ public class SpringCloudStreamRocketMQThreadPoolAdapter implements ThreadPoolAda
ThreadPoolExecutor rocketMQConsumeExecutor = rocketMqSpringCloudStreamConsumeExecutor.get(identify);
if (rocketMQConsumeExecutor != null) {
result.setThreadPoolKey(identify);
result.setCoreSize(rocketMQConsumeExecutor.getCorePoolSize());
result.setMaximumSize(rocketMQConsumeExecutor.getMaximumPoolSize());
result.setCorePoolSize(rocketMQConsumeExecutor.getCorePoolSize());
result.setMaximumPoolSize(rocketMQConsumeExecutor.getMaximumPoolSize());
return result;
}
log.warn("[{}] RocketMQ consuming thread pool not found.", identify);

@ -57,8 +57,8 @@ public class JettyWebThreadPoolHandlerSupport implements IWebThreadPoolHandlerSu
public ThreadPoolBaseInfo simpleInfo() {
ThreadPoolBaseInfo poolBaseInfo = new ThreadPoolBaseInfo();
QueuedThreadPool queuedThreadPool = (QueuedThreadPool) executor;
poolBaseInfo.setCoreSize(queuedThreadPool.getMinThreads());
poolBaseInfo.setMaximumSize(queuedThreadPool.getMaxThreads());
poolBaseInfo.setCorePoolSize(queuedThreadPool.getMinThreads());
poolBaseInfo.setMaximumPoolSize(queuedThreadPool.getMaxThreads());
BlockingQueue jobs = (BlockingQueue) ReflectUtil.getFieldValue(queuedThreadPool, "_jobs");
int queueCapacity = jobs.remainingCapacity() + jobs.size();
poolBaseInfo.setQueueCapacity(queueCapacity);
@ -76,8 +76,8 @@ public class JettyWebThreadPoolHandlerSupport implements IWebThreadPoolHandlerSu
QueuedThreadPool jettyExecutor = (QueuedThreadPool) executor;
int minThreads = jettyExecutor.getMinThreads();
int maxThreads = jettyExecutor.getMaxThreads();
parameterInfo.setCoreSize(minThreads);
parameterInfo.setMaxSize(maxThreads);
parameterInfo.setCorePoolSize(minThreads);
parameterInfo.setMaximumPoolSize(maxThreads);
} catch (Exception ex) {
log.error("Failed to get the jetty thread pool parameter.", ex);
}
@ -102,9 +102,9 @@ public class JettyWebThreadPoolHandlerSupport implements IWebThreadPoolHandlerSu
runStateInfo.setQueueSize(queueSize);
runStateInfo.setQueueCapacity(queueCapacity);
runStateInfo.setQueueRemainingCapacity(remainingCapacity);
runStateInfo.setCoreSize(corePoolSize);
runStateInfo.setCorePoolSize(corePoolSize);
runStateInfo.setPoolSize(poolSize);
runStateInfo.setMaximumSize(maximumPoolSize);
runStateInfo.setMaximumPoolSize(maximumPoolSize);
runStateInfo.setActiveSize(busyCount);
runStateInfo.setCurrentLoad(currentLoad);
runStateInfo.setClientLastRefreshTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));

@ -72,8 +72,8 @@ public class TomcatWebThreadPoolHandlerSupport implements IWebThreadPoolHandlerS
int queueCapacity = queueSize + remainingCapacity;
String rejectedExecutionHandlerName = executor instanceof ThreadPoolExecutor ? ((ThreadPoolExecutor) executor).getRejectedExecutionHandler().getClass().getSimpleName()
: tomcatThreadPoolExecutor.getRejectedExecutionHandler().getClass().getSimpleName();
poolBaseInfo.setCoreSize(corePoolSize);
poolBaseInfo.setMaximumSize(maximumPoolSize);
poolBaseInfo.setCorePoolSize(corePoolSize);
poolBaseInfo.setMaximumPoolSize(maximumPoolSize);
poolBaseInfo.setKeepAliveTime(keepAliveTime);
poolBaseInfo.setQueueType(blockingQueue.getClass().getSimpleName());
poolBaseInfo.setQueueCapacity(queueCapacity);
@ -89,8 +89,8 @@ public class TomcatWebThreadPoolHandlerSupport implements IWebThreadPoolHandlerS
int minThreads = tomcatThreadPoolExecutor.getCorePoolSize();
int maxThreads = tomcatThreadPoolExecutor.getMaximumPoolSize();
long keepAliveTime = tomcatThreadPoolExecutor.getKeepAliveTime(TimeUnit.SECONDS);
parameterInfo.setCoreSize(minThreads);
parameterInfo.setMaxSize(maxThreads);
parameterInfo.setCorePoolSize(minThreads);
parameterInfo.setMaximumPoolSize(maxThreads);
parameterInfo.setKeepAliveTime(keepAliveTime);
} catch (Exception ex) {
log.error("Failed to get the tomcat thread pool parameter.", ex);
@ -118,9 +118,9 @@ public class TomcatWebThreadPoolHandlerSupport implements IWebThreadPoolHandlerS
String queueType = queue.getClass().getSimpleName();
int remainingCapacity = queue.remainingCapacity();
int queueCapacity = queueSize + remainingCapacity;
runStateInfo.setCoreSize(corePoolSize);
runStateInfo.setCorePoolSize(corePoolSize);
runStateInfo.setPoolSize(poolSize);
runStateInfo.setMaximumSize(maximumPoolSize);
runStateInfo.setMaximumPoolSize(maximumPoolSize);
runStateInfo.setActiveSize(activeCount);
runStateInfo.setCurrentLoad(currentLoad);
runStateInfo.setPeakLoad(peakLoad);

@ -63,8 +63,8 @@ public class UndertowWebThreadPoolHandlerSupport implements IWebThreadPoolHandle
int coreSize = xnioWorker.getOption(Options.WORKER_TASK_CORE_THREADS);
int maximumPoolSize = xnioWorker.getOption(Options.WORKER_TASK_MAX_THREADS);
int keepAliveTime = xnioWorker.getOption(Options.WORKER_TASK_KEEPALIVE);
poolBaseInfo.setCoreSize(coreSize);
poolBaseInfo.setMaximumSize(maximumPoolSize);
poolBaseInfo.setCorePoolSize(coreSize);
poolBaseInfo.setMaximumPoolSize(maximumPoolSize);
poolBaseInfo.setKeepAliveTime((long) keepAliveTime);
poolBaseInfo.setRejectedName("-");
poolBaseInfo.setQueueType("-");
@ -83,8 +83,8 @@ public class UndertowWebThreadPoolHandlerSupport implements IWebThreadPoolHandle
int minThreads = xnioWorker.getOption(Options.WORKER_TASK_CORE_THREADS);
int maxThreads = xnioWorker.getOption(Options.WORKER_TASK_MAX_THREADS);
long keepAliveTime = xnioWorker.getOption(Options.WORKER_TASK_KEEPALIVE);
parameterInfo.setCoreSize(minThreads);
parameterInfo.setMaxSize(maxThreads);
parameterInfo.setCorePoolSize(minThreads);
parameterInfo.setMaximumPoolSize(maxThreads);
parameterInfo.setKeepAliveTime(keepAliveTime);
} catch (Exception ex) {
log.error("Failed to get the undertow thread pool parameter.", ex);
@ -114,9 +114,9 @@ public class UndertowWebThreadPoolHandlerSupport implements IWebThreadPoolHandle
activeCount = Math.max(activeCount, 0);
String currentLoad = CalculateUtil.divide(activeCount, maximumPoolSize) + "";
String peakLoad = CalculateUtil.divide(activeCount, maximumPoolSize) + "";
stateInfo.setCoreSize(corePoolSize);
stateInfo.setCorePoolSize(corePoolSize);
stateInfo.setPoolSize(poolSize);
stateInfo.setMaximumSize(maximumPoolSize);
stateInfo.setMaximumPoolSize(maximumPoolSize);
stateInfo.setActiveSize(activeCount);
stateInfo.setCurrentLoad(currentLoad);
stateInfo.setPeakLoad(peakLoad);

@ -47,14 +47,14 @@ public class GlobalRemotePoolInfo implements Serializable {
private String tpId;
/**
* coreSize
* corePoolSize
*/
private Integer coreSize;
private Integer corePoolSize;
/**
* maxSize
* maximumPoolSize
*/
private Integer maxSize;
private Integer maximumPoolSize;
/**
* queueType

@ -28,14 +28,14 @@ import lombok.experimental.Accessors;
public class ThreadPoolBaseInfo {
/**
* coreSize
* corePoolSize
*/
private Integer coreSize;
private Integer corePoolSize;
/**
* maximumSize
* maximumPoolSize
*/
private Integer maximumSize;
private Integer maximumPoolSize;
/**
* queueType

@ -37,8 +37,8 @@ public class ContentUtil {
threadPoolParameterInfo.setTenantId(parameter.getTenantId())
.setItemId(parameter.getItemId())
.setTpId(parameter.getTpId())
.setCoreSize(parameter.getCoreSize())
.setMaxSize(parameter.getMaxSize())
.setCorePoolSize(parameter.getCoreSize())
.setMaximumPoolSize(parameter.getMaxSize())
.setQueueType(parameter.getQueueType())
.setCapacity(parameter.getCapacity())
.setKeepAliveTime(parameter.getKeepAliveTime())

@ -81,8 +81,8 @@ public abstract class AbstractThreadPoolRuntime {
.rejectCount(rejectCount)
.timestamp(System.currentTimeMillis())
.build();
stateInfo.setCoreSize(actualExecutor.getCorePoolSize());
stateInfo.setMaximumSize(actualExecutor.getMaximumPoolSize());
stateInfo.setCorePoolSize(actualExecutor.getCorePoolSize());
stateInfo.setMaximumPoolSize(actualExecutor.getMaximumPoolSize());
stateInfo.setQueueType(blockingQueue.getClass().getSimpleName());
stateInfo.setQueueCapacity(blockingQueue.size() + blockingQueue.remainingCapacity());
return supplement(stateInfo);

@ -56,8 +56,8 @@ public class AdapterThreadPoolMicrometerMonitorHandler extends AbstractAdapterTh
Iterable<Tag> tags = CollectionUtil.newArrayList(
Tag.of(ADAPTER_THREAD_POOL_ID_TAG, threadPoolAdapterState.getThreadPoolKey()),
Tag.of(APPLICATION_NAME_TAG, applicationName));
Metrics.gauge(metricName("core.size"), tags, threadPoolAdapterState, ThreadPoolAdapterState::getCoreSize);
Metrics.gauge(metricName("maximum.size"), tags, threadPoolAdapterState, ThreadPoolAdapterState::getMaximumSize);
Metrics.gauge(metricName("core.size"), tags, threadPoolAdapterState, ThreadPoolAdapterState::getCorePoolSize);
Metrics.gauge(metricName("maximum.size"), tags, threadPoolAdapterState, ThreadPoolAdapterState::getMaximumPoolSize);
Metrics.gauge(metricName("queue.capacity"), tags, threadPoolAdapterState, ThreadPoolAdapterState::getBlockingQueueCapacity);
}

@ -58,8 +58,8 @@ public class DynamicThreadPoolMicrometerMonitorHandler extends AbstractDynamicTh
Tag.of(APPLICATION_NAME_TAG, applicationName));
Metrics.gauge(metricName("current.load"), tags, poolRunStateInfo, ThreadPoolRunStateInfo::getSimpleCurrentLoad);
Metrics.gauge(metricName("peak.load"), tags, poolRunStateInfo, ThreadPoolRunStateInfo::getSimplePeakLoad);
Metrics.gauge(metricName("core.size"), tags, poolRunStateInfo, ThreadPoolRunStateInfo::getCoreSize);
Metrics.gauge(metricName("maximum.size"), tags, poolRunStateInfo, ThreadPoolRunStateInfo::getMaximumSize);
Metrics.gauge(metricName("core.size"), tags, poolRunStateInfo, ThreadPoolRunStateInfo::getCorePoolSize);
Metrics.gauge(metricName("maximum.size"), tags, poolRunStateInfo, ThreadPoolRunStateInfo::getMaximumPoolSize);
Metrics.gauge(metricName("current.size"), tags, poolRunStateInfo, ThreadPoolRunStateInfo::getPoolSize);
Metrics.gauge(metricName("largest.size"), tags, poolRunStateInfo, ThreadPoolRunStateInfo::getLargestPoolSize);
Metrics.gauge(metricName("active.size"), tags, poolRunStateInfo, ThreadPoolRunStateInfo::getActiveSize);

@ -54,8 +54,8 @@ public class WebThreadPoolMicrometerMonitorHandler extends AbstractWebThreadPool
Iterable<Tag> tags = CollectionUtil.newArrayList(Tag.of(APPLICATION_NAME_TAG, applicationName));
Metrics.gauge(metricName("current.load"), tags, webThreadPoolRunStateInfo, ThreadPoolRunStateInfo::getSimpleCurrentLoad);
Metrics.gauge(metricName("peak.load"), tags, webThreadPoolRunStateInfo, ThreadPoolRunStateInfo::getSimplePeakLoad);
Metrics.gauge(metricName("core.size"), tags, webThreadPoolRunStateInfo, ThreadPoolRunStateInfo::getCoreSize);
Metrics.gauge(metricName("maximum.size"), tags, webThreadPoolRunStateInfo, ThreadPoolRunStateInfo::getMaximumSize);
Metrics.gauge(metricName("core.size"), tags, webThreadPoolRunStateInfo, ThreadPoolRunStateInfo::getCorePoolSize);
Metrics.gauge(metricName("maximum.size"), tags, webThreadPoolRunStateInfo, ThreadPoolRunStateInfo::getMaximumPoolSize);
Metrics.gauge(metricName("current.size"), tags, webThreadPoolRunStateInfo, ThreadPoolRunStateInfo::getPoolSize);
Metrics.gauge(metricName("largest.size"), tags, webThreadPoolRunStateInfo, ThreadPoolRunStateInfo::getLargestPoolSize);
Metrics.gauge(metricName("active.size"), tags, webThreadPoolRunStateInfo, ThreadPoolRunStateInfo::getActiveSize);

@ -20,8 +20,6 @@ package cn.hippo4j.config.model.biz.threadpool;
import com.fasterxml.jackson.annotation.JsonAlias;
import lombok.Data;
import java.util.List;
/**
* Config modify verify dto
*/

@ -69,8 +69,8 @@ public class AdapterExecutorsRefreshListener extends AbstractRefreshListener<Ada
threadPoolAdapterMap.forEach((key, val) -> {
if (Objects.equals(val.mark(), each.getMark())) {
ThreadPoolAdapterState threadPoolState = val.getThreadPoolState(each.getThreadPoolKey());
if (!Objects.equals(threadPoolState.getCoreSize(), each.getCorePoolSize())
|| !Objects.equals(threadPoolState.getMaximumSize(), each.getMaximumPoolSize())) {
if (!Objects.equals(threadPoolState.getCorePoolSize(), each.getCorePoolSize())
|| !Objects.equals(threadPoolState.getMaximumPoolSize(), each.getMaximumPoolSize())) {
val.updateThreadPool(BeanUtil.convert(each, ThreadPoolAdapterParameter.class));
DynamicThreadPoolAdapterRegister.ADAPTER_EXECUTORS_MAP.put(buildKey, each);
}

@ -66,17 +66,17 @@ public class WebExecutorRefreshListener extends AbstractRefreshListener<WebExecu
ThreadPoolParameter beforeParameter = webThreadPoolService.getWebThreadPoolParameter();
// Prevent NPE exceptions from being thrown when certain parameters are not configured.
if (nowParameter.getCoreSize() == null) {
nowParameter.setCoreSize(beforeParameter.getCoreSize());
if (nowParameter.corePoolSizeAdapt() == null) {
nowParameter.setCorePoolSize(beforeParameter.getCoreSize());
}
if (nowParameter.getMaxSize() == null) {
nowParameter.setMaxSize(beforeParameter.getMaxSize());
if (nowParameter.maximumPoolSizeAdapt() == null) {
nowParameter.setMaximumPoolSize(beforeParameter.getMaxSize());
}
if (nowParameter.getKeepAliveTime() == null) {
nowParameter.setKeepAliveTime(beforeParameter.getKeepAliveTime());
}
if (!Objects.equals(beforeParameter.getCoreSize(), nowParameter.getCoreSize())
|| !Objects.equals(beforeParameter.getMaxSize(), nowParameter.getMaxSize())
if (!Objects.equals(beforeParameter.getCoreSize(), nowParameter.corePoolSizeAdapt())
|| !Objects.equals(beforeParameter.getMaxSize(), nowParameter.maximumPoolSizeAdapt())
|| !Objects.equals(beforeParameter.getKeepAliveTime(), nowParameter.getKeepAliveTime())) {
webThreadPoolService.updateWebThreadPool(nowParameter);
configChange.sendPoolConfigChange(buildChangeRequest(beforeParameter, nowParameter, webThreadPoolService));
@ -112,7 +112,7 @@ public class WebExecutorRefreshListener extends AbstractRefreshListener<WebExecu
if (webThreadPoolProperties != null && webThreadPoolProperties.getEnable() && match(webThreadPoolProperties)) {
threadPoolParameterInfo = ThreadPoolParameterInfo.builder()
.coreSize(webThreadPoolProperties.getCorePoolSize())
.corePoolSize(webThreadPoolProperties.getCorePoolSize())
.maximumPoolSize(webThreadPoolProperties.getMaximumPoolSize())
.keepAliveTime(webThreadPoolProperties.getKeepAliveTime())
.build();

Loading…
Cancel
Save