Skip to content

Commit 2345609

Browse files
committed
添加Zookeeper工具。
1 parent 81f6cab commit 2345609

8 files changed

Lines changed: 366 additions & 2 deletions

File tree

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,12 @@
200200
<artifactId>jsch</artifactId>
201201
<version>0.1.55</version>
202202
</dependency>
203+
<dependency>
204+
<groupId>com.101tec</groupId>
205+
<artifactId>zkclient</artifactId>
206+
<version>0.10</version>
207+
<scope>compile</scope>
208+
</dependency>
203209

204210
<!-- 目录文件监控工具包 -->
205211
<!-- <dependency> <groupId>net.sf.jpathwatch</groupId> <artifactId>jpathwatch</artifactId>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package com.xwintop.xJavaFxTool.controller.debugTools;
2+
3+
import com.xwintop.xJavaFxTool.services.debugTools.ZookeeperToolService;
4+
import com.xwintop.xJavaFxTool.view.debugTools.ZookeeperToolView;
5+
import javafx.event.ActionEvent;
6+
import javafx.fxml.FXML;
7+
import javafx.scene.control.TreeItem;
8+
import lombok.Getter;
9+
import lombok.Setter;
10+
import lombok.extern.slf4j.Slf4j;
11+
12+
import java.net.URL;
13+
import java.util.ResourceBundle;
14+
15+
/**
16+
* @ClassName: ZookeeperToolController
17+
* @Description: Zookeeper工具
18+
* @author: xufeng
19+
* @date: 2019/4/8 17:00
20+
*/
21+
22+
@Getter
23+
@Setter
24+
@Slf4j
25+
public class ZookeeperToolController extends ZookeeperToolView {
26+
private ZookeeperToolService zookeeperToolService = new ZookeeperToolService(this);
27+
28+
@Override
29+
public void initialize(URL location, ResourceBundle resources) {
30+
initView();
31+
initEvent();
32+
initService();
33+
}
34+
35+
private void initView() {
36+
TreeItem<String> treeItem = new TreeItem<String>("/");
37+
nodeTreeView.setRoot(treeItem);
38+
}
39+
40+
private void initEvent() {
41+
}
42+
43+
private void initService() {
44+
}
45+
46+
@FXML
47+
private void connectOnAction(ActionEvent event) {
48+
zookeeperToolService.connectOnAction();
49+
}
50+
51+
@FXML
52+
private void disconnectOnAction(ActionEvent event) {
53+
zookeeperToolService.disconnectOnAction();
54+
}
55+
56+
@FXML
57+
private void refreshOnAction(ActionEvent event) {
58+
zookeeperToolService.refreshOnAction();
59+
}
60+
61+
@FXML
62+
private void deleteNodeOnAction(ActionEvent event) {
63+
zookeeperToolService.disconnectOnAction();
64+
}
65+
66+
@FXML
67+
private void addNodeOnAction(ActionEvent event) {
68+
zookeeperToolService.addNodeOnAction();
69+
}
70+
71+
@FXML
72+
private void nodeDataSaveOnAction(ActionEvent event) {
73+
74+
}
75+
76+
77+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package com.xwintop.xJavaFxTool.services.debugTools;
2+
3+
import com.xwintop.xJavaFxTool.controller.debugTools.ZookeeperToolController;
4+
import javafx.scene.control.TreeItem;
5+
import lombok.Getter;
6+
import lombok.Setter;
7+
import lombok.extern.slf4j.Slf4j;
8+
import org.I0Itec.zkclient.ZkClient;
9+
import org.apache.commons.lang3.StringUtils;
10+
11+
import java.util.List;
12+
13+
/**
14+
* @ClassName: ZookeeperToolService
15+
* @Description: Zookeeper工具
16+
* @author: xufeng
17+
* @date: 2019/4/8 17:00
18+
*/
19+
20+
@Getter
21+
@Setter
22+
@Slf4j
23+
public class ZookeeperToolService {
24+
public ZookeeperToolController zookeeperToolController;
25+
26+
ZkClient zkClient = null;
27+
28+
public ZookeeperToolService(ZookeeperToolController zookeeperToolController) {
29+
this.zookeeperToolController = zookeeperToolController;
30+
}
31+
32+
public void connectOnAction() {
33+
if (zkClient == null) {
34+
zkClient = new ZkClient(zookeeperToolController.getZkServersTextField().getText().trim());
35+
// zkClient.setZkSerializer(new ZKStringSerializer());
36+
}
37+
zookeeperToolController.getNodeTreeView().getRoot().getChildren().clear();
38+
this.addNodeTree("/", zookeeperToolController.getNodeTreeView().getRoot());
39+
}
40+
41+
private void addNodeTree(String path, TreeItem<String> treeItem) {
42+
List<String> list = zkClient.getChildren(path);
43+
for (String name : list) {
44+
log.info("获取到文件:" + path + "/" + name);
45+
TreeItem<String> treeItem2 = new TreeItem<>(name);
46+
treeItem.getChildren().add(treeItem2);
47+
this.addNodeTree(StringUtils.appendIfMissing(path, "/", "/") + name, treeItem2);
48+
}
49+
}
50+
51+
public void disconnectOnAction() {
52+
53+
}
54+
55+
public void refreshOnAction() {
56+
57+
}
58+
59+
public void deleteNodeOnAction() {
60+
61+
}
62+
63+
public void addNodeOnAction() {
64+
65+
}
66+
67+
public void nodeDataSaveOnAction() {
68+
69+
}
70+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package com.xwintop.xJavaFxTool.view.debugTools;
2+
3+
import javafx.fxml.FXML;
4+
import javafx.fxml.Initializable;
5+
import javafx.scene.control.Button;
6+
import javafx.scene.control.TextArea;
7+
import javafx.scene.control.TextField;
8+
import javafx.scene.control.TreeView;
9+
import lombok.Getter;
10+
import lombok.Setter;
11+
12+
/**
13+
* @ClassName: ZookeeperToolView
14+
* @Description: Zookeeper工具
15+
* @author: xufeng
16+
* @date: 2019/4/8 17:00
17+
*/
18+
19+
@Getter
20+
@Setter
21+
public abstract class ZookeeperToolView implements Initializable {
22+
@FXML
23+
protected TextField zkServersTextField;
24+
@FXML
25+
protected Button connectButton;
26+
@FXML
27+
protected Button disconnectButton;
28+
@FXML
29+
protected Button refreshButton;
30+
@FXML
31+
protected Button addNodeButton;
32+
@FXML
33+
protected Button deleteNodeButton;
34+
@FXML
35+
protected TreeView<String> nodeTreeView;
36+
@FXML
37+
protected Button nodeDataSaveButton;
38+
@FXML
39+
protected TextArea nodeDataValueTextArea;
40+
@FXML
41+
protected TextField A_VERSIONTextField;
42+
@FXML
43+
protected TextField C_TIMETextField;
44+
@FXML
45+
protected TextField C_VERSIONTextField;
46+
@FXML
47+
protected TextField CZXIDTextField;
48+
@FXML
49+
protected TextField DATA_LENGTHTextField;
50+
@FXML
51+
protected TextField EPHEMERAL_OWNERTextField;
52+
@FXML
53+
protected TextField M_TIMETextField;
54+
@FXML
55+
protected TextField MZXIDTextField;
56+
@FXML
57+
protected TextField NUM_CHILDRENTextField;
58+
@FXML
59+
protected TextField PZXIDTextField;
60+
@FXML
61+
protected TextField VERSIONTextField;
62+
@FXML
63+
protected TextField aclSchemeTextField;
64+
@FXML
65+
protected TextField aclIdTextField;
66+
@FXML
67+
protected TextField aclPermissionsTextField;
68+
69+
}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import javafx.geometry.Insets?>
4+
<?import javafx.scene.control.Button?>
5+
<?import javafx.scene.control.Label?>
6+
<?import javafx.scene.control.SplitPane?>
7+
<?import javafx.scene.control.Tab?>
8+
<?import javafx.scene.control.TabPane?>
9+
<?import javafx.scene.control.TextArea?>
10+
<?import javafx.scene.control.TextField?>
11+
<?import javafx.scene.control.TreeView?>
12+
<?import javafx.scene.layout.AnchorPane?>
13+
<?import javafx.scene.layout.BorderPane?>
14+
<?import javafx.scene.layout.ColumnConstraints?>
15+
<?import javafx.scene.layout.GridPane?>
16+
<?import javafx.scene.layout.HBox?>
17+
<?import javafx.scene.layout.RowConstraints?>
18+
19+
<AnchorPane prefHeight="517.0" prefWidth="859.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.xwintop.xJavaFxTool.controller.debugTools.ZookeeperToolController">
20+
<children>
21+
<BorderPane AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0">
22+
<top>
23+
<HBox alignment="CENTER_LEFT" prefWidth="200.0" spacing="10.0" BorderPane.alignment="CENTER">
24+
<children>
25+
<Label text="zkServers" />
26+
<TextField fx:id="zkServersTextField" text="localhost:2181" />
27+
<Button fx:id="connectButton" mnemonicParsing="false" onAction="#connectOnAction" text="连接" />
28+
<Button fx:id="disconnectButton" mnemonicParsing="false" onAction="#disconnectOnAction" text="关闭" />
29+
<Button fx:id="refreshButton" mnemonicParsing="false" onAction="#refreshOnAction" text="刷新" />
30+
<Button fx:id="addNodeButton" mnemonicParsing="false" onAction="#addNodeOnAction" text="添加子结点" />
31+
<Button fx:id="deleteNodeButton" mnemonicParsing="false" onAction="#deleteNodeOnAction" text="删除" />
32+
</children>
33+
<BorderPane.margin>
34+
<Insets bottom="10.0" />
35+
</BorderPane.margin>
36+
</HBox>
37+
</top>
38+
<center>
39+
<SplitPane dividerPositions="0.34560906515580736" BorderPane.alignment="CENTER">
40+
<items>
41+
<TreeView fx:id="nodeTreeView" />
42+
<TabPane tabClosingPolicy="UNAVAILABLE">
43+
<tabs>
44+
<Tab text="Node Data">
45+
<content>
46+
<BorderPane>
47+
<top>
48+
<HBox alignment="CENTER_LEFT" spacing="10.0" BorderPane.alignment="CENTER">
49+
<children>
50+
<Button fx:id="nodeDataSaveButton" mnemonicParsing="false" onAction="#nodeDataSaveOnAction" text="保存" />
51+
</children>
52+
<BorderPane.margin>
53+
<Insets bottom="5.0" top="5.0" />
54+
</BorderPane.margin>
55+
</HBox>
56+
</top>
57+
<center>
58+
<TextArea fx:id="nodeDataValueTextArea" BorderPane.alignment="CENTER" />
59+
</center>
60+
</BorderPane>
61+
</content>
62+
</Tab>
63+
<Tab text="Node Metadata">
64+
<content>
65+
<GridPane>
66+
<columnConstraints>
67+
<ColumnConstraints hgrow="SOMETIMES" maxWidth="267.0" minWidth="10.0" prefWidth="128.0" />
68+
<ColumnConstraints hgrow="SOMETIMES" maxWidth="416.0" minWidth="10.0" prefWidth="416.0" />
69+
</columnConstraints>
70+
<rowConstraints>
71+
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
72+
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
73+
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
74+
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
75+
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
76+
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
77+
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
78+
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
79+
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
80+
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
81+
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
82+
</rowConstraints>
83+
<children>
84+
<TextField fx:id="A_VERSIONTextField" editable="false" GridPane.columnIndex="1" />
85+
<Label text="ACL Version" />
86+
<TextField fx:id="C_TIMETextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="1" />
87+
<TextField fx:id="C_VERSIONTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="2" />
88+
<TextField fx:id="CZXIDTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="3" />
89+
<TextField fx:id="DATA_LENGTHTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="4" />
90+
<TextField fx:id="EPHEMERAL_OWNERTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="5" />
91+
<TextField fx:id="M_TIMETextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="6" />
92+
<TextField fx:id="MZXIDTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="7" />
93+
<TextField fx:id="NUM_CHILDRENTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="8" />
94+
<TextField fx:id="PZXIDTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="9" />
95+
<TextField fx:id="VERSIONTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="10" />
96+
<Label text="Creation Time" GridPane.rowIndex="1" />
97+
<Label text="Children Version" GridPane.rowIndex="2" />
98+
<Label text="Creation ID" GridPane.rowIndex="3" />
99+
<Label text="Data Length" GridPane.rowIndex="4" />
100+
<Label text="Ephemeral Owner" GridPane.rowIndex="5" />
101+
<Label text="Last Modified Time" GridPane.rowIndex="6" />
102+
<Label text="Modified ID" GridPane.rowIndex="7" />
103+
<Label text="Number of Children" GridPane.rowIndex="8" />
104+
<Label text="Node ID" GridPane.rowIndex="9" />
105+
<Label text="Data Version" GridPane.rowIndex="10" />
106+
</children>
107+
<padding>
108+
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
109+
</padding>
110+
</GridPane>
111+
</content>
112+
</Tab>
113+
<Tab text="Node ACLs">
114+
<content>
115+
<AnchorPane minHeight="0.0" minWidth="0.0">
116+
<children>
117+
<Label layoutX="14.0" layoutY="14.0" text="Scheme:" />
118+
<TextField fx:id="aclSchemeTextField" editable="false" layoutX="98.0" layoutY="10.0" />
119+
<Label layoutX="14.0" layoutY="53.0" text="Id:" />
120+
<TextField fx:id="aclIdTextField" editable="false" layoutX="98.0" layoutY="49.0" />
121+
<Label layoutX="14.0" layoutY="94.0" text="Permissions:" />
122+
<TextField fx:id="aclPermissionsTextField" editable="false" layoutX="98.0" layoutY="90.0" />
123+
</children>
124+
</AnchorPane>
125+
</content>
126+
</Tab>
127+
</tabs>
128+
</TabPane>
129+
</items>
130+
</SplitPane>
131+
</center>
132+
</BorderPane>
133+
</children>
134+
</AnchorPane>

src/main/resources/config/toolFxmlLoaderConfiguration.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@
245245
<title>GatewayConfTool</title>
246246
<menuParentId>epmsTools</menuParentId>
247247
</ToolFxmlLoaderConfiguration>
248+
<ToolFxmlLoaderConfiguration>
249+
<url>/com/xwintop/xJavaFxTool/fxmlView/debugTools/ZookeeperTool.fxml</url>
250+
<title>ZookeeperTool</title>
251+
<menuParentId>debugTools</menuParentId>
252+
<isDefaultShow>true</isDefaultShow>
253+
</ToolFxmlLoaderConfiguration>
248254

249255
<ToolFxmlLoaderConfiguration url="/web/littleTools/cron/index.htm"
250256
title="webCronExpBuilder" menuParentId="netWorkToolsMenu"

src/main/resources/locale/Menu.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,5 @@ x2048=2048
7777
SocketTool=Socket\u8C03\u8BD5\u5DE5\u5177
7878
ImageAnalysisTool=\u56FE\u7247\u62C6\u5206\u5DE5\u5177
7979
DecompilerWxApkgTool=\u53CD\u7F16\u8BD1\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u5305\u5DE5\u5177
80-
GatewayConfTool=Gateway\u914D\u7F6E\u5DE5\u5177
80+
GatewayConfTool=Gateway\u914D\u7F6E\u5DE5\u5177
81+
ZookeeperTool=Zookeeper\u5DE5\u5177

0 commit comments

Comments
 (0)