feat: Support getting the plugin information when getting the thread pool information

pull/944/head
huangchengxing 3 years ago
parent 061109de79
commit 91a9806a29

@ -24,6 +24,7 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import java.io.Serializable;
import java.util.Collection;
/**
* Pool run state info.
@ -115,6 +116,11 @@ public class ThreadPoolRunStateInfo extends ThreadPoolBaseInfo implements Serial
*/
private Long timestamp;
/**
* plugin runtime info
*/
private Collection<PluginRuntimeInfo> pluginRuntimeInfos;
public Integer getSimpleCurrentLoad() {
return Integer.parseInt(getCurrentLoad().replace("%", ""));
}

@ -18,13 +18,15 @@
package cn.hippo4j.core.executor.state;
import cn.hippo4j.common.model.ThreadPoolRunStateInfo;
import cn.hippo4j.common.toolkit.CalculateUtil;
import cn.hippo4j.core.executor.DynamicThreadPoolExecutor;
import cn.hippo4j.core.executor.DynamicThreadPoolWrapper;
import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage;
import cn.hippo4j.common.toolkit.CalculateUtil;
import cn.hippo4j.core.plugin.manager.ThreadPoolPluginSupport;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
@ -80,6 +82,7 @@ public abstract class AbstractThreadPoolRuntime {
.queueRemainingCapacity(blockingQueue.remainingCapacity())
.rejectCount(rejectCount)
.timestamp(System.currentTimeMillis())
.pluginRuntimeInfos(actualExecutor instanceof ThreadPoolPluginSupport ? ((ThreadPoolPluginSupport) actualExecutor).getAllPluginRuntimes() : Collections.emptyList())
.build();
stateInfo.setCoreSize(actualExecutor.getCorePoolSize());
stateInfo.setMaximumSize(actualExecutor.getMaximumPoolSize());

@ -25,6 +25,7 @@ import cn.hippo4j.common.toolkit.MemoryUtil;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.core.executor.DynamicThreadPoolWrapper;
import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage;
import static cn.hippo4j.core.toolkit.IdentifyUtil.CLIENT_IDENTIFICATION_VALUE;
import cn.hippo4j.core.toolkit.inet.InetUtils;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -32,8 +33,6 @@ import org.springframework.core.env.ConfigurableEnvironment;
import java.util.concurrent.ThreadPoolExecutor;
import static cn.hippo4j.core.toolkit.IdentifyUtil.CLIENT_IDENTIFICATION_VALUE;
/**
* Thread pool run state service.
*/
@ -67,6 +66,7 @@ public class ThreadPoolRunStateHandler extends AbstractThreadPoolRuntime {
rejectedName = pool.getRejectedExecutionHandler().getClass().getSimpleName();
poolRunStateInfo.setRejectedName(rejectedName);
ManyThreadPoolRunStateInfo manyThreadPoolRunStateInfo = BeanUtil.convert(poolRunStateInfo, ManyThreadPoolRunStateInfo.class);
manyThreadPoolRunStateInfo.setPluginRuntimeInfos(poolRunStateInfo.getPluginRuntimeInfos());
manyThreadPoolRunStateInfo.setIdentify(CLIENT_IDENTIFICATION_VALUE);
String active = environment.getProperty("spring.profiles.active", "UNKNOWN");
manyThreadPoolRunStateInfo.setActive(active.toUpperCase());

Loading…
Cancel
Save