diff --git a/pom.xml b/pom.xml
index 3d2c263..8e307cb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
com.ecep.contract
Contract-Manager
- 0.0.45-SNAPSHOT
+ 0.0.46-SNAPSHOT
Contract-Manager
Contract-Manager
diff --git a/src/main/java/com/ecep/contract/manager/ds/other/controller/HomeWindowController.java b/src/main/java/com/ecep/contract/manager/ds/other/controller/HomeWindowController.java
index f4248a5..3f9a7ec 100644
--- a/src/main/java/com/ecep/contract/manager/ds/other/controller/HomeWindowController.java
+++ b/src/main/java/com/ecep/contract/manager/ds/other/controller/HomeWindowController.java
@@ -220,13 +220,4 @@ public class HomeWindowController extends BaseController {
public void onShowTaskMonitorWindowAction(ActionEvent event) {
showInOwner(TaskMonitorViewController.class);
}
-
- /**
- * 运行任务监控演示
- */
- public void onRunTaskMonitorDemo(ActionEvent event) {
- com.ecep.contract.manager.ui.task.DemoTask.runDemo();
- // 自动打开任务监控窗口
- showInOwner(TaskMonitorViewController.class);
- }
}
diff --git a/src/main/java/com/ecep/contract/manager/ui/task/TaskMonitorCenter.java b/src/main/java/com/ecep/contract/manager/ui/task/TaskMonitorCenter.java
index 171373b..af7e189 100644
--- a/src/main/java/com/ecep/contract/manager/ui/task/TaskMonitorCenter.java
+++ b/src/main/java/com/ecep/contract/manager/ui/task/TaskMonitorCenter.java
@@ -162,7 +162,7 @@ public class TaskMonitorCenter {
tooltip.setText("当前运行任务数: " + activeTasks.size());
});
monitorLabel.setOnMouseClicked(event -> {
- BaseController.show(TaskMonitorViewController.class, monitorLabel.getScene().getWindow());
+ BaseController.show(TaskMonitorViewController.class, monitorLabel.getScene().getWindow());
});
}
}
\ No newline at end of file
diff --git a/src/main/java/com/ecep/contract/manager/ui/task/TaskMonitorViewController.java b/src/main/java/com/ecep/contract/manager/ui/task/TaskMonitorViewController.java
index 1323797..42ebaf8 100644
--- a/src/main/java/com/ecep/contract/manager/ui/task/TaskMonitorViewController.java
+++ b/src/main/java/com/ecep/contract/manager/ui/task/TaskMonitorViewController.java
@@ -1,5 +1,9 @@
package com.ecep.contract.manager.ui.task;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import org.springframework.context.annotation.Lazy;
@@ -13,6 +17,7 @@ import com.ecep.contract.manager.ui.Message;
import com.ecep.contract.manager.util.MyDateTimeUtils;
import javafx.beans.property.SimpleStringProperty;
+import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
@@ -30,6 +35,7 @@ import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
+import javafx.beans.property.SimpleStringProperty;
import javafx.scene.text.Text;
import javafx.stage.WindowEvent;
@@ -69,10 +75,47 @@ public class TaskMonitorViewController extends BaseController {
private Button cancelTaskButton;
@FXML
private Button clearHistoryButton;
+ @FXML
+ private Button refreshExecutorInfoButton;
+ @FXML
+ private TableView executorInfoTable;
+ @FXML
+ private TableColumn executorFieldColumn;
+ @FXML
+ private TableColumn executorValueColumn;
+ @FXML
+ private TableColumn executorDescriptionColumn;
public TaskMonitorViewController() {
}
+ /**
+ * 用于存储ExecutorService信息的内部类
+ */
+ public static class ExecutorInfo {
+ private final String field;
+ private final String value;
+ private final String description;
+
+ public ExecutorInfo(String field, String value, String description) {
+ this.field = field;
+ this.value = value;
+ this.description = description;
+ }
+
+ public String getField() {
+ return field;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+ }
+
@Override
public void onShown(WindowEvent windowEvent) {
super.onShown(windowEvent);
@@ -144,6 +187,94 @@ public class TaskMonitorViewController extends BaseController {
});
cancelTaskButton.disableProperty().bind(activeTasksTable.getSelectionModel().selectedItemProperty().isNull());
+ // 初始化Executor信息表格
+ initializeExecutorInfoTable();
+ }
+
+ /**
+ * 初始化Executor信息表格
+ */
+ private void initializeExecutorInfoTable() {
+ executorFieldColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getField()));
+ executorValueColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getValue()));
+ executorDescriptionColumn
+ .setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getDescription()));
+
+ // 初始加载Executor信息
+ refreshExecutorInfo();
+ // 绑定刷新按钮事件
+ refreshExecutorInfoButton.setOnAction(event -> refreshExecutorInfo());
+ }
+
+ /**
+ * 刷新Executor信息
+ */
+ @FXML
+ private void refreshExecutorInfo() {
+ executorInfoTable.getItems().clear();
+
+ try {
+ ExecutorService executorService = Desktop.instance.getExecutorService();
+ if (executorService instanceof ThreadPoolExecutor threadPoolExecutor) {
+ executorInfoTable.getItems().add(new ExecutorInfo(
+ "PoolSize",
+ String.valueOf(threadPoolExecutor.getPoolSize()),
+ "PoolSize"));
+ executorInfoTable.getItems().add(new ExecutorInfo(
+ "活动线程数",
+ String.valueOf(threadPoolExecutor.getActiveCount()),
+ "当前正在执行任务的线程数"));
+ // 添加线程池信息
+ executorInfoTable.getItems().add(new ExecutorInfo(
+ "核心线程数",
+ String.valueOf(threadPoolExecutor.getCorePoolSize()),
+ "线程池维护的最小线程数"));
+ executorInfoTable.getItems().add(new ExecutorInfo(
+ "最大线程数",
+ String.valueOf(threadPoolExecutor.getMaximumPoolSize()),
+ "线程池允许的最大线程数"));
+ executorInfoTable.getItems().add(new ExecutorInfo(
+ "KeepAliveTime",
+ String.valueOf(threadPoolExecutor.getKeepAliveTime(TimeUnit.SECONDS)),
+ "the thread keep-alive time, which is the amount of time that threads may remain idle before being terminated. Threads that wait this amount of time without processing a task will be terminated if there are more than the core number of threads currently in the pool, or if this pool allows core thread timeout."));
+
+ executorInfoTable.getItems().add(new ExecutorInfo(
+ "任务队列大小",
+ String.valueOf(threadPoolExecutor.getQueue().size()),
+ "等待执行的任务数量"));
+ executorInfoTable.getItems().add(new ExecutorInfo(
+ "已完成任务数",
+ String.valueOf(threadPoolExecutor.getCompletedTaskCount()),
+ "已完成执行的任务总数"));
+ executorInfoTable.getItems().add(new ExecutorInfo(
+ "LargestPoolSize",
+ String.valueOf(threadPoolExecutor.getLargestPoolSize()),
+ "线程池当前状态"));
+
+ // 如果是ScheduledExecutorService,添加额外信息
+ if (executorService instanceof ScheduledExecutorService) {
+ executorInfoTable.getItems().add(new ExecutorInfo(
+ "线程池类型",
+ "ScheduledExecutorService",
+ "可调度的线程池"));
+ } else {
+ executorInfoTable.getItems().add(new ExecutorInfo(
+ "线程池类型",
+ "ThreadPoolExecutor",
+ "普通线程池"));
+ }
+ } else {
+ executorInfoTable.getItems().add(new ExecutorInfo(
+ "错误",
+ "未知的ExecutorService类型",
+ "无法获取线程池详细信息"));
+ }
+ } catch (Exception e) {
+ executorInfoTable.getItems().add(new ExecutorInfo(
+ "异常",
+ e.getMessage(),
+ "获取ExecutorService信息时发生错误"));
+ }
}
/**
@@ -205,7 +336,7 @@ public class TaskMonitorViewController extends BaseController {
text.setFill(Color.ORANGE);
} else if (msg.getLevel() == Level.SEVERE) {
text.setFill(Color.RED);
- }else if (msg.getLevel()== Level.CONFIG) {
+ } else if (msg.getLevel() == Level.CONFIG) {
text.setFill(Color.GRAY);
}
vBox.getChildren().add(text);
@@ -218,4 +349,11 @@ public class TaskMonitorViewController extends BaseController {
alert.getDialogPane().setContent(scrollPane);
alert.showAndWait();
}
+
+ /**
+ * 运行任务监控演示
+ */
+ public void onRunTaskMonitorDemo(ActionEvent event) {
+ com.ecep.contract.manager.ui.task.DemoTask.runDemo();
+ }
}
\ No newline at end of file
diff --git a/src/main/resources/ui/home.fxml b/src/main/resources/ui/home.fxml
index ad61bb9..3503e20 100644
--- a/src/main/resources/ui/home.fxml
+++ b/src/main/resources/ui/home.fxml
@@ -159,26 +159,6 @@
-
-
-
diff --git a/src/main/resources/ui/task/TaskMonitorView.fxml b/src/main/resources/ui/task/TaskMonitorView.fxml
index 4be2d75..148b545 100644
--- a/src/main/resources/ui/task/TaskMonitorView.fxml
+++ b/src/main/resources/ui/task/TaskMonitorView.fxml
@@ -8,56 +8,83 @@
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+