use of com.dtp.common.dto.ThreadPoolStats in project dynamic-tp by lyh200.
the class JettyTpHandler method getPoolStats.
@Override
public ThreadPoolStats getPoolStats() {
ThreadPool.SizedThreadPool threadPool = convertAndGet();
ThreadPoolStats poolStats = ThreadPoolStats.builder().corePoolSize(threadPool.getMinThreads()).maximumPoolSize(threadPool.getMaxThreads()).dtpName("jettyWebServerTp").build();
if (threadPool instanceof QueuedThreadPool) {
QueuedThreadPool queuedThreadPool = (QueuedThreadPool) threadPool;
poolStats.setActiveCount(queuedThreadPool.getBusyThreads());
poolStats.setQueueSize(queuedThreadPool.getQueueSize());
poolStats.setPoolSize(queuedThreadPool.getThreads());
}
return poolStats;
}
use of com.dtp.common.dto.ThreadPoolStats in project dynamic-tp by lyh200.
the class DtpMonitor method run.
private void run() {
List<String> names = DtpRegistry.listAllDtpNames();
if (CollUtil.isEmpty(names)) {
return;
}
names.forEach(x -> {
DtpExecutor executor = DtpRegistry.getExecutor(x);
AlarmManager.triggerAlarm(() -> doAlarm(executor, ALARM_TYPES));
ThreadPoolStats poolStats = MetricsConverter.convert(executor);
doCollect(poolStats);
});
publishEvent();
}
use of com.dtp.common.dto.ThreadPoolStats in project dynamic-tp by dromara.
the class MetricsConverter method convert.
public static ThreadPoolStats convert(ExecutorWrapper wrapper) {
if (wrapper.getExecutor() == null) {
return null;
}
ThreadPoolStats poolStats = convertCommon(wrapper.getExecutor());
poolStats.setPoolName(wrapper.getThreadPoolName());
poolStats.setDynamic(false);
return poolStats;
}
use of com.dtp.common.dto.ThreadPoolStats in project dynamic-tp by dromara.
the class DtpMonitor method run.
private void run() {
List<String> dtpNames = DtpRegistry.listAllDtpNames();
List<String> commonNames = DtpRegistry.listAllCommonNames();
if (CollUtil.isEmpty(dtpNames) && CollUtil.isEmpty(commonNames)) {
return;
}
boolean enabledCollect = dtpProperties.isEnabledCollect();
dtpNames.forEach(x -> {
DtpExecutor executor = DtpRegistry.getDtpExecutor(x);
AlarmManager.triggerAlarm(() -> doAlarm(executor, ALARM_TYPES));
if (enabledCollect) {
ThreadPoolStats poolStats = MetricsConverter.convert(executor);
doCollect(poolStats);
}
});
if (!enabledCollect) {
return;
}
commonNames.forEach(x -> {
ExecutorWrapper wrapper = DtpRegistry.getCommonExecutor(x);
ThreadPoolStats poolStats = MetricsConverter.convert(wrapper);
doCollect(poolStats);
});
publishEvent();
}
use of com.dtp.common.dto.ThreadPoolStats in project dynamic-tp by dromara.
the class MicroMeterCollector method collect.
@Override
public void collect(ThreadPoolStats threadPoolStats) {
// metrics must be held with a strong reference, even though it is never referenced within this class
ThreadPoolStats oldStats = GAUGE_CACHE.get(threadPoolStats.getPoolName());
if (Objects.isNull(oldStats)) {
GAUGE_CACHE.put(threadPoolStats.getPoolName(), threadPoolStats);
} else {
BeanUtil.copyProperties(threadPoolStats, oldStats);
}
gauge(GAUGE_CACHE.get(threadPoolStats.getPoolName()));
}
Aggregations