Search in sources :

Example 1 with ExecutorWrapper

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();
}
Also used : ThreadPoolStats(com.dtp.common.dto.ThreadPoolStats) DtpExecutor(com.dtp.core.thread.DtpExecutor) ExecutorWrapper(com.dtp.core.support.ExecutorWrapper)

Example 2 with ExecutorWrapper

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;
}
Also used : JvmStats(com.dtp.common.dto.JvmStats) Metrics(com.dtp.common.dto.Metrics) DtpExecutor(com.dtp.core.thread.DtpExecutor) RuntimeInfo(cn.hutool.system.RuntimeInfo) ExecutorWrapper(com.dtp.core.support.ExecutorWrapper) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation)

Example 3 with ExecutorWrapper

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");
}
Also used : ExecutorWrapper(com.dtp.core.support.ExecutorWrapper)

Aggregations

ExecutorWrapper (com.dtp.core.support.ExecutorWrapper)3 DtpExecutor (com.dtp.core.thread.DtpExecutor)2 RuntimeInfo (cn.hutool.system.RuntimeInfo)1 JvmStats (com.dtp.common.dto.JvmStats)1 Metrics (com.dtp.common.dto.Metrics)1 ThreadPoolStats (com.dtp.common.dto.ThreadPoolStats)1 ReadOperation (org.springframework.boot.actuate.endpoint.annotation.ReadOperation)1