Skip to content

Commit caa5b55

Browse files
authored
Merge pull request #223 from Dokyeongyun/ft-220423-alertLogMonitoringSummary
Ft 220423 alert log monitoring summary
2 parents 0d2bd79 + c920f21 commit caa5b55

File tree

7 files changed

+305
-25
lines changed

7 files changed

+305
-25
lines changed

src/main/java/root/core/domain/AlertLog.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
@Data
99
public class AlertLog {
10+
private String filePath;
1011
private String fullLogString;
1112
private List<Log> alertLogs;
1213

src/main/java/root/core/usecase/implement/ServerMonitoringUsecaseImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,9 @@ public AlertLog getAlertLogDuringPeriod(AlertLogCommand alc, String startDate, S
344344
}
345345
}
346346

347-
// 종료 후 fullLogString 추가
347+
// 종료 후 fullLogString 추가 & Alert log file path 설정
348348
alertLog.setFullLogString(sb.toString());
349+
alertLog.setFilePath(alc.getReadFilePath());
349350

350351
log.info("\t▶ Alert Log READ LINE: " + (readEndIndex - readStartIndex) + "/" + alc.getReadLine());
351352

src/main/java/root/javafx/Controller/AlertLogMonitoringMenuController.java

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import javafx.fxml.Initializable;
1616
import javafx.scene.control.Alert.AlertType;
1717
import javafx.scene.control.DatePicker;
18+
import javafx.scene.layout.AnchorPane;
19+
import javafx.scene.layout.StackPane;
1820
import root.common.server.implement.JschServer;
1921
import root.core.domain.AlertLog;
2022
import root.core.domain.JschConnectionInfo;
@@ -30,6 +32,7 @@
3032
import root.core.usecase.constracts.ServerMonitoringUsecase;
3133
import root.core.usecase.implement.ServerMonitoringUsecaseImpl;
3234
import root.javafx.CustomView.AlertLogListViewCell;
35+
import root.javafx.CustomView.AlertLogMonitoringSummaryAP;
3336
import root.javafx.CustomView.dateCell.DisableAfterTodayDateCell;
3437
import root.utils.AlertUtils;
3538

@@ -54,6 +57,15 @@ public class AlertLogMonitoringMenuController implements Initializable {
5457
@FXML
5558
JFXListView<Log> alertLogLV;
5659

60+
@FXML
61+
StackPane alertLogSummarySP;
62+
63+
@FXML
64+
AnchorPane mainNodataAP;
65+
66+
@FXML
67+
AnchorPane summaryNodataAP;
68+
5769
Map<String, AlertLog> alertLogMonitoringResultMap;
5870

5971
public AlertLogMonitoringMenuController() {
@@ -96,9 +108,15 @@ public void initialize(URL location, ResourceBundle resources) {
96108

97109
private void changeAlertLogListViewData(String serverID) {
98110
alertLogLV.getItems().clear();
99-
AlertLog al = alertLogMonitoringResultMap.get(serverID);
100-
if (al != null) {
101-
alertLogLV.getItems().addAll(al.getAlertLogs());
111+
AlertLog alertLog = alertLogMonitoringResultMap.get(serverID);
112+
if (alertLog != null) {
113+
// Alert Log ListView
114+
alertLogLV.getItems().addAll(alertLog.getAlertLogs());
115+
116+
// Alert Log Summary
117+
alertLogSummarySP.getChildren().add(new AlertLogMonitoringSummaryAP(alertLog));
118+
} else {
119+
// TODO There is no alert log monitoring result
102120
}
103121
}
104122

@@ -135,6 +153,11 @@ private void initAlertLogMonitoringElements() {
135153

136154
// AlertLog ListView
137155
alertLogLV.setCellFactory(categoryList -> new AlertLogListViewCell());
156+
157+
// Set view visible
158+
mainNodataAP.setVisible(true);
159+
alertLogLV.setVisible(false);
160+
summaryNodataAP.setVisible(true);
138161
}
139162

140163
/**
@@ -196,9 +219,15 @@ public void monitoringAlertLog(ActionEvent e) throws Exception {
196219
}
197220
ServerMonitoringUsecase usecase = new ServerMonitoringUsecaseImpl(repo, ReportFileRepo.getInstance());
198221

199-
alertLogMonitoringResultMap.put(selectedServer,
200-
usecase.getAlertLogDuringPeriod(connInfo.getAlc(), alertLogStartDay, alertLogEndDay));
222+
AlertLog result = usecase.getAlertLogDuringPeriod(connInfo.getAlc(), alertLogStartDay, alertLogEndDay);
223+
alertLogMonitoringResultMap.put(selectedServer, result);
201224

202225
changeAlertLogListViewData(alertLogServerComboBox.getSelectionModel().getSelectedItem());
226+
227+
// Set view visible
228+
mainNodataAP.setVisible(false);
229+
alertLogLV.setVisible(true);
230+
summaryNodataAP.setVisible(false);
231+
summaryNodataAP.toBack();
203232
}
204233
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
package root.javafx.CustomView;
2+
3+
import java.io.IOException;
4+
import java.net.URL;
5+
import java.util.ArrayList;
6+
import java.util.List;
7+
import java.util.ResourceBundle;
8+
9+
import javafx.beans.property.SimpleDoubleProperty;
10+
import javafx.beans.property.SimpleIntegerProperty;
11+
import javafx.collections.FXCollections;
12+
import javafx.fxml.FXML;
13+
import javafx.fxml.FXMLLoader;
14+
import javafx.fxml.Initializable;
15+
import javafx.scene.control.Label;
16+
import javafx.scene.control.ListView;
17+
import javafx.scene.control.TableColumn;
18+
import javafx.scene.control.TableView;
19+
import javafx.scene.layout.AnchorPane;
20+
import lombok.Data;
21+
import lombok.extern.slf4j.Slf4j;
22+
import root.core.domain.AlertLog;
23+
import root.core.domain.Log;
24+
import root.javafx.DI.DependencyInjection;
25+
26+
@Slf4j
27+
public class AlertLogMonitoringSummaryAP extends AnchorPane implements Initializable {
28+
29+
@FXML
30+
Label alertLogFileLB;
31+
32+
@FXML
33+
private TableView<AlertLogSummary> summaryTV;
34+
35+
@FXML
36+
private TableColumn<AlertLogSummary, Integer> totalCL;
37+
38+
@FXML
39+
private TableColumn<AlertLogSummary, Integer> normalCL;
40+
41+
@FXML
42+
private TableColumn<AlertLogSummary, Integer> errorCL;
43+
44+
@FXML
45+
private TableColumn<AlertLogSummary, Double> errorRateCL;
46+
47+
@FXML
48+
private ListView<Log> errorLogLV;
49+
50+
private AlertLog alertLog;
51+
52+
private List<Log> errorLogs = new ArrayList<>();
53+
54+
public AlertLogMonitoringSummaryAP(AlertLog alertLog) {
55+
this.alertLog = alertLog;
56+
try {
57+
FXMLLoader loader = DependencyInjection.getLoader("/fxml/AlertLogMonitoringSummary.fxml");
58+
loader.setController(this);
59+
loader.setRoot(this);
60+
loader.load();
61+
} catch (IOException e) {
62+
log.error(e.getMessage());
63+
}
64+
}
65+
66+
@Override
67+
public void initialize(URL location, ResourceBundle resources) {
68+
// Set cell value factory of summary table column
69+
totalCL.setCellValueFactory(cellData -> cellData.getValue().getTotalLogCount().asObject());
70+
normalCL.setCellValueFactory(cellData -> cellData.getValue().getNormalLogCount().asObject());
71+
errorCL.setCellValueFactory(cellData -> cellData.getValue().getErrorLogCount().asObject());
72+
errorRateCL.setCellValueFactory(cellData -> cellData.getValue().getErrorRate().asObject());
73+
74+
// Set cell factory of error log listview
75+
errorLogLV.setCellFactory(categoryList -> new AlertLogListViewCell());
76+
77+
render();
78+
}
79+
80+
private void render() {
81+
// Set Alert log file path label text
82+
alertLogFileLB.setText(alertLog.getFilePath());
83+
84+
// Set summary tableview value
85+
summaryTV.setItems(FXCollections.observableArrayList(List.of(getSummaryData())));
86+
87+
errorLogLV.getItems().addAll(errorLogs);
88+
}
89+
90+
private AlertLogSummary getSummaryData() {
91+
int total = 0;
92+
int normal = 0;
93+
int error = 0;
94+
95+
for (Log l : alertLog.getAlertLogs()) {
96+
total++;
97+
boolean isErrorLog = false;
98+
for (String s : l.getLogContents()) {
99+
// TODO Remove hard-coding that identifying error log
100+
if (s.contains("ORA-")) {
101+
isErrorLog = true;
102+
break;
103+
}
104+
}
105+
if (isErrorLog) {
106+
error++;
107+
errorLogs.add(l);
108+
} else {
109+
normal++;
110+
}
111+
}
112+
113+
return new AlertLogSummary(total, normal, error);
114+
}
115+
116+
@Data
117+
private static class AlertLogSummary {
118+
private SimpleIntegerProperty totalLogCount;
119+
private SimpleIntegerProperty normalLogCount;
120+
private SimpleIntegerProperty errorLogCount;
121+
private SimpleDoubleProperty errorRate;
122+
123+
public AlertLogSummary(int totalLogCount, int normalLogCount, int errorLogCount) {
124+
double rate = (double) Math.round((errorLogCount / (double) totalLogCount * 100) * 100) / 100;
125+
126+
this.totalLogCount = new SimpleIntegerProperty(totalLogCount);
127+
this.normalLogCount = new SimpleIntegerProperty(normalLogCount);
128+
this.errorLogCount = new SimpleIntegerProperty(errorLogCount);
129+
this.errorRate = new SimpleDoubleProperty(rate);
130+
}
131+
}
132+
}

src/main/resources/css/javaFx.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,14 @@
268268
.gray-scrollbar .scroll-bar:vertical .thumb {
269269
-fx-background-color: derive(gray,40.0%);
270270
}
271+
272+
/* No scrollbar tableview */
273+
.no-scrollbar-tableview .virtual-flow .scroll-bar * {
274+
-fx-min-width: 0;
275+
-fx-pref-width: 0;
276+
-fx-max-width: 0;
277+
278+
-fx-min-height: 0;
279+
-fx-pref-height: 0;
280+
-fx-max-height: 0;
281+
}

0 commit comments

Comments
 (0)