Search in sources :

Example 1 with Metrics

use of com.dtp.common.dto.Metrics 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 2 with Metrics

use of com.dtp.common.dto.Metrics in project dynamic-tp by lyh200.

the class DtpEndpoint method invoke.

@ReadOperation
public List<Metrics> invoke() {
    List<String> dtpNames = DtpRegistry.listAllDtpNames();
    List<Metrics> metricsList = Lists.newArrayList();
    dtpNames.forEach(x -> {
        DtpExecutor executor = DtpRegistry.getExecutor(x);
        metricsList.add(MetricsConverter.convert(executor));
    });
    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) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation)

Aggregations

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