|
@@ -1,14 +1,17 @@
|
|
|
package cn.reghao.devops.common.agent.machine;
|
|
package cn.reghao.devops.common.agent.machine;
|
|
|
|
|
|
|
|
|
|
+import cn.reghao.devops.common.agent.app.iface.AppStat;
|
|
|
import cn.reghao.devops.common.machine.Machine;
|
|
import cn.reghao.devops.common.machine.Machine;
|
|
|
import cn.reghao.devops.common.msg.MessageSender;
|
|
import cn.reghao.devops.common.msg.MessageSender;
|
|
|
import cn.reghao.devops.common.msg.event.EvtAgentHeartbeat;
|
|
import cn.reghao.devops.common.msg.event.EvtAgentHeartbeat;
|
|
|
import cn.reghao.devops.common.msg.event.EvtAgentStart;
|
|
import cn.reghao.devops.common.msg.event.EvtAgentStart;
|
|
|
|
|
+import cn.reghao.devops.common.msg.event.EvtAppStatResult;
|
|
|
import cn.reghao.jutil.jdk.event.message.EventMessage;
|
|
import cn.reghao.jutil.jdk.event.message.EventMessage;
|
|
|
import cn.reghao.jutil.jdk.thread.ThreadPoolWrapper;
|
|
import cn.reghao.jutil.jdk.thread.ThreadPoolWrapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
|
import java.util.concurrent.ScheduledFuture;
|
|
import java.util.concurrent.ScheduledFuture;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -22,13 +25,16 @@ public class MachineEvent {
|
|
|
private final ScheduledExecutorService scheduler;
|
|
private final ScheduledExecutorService scheduler;
|
|
|
private ScheduledFuture<?> heartbeatFuture;
|
|
private ScheduledFuture<?> heartbeatFuture;
|
|
|
private final Machine machine;
|
|
private final Machine machine;
|
|
|
|
|
+ private final AppStat appStat;
|
|
|
private final MessageSender messageSender;
|
|
private final MessageSender messageSender;
|
|
|
private final int heartbeatInterval;
|
|
private final int heartbeatInterval;
|
|
|
|
|
|
|
|
- public MachineEvent(MessageSender messageSender, Machine machine, ScheduledExecutorService scheduler, int heartbeatInterval) {
|
|
|
|
|
- this.scheduler = scheduler;
|
|
|
|
|
- this.machine = machine;
|
|
|
|
|
|
|
+ public MachineEvent(MessageSender messageSender, Machine machine, AppStat appStat,
|
|
|
|
|
+ ScheduledExecutorService scheduler, int heartbeatInterval) {
|
|
|
this.messageSender = messageSender;
|
|
this.messageSender = messageSender;
|
|
|
|
|
+ this.machine = machine;
|
|
|
|
|
+ this.appStat = appStat;
|
|
|
|
|
+ this.scheduler = scheduler;
|
|
|
this.heartbeatInterval = heartbeatInterval;
|
|
this.heartbeatInterval = heartbeatInterval;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -37,6 +43,16 @@ public class MachineEvent {
|
|
|
EventMessage eventMessage = EventMessage.evt(evtAgentStart);
|
|
EventMessage eventMessage = EventMessage.evt(evtAgentStart);
|
|
|
pub(eventMessage);
|
|
pub(eventMessage);
|
|
|
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ List<EvtAppStatResult> list = appStat.stat();
|
|
|
|
|
+ list.forEach(evtAppStatResult -> {
|
|
|
|
|
+ EventMessage eventMessage1 = EventMessage.evt(evtAppStatResult);
|
|
|
|
|
+ pub(eventMessage1);
|
|
|
|
|
+ });
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
agentHeartbeat();
|
|
agentHeartbeat();
|
|
|
}
|
|
}
|
|
|
|
|
|