luoluoyuyu commented on code in PR #3764:
URL: https://github.com/apache/streampipes/pull/3764#discussion_r2362844169
##########
streampipes-model/src/main/java/org/apache/streampipes/model/loadbalancer/ServiceLoadDataReportGenerator.java:
##########
@@ -0,0 +1,84 @@
+package org.apache.streampipes.model.loadbalancer;
+
+
+import com.sun.management.OperatingSystemMXBean;
+
+import java.lang.management.ManagementFactory;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+public class ServiceLoadDataReportGenerator {
+ private static final int CPU_CHECK_MILLIS = 100;
+ private static final double totalCPULimit;
+ private static final OperatingSystemMXBean systemBean;
+ private static final ServiceLoadDataReport serviceLoadDataReport;;
+
+ private static final ScheduledExecutorService executorService;
+ private static double CPUUsageSum = 0d;
+ private static double CPUUsageCount = 0;
+
+ static {
+ executorService = Executors.newSingleThreadScheduledExecutor();
+ systemBean = (OperatingSystemMXBean)
ManagementFactory.getOperatingSystemMXBean();
+ serviceLoadDataReport = new ServiceLoadDataReport();
+ totalCPULimit = getTotalCPULimit();
+
+ serviceLoadDataReport.setMemory(getMemoryUsage());
+
+ // 启动定时任务
+
executorService.scheduleWithFixedDelay(ServiceLoadDataReportGenerator::checkCPULoad,
CPU_CHECK_MILLIS, CPU_CHECK_MILLIS, TimeUnit.MILLISECONDS);
Review Comment:
Please don't use Chinese
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]