修改动态线程池运行时数据上报方式.

pull/28/head
chen.ma 3 years ago
parent 7fb2e178c0
commit 2a14a402e3

@ -1,6 +1,7 @@
package cn.hippo4j.starter.monitor;
import cn.hippo4j.common.monitor.Message;
import cn.hippo4j.common.monitor.MessageWrapper;
import cn.hippo4j.starter.remote.HttpAgent;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -22,7 +23,9 @@ public class HttpMvcSender implements MessageSender {
@Override
public void send(Message message) {
try {
httpAgent.httpPost(MONITOR_PATH, message);
MessageWrapper messageWrapper = new MessageWrapper(message);
messageWrapper.setMessageType(message.getMessageType());
httpAgent.httpPost(MONITOR_PATH, messageWrapper);
} catch (Throwable ex) {
log.error("Failed to push dynamic thread pool runtime data.", ex);
}

@ -75,8 +75,8 @@ public class ReportingEventExecutor extends AbstractThreadPoolRuntime implements
@Override
public void run(String... args) {
// 延迟 10秒后每 5秒调用一次. scheduleAtFixedRate 间隔周期是前后两次任务的开始时间计算的, 不考虑执行任务本身的耗时
collectVesselExecutor.scheduleAtFixedRate(() -> runTimeGatherTask(), 10, 5, TimeUnit.SECONDS);
// 延迟 10秒后每 5秒调用一次. scheduleWithFixedDelay 每次执行时间为上一次任务结束时, 向后推一个时间间隔
collectVesselExecutor.scheduleWithFixedDelay(() -> runTimeGatherTask(), 10, 5, TimeUnit.SECONDS);
ThreadUtil.newThread(this, "reporting-task", Boolean.TRUE).start();
log.info("Dynamic thread pool :: [{}]. The dynamic thread pool starts data collection and reporting. ", getThreadPoolNum());
@ -108,7 +108,7 @@ public class ReportingEventExecutor extends AbstractThreadPoolRuntime implements
runtimeMessages.add(runtimeMessage);
}
message.setMessageTypeEnum(MessageTypeEnum.RUNTIME);
message.setMessageType(MessageTypeEnum.RUNTIME);
message.setMessages(runtimeMessages);
return message;

Loading…
Cancel
Save