Compare commits
2 Commits
0.0.45
...
fa25130c9f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa25130c9f | ||
|
|
b0b67b5d7f |
2
pom.xml
2
pom.xml
@@ -10,7 +10,7 @@
|
||||
</parent>
|
||||
<groupId>com.ecep.contract</groupId>
|
||||
<artifactId>Contract-Manager</artifactId>
|
||||
<version>0.0.45-SNAPSHOT</version>
|
||||
<version>0.0.46-SNAPSHOT</version>
|
||||
<name>Contract-Manager</name>
|
||||
<description>Contract-Manager</description>
|
||||
<url/>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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<ExecutorInfo> executorInfoTable;
|
||||
@FXML
|
||||
private TableColumn<ExecutorInfo, String> executorFieldColumn;
|
||||
@FXML
|
||||
private TableColumn<ExecutorInfo, String> executorValueColumn;
|
||||
@FXML
|
||||
private TableColumn<ExecutorInfo, String> 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();
|
||||
}
|
||||
}
|
||||
@@ -159,26 +159,6 @@
|
||||
</VBox>
|
||||
</graphic>
|
||||
</Button>
|
||||
|
||||
<!-- 任务监控演示 -->
|
||||
<Button mnemonicParsing="false" style="-fx-padding: 6px;" onAction="#onRunTaskMonitorDemo">
|
||||
<graphic>
|
||||
<VBox alignment="CENTER">
|
||||
<children>
|
||||
<ImageView fitHeight="46.0" fitWidth="64.0">
|
||||
<viewport>
|
||||
<Rectangle2D height="46.0" width="64.0"/>
|
||||
</viewport>
|
||||
</ImageView>
|
||||
<Label text="任务监控演示">
|
||||
<VBox.margin>
|
||||
<Insets top="5.0"/>
|
||||
</VBox.margin>
|
||||
</Label>
|
||||
</children>
|
||||
</VBox>
|
||||
</graphic>
|
||||
</Button>
|
||||
</items>
|
||||
<opaqueInsets>
|
||||
<Insets/>
|
||||
|
||||
@@ -8,56 +8,83 @@
|
||||
<?import javafx.scene.control.ToolBar?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
|
||||
<TabPane minHeight="400.0" minWidth="500.0" tabMinWidth="70.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.ecep.contract.manager.ui.task.TaskMonitorViewController">
|
||||
<tabs>
|
||||
<VBox minHeight="400.0" minWidth="500.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.ecep.contract.manager.ui.task.TaskMonitorViewController">
|
||||
<ToolBar>
|
||||
<items>
|
||||
<Button fx:id="runTaskMonitorDemoBtn" text="运行演示任务" onAction="#onRunTaskMonitorDemo"/>
|
||||
</items>
|
||||
</ToolBar>
|
||||
<TabPane tabMinWidth="70.0" VBox.vgrow="ALWAYS">
|
||||
<tabs>
|
||||
<Tab closable="false" text="活动任务">
|
||||
<content>
|
||||
<VBox>
|
||||
<children>
|
||||
<ToolBar prefHeight="40.0" prefWidth="200.0">
|
||||
<items>
|
||||
<Button fx:id="cancelTaskButton" text="取消选中任务" />
|
||||
</items>
|
||||
</ToolBar>
|
||||
<TableView fx:id="activeTasksTable">
|
||||
<columns>
|
||||
<TableColumn fx:id="activeTaskIdColumn" prefWidth="150.0" text="任务ID" />
|
||||
<TableColumn fx:id="activeTaskTitleColumn" prefWidth="200.0" text="任务标题" />
|
||||
<TableColumn fx:id="activeTaskProgressColumn" prefWidth="150.0" text="进度" />
|
||||
<TableColumn fx:id="activeTaskStatusColumn" prefWidth="100.0" text="状态" />
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox>
|
||||
<children>
|
||||
<ToolBar prefHeight="40.0" prefWidth="200.0">
|
||||
<items>
|
||||
<Button fx:id="cancelTaskButton" text="取消选中任务"/>
|
||||
</items>
|
||||
</ToolBar>
|
||||
<TableView fx:id="activeTasksTable">
|
||||
<columns>
|
||||
<TableColumn fx:id="activeTaskIdColumn" prefWidth="150.0" text="任务ID"/>
|
||||
<TableColumn fx:id="activeTaskTitleColumn" prefWidth="200.0" text="任务标题"/>
|
||||
<TableColumn fx:id="activeTaskProgressColumn" prefWidth="150.0" text="进度"/>
|
||||
<TableColumn fx:id="activeTaskStatusColumn" prefWidth="100.0" text="状态"/>
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
</children>
|
||||
</VBox>
|
||||
</content>
|
||||
</Tab>
|
||||
<Tab closable="false" text="任务历史">
|
||||
<content>
|
||||
<content>
|
||||
<!-- 历史任务区域 -->
|
||||
<VBox spacing="5.0">
|
||||
<ToolBar prefHeight="40.0" prefWidth="200.0">
|
||||
<items>
|
||||
<Button fx:id="clearHistoryButton" alignment="CENTER_RIGHT" text="清空历史" />
|
||||
</items>
|
||||
</ToolBar>
|
||||
<ToolBar prefHeight="40.0" prefWidth="200.0">
|
||||
<items>
|
||||
<Button fx:id="clearHistoryButton" alignment="CENTER_RIGHT" text="清空历史"/>
|
||||
</items>
|
||||
</ToolBar>
|
||||
<TableView fx:id="historyTasksTable" VBox.vgrow="ALWAYS">
|
||||
<columns>
|
||||
<TableColumn fx:id="historyTaskIdColumn" prefWidth="150.0" text="任务ID" />
|
||||
<TableColumn fx:id="historyTaskTitleColumn" prefWidth="200.0" text="任务标题" />
|
||||
<TableColumn fx:id="historyTaskStatusColumn" prefWidth="100.0" text="状态" />
|
||||
<TableColumn fx:id="historyTaskStartTimeColumn" prefWidth="150.0" text="开始时间" />
|
||||
<TableColumn fx:id="historyTaskExecutionTimeColumn" prefWidth="100.0" text="执行耗时" />
|
||||
<TableColumn fx:id="historyTaskIdColumn" prefWidth="150.0" text="任务ID"/>
|
||||
<TableColumn fx:id="historyTaskTitleColumn" prefWidth="200.0" text="任务标题"/>
|
||||
<TableColumn fx:id="historyTaskStatusColumn" prefWidth="100.0" text="状态"/>
|
||||
<TableColumn fx:id="historyTaskStartTimeColumn" prefWidth="150.0" text="开始时间"/>
|
||||
<TableColumn fx:id="historyTaskExecutionTimeColumn" prefWidth="100.0" text="执行耗时"/>
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
</VBox>
|
||||
</content>
|
||||
</content>
|
||||
</Tab>
|
||||
</tabs>
|
||||
</TabPane>
|
||||
<Tab closable="false" text="Executor">
|
||||
<content>
|
||||
<VBox spacing="5.0">
|
||||
<ToolBar prefHeight="40.0" prefWidth="200.0">
|
||||
<items>
|
||||
<Button fx:id="refreshExecutorInfoButton" text="刷新"/>
|
||||
</items>
|
||||
</ToolBar>
|
||||
<TableView fx:id="executorInfoTable" VBox.vgrow="ALWAYS">
|
||||
<columns>
|
||||
<TableColumn fx:id="executorFieldColumn" prefWidth="150.0" text="字段"/>
|
||||
<TableColumn fx:id="executorValueColumn" prefWidth="200.0" text="值"/>
|
||||
<TableColumn fx:id="executorDescriptionColumn" prefWidth="300.0" text="描述"/>
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
</VBox>
|
||||
</content>
|
||||
</Tab>
|
||||
</tabs>
|
||||
</TabPane>
|
||||
</VBox>
|
||||
|
||||
Reference in New Issue
Block a user