use of com.dtp.core.support.ExecutorWrapper 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.core.support.ExecutorWrapper in project dynamic-tp by dromara.
the class DtpEndpoint method invoke.
@ReadOperation
public List<Metrics> invoke() {
List<String> dtpNames = DtpRegistry.listAllDtpNames();
List<String> commonNames = DtpRegistry.listAllCommonNames();
List<Metrics> metricsList = Lists.newArrayList();
dtpNames.forEach(x -> {
DtpExecutor executor = DtpRegistry.getDtpExecutor(x);
metricsList.add(MetricsConverter.convert(executor));
});
commonNames.forEach(x -> {
ExecutorWrapper wrapper = DtpRegistry.getCommonExecutor(x);
metricsList.add(MetricsConverter.convert(wrapper));
});
JvmStats jvmStats = new JvmStats();
RuntimeInfo runtimeInfo = new RuntimeInfo();
jvmStats.setMaxMemory(FileUtil.readableFileSize(runtimeInfo.getMaxMemory()));
jvmStats.setTotalMemory(FileUtil.readableFileSize(runtimeInfo.getTotalMemory()));
jvmStats.setFreeMemory(FileUtil.readableFileSize(runtimeInfo.getFreeMemory()));
jvmStats.setUsableMemory(FileUtil.readableFileSize(runtimeInfo.getUsableMemory()));
metricsList.add(jvmStats);
return metricsList;
}
use of com.dtp.core.support.ExecutorWrapper in project dynamic-tp by dromara.
the class DtpPostProcessor method registerCommon.
private void registerCommon(String poolName, ThreadPoolExecutor executor) {
ExecutorWrapper wrapper = new ExecutorWrapper();
wrapper.setThreadPoolName(poolName);
wrapper.setExecutor(executor);
DtpRegistry.registerCommon(wrapper, "beanPostProcessor");
}
Aggregations