Skip to content

Commit f671eb1

Browse files
committed
Refactoring: Remove 'AlertLogCommandPeriod' Model
1 parent c9ebc06 commit f671eb1

File tree

9 files changed

+24
-64
lines changed

9 files changed

+24
-64
lines changed

src/main/java/root/applications/ConsoleApp.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import root.common.server.implement.JschServer;
1616
import root.core.batch.DBCheckBatch;
1717
import root.core.batch.ServerCheckBatch;
18-
import root.core.domain.AlertLogCommandPeriod;
1918
import root.core.domain.JdbcConnectionInfo;
2019
import root.core.domain.JschConnectionInfo;
2120
import root.core.repository.constracts.DBCheckRepository;
@@ -167,9 +166,9 @@ public static void main(String[] args) throws IOException {
167166
ServerCheckUsecase usecase = new ServerCheckUsecaseImpl(repo, ReportFileRepo.getInstance());
168167
ServerCheckBatch serverBatch = new ServerCheckBatch(usecase);
169168

170-
AlertLogCommandPeriod alcp = new AlertLogCommandPeriod(jsch.getAlc(),
171-
DateUtils.addDate(DateUtils.getToday("yyyy-MM-dd"), 0, 0, -1), DateUtils.getToday("yyyy-MM-dd"));
172-
serverBatch.startBatchAlertLogCheckDuringPeriod(alcp);
169+
String startDate = DateUtils.addDate(DateUtils.getToday("yyyy-MM-dd"), 0, 0, -1);
170+
String endDate = DateUtils.getToday("yyyy-MM-dd");
171+
serverBatch.startBatchAlertLogCheckDuringPeriod(jsch.getAlc(), startDate, endDate);
173172
serverBatch.startBatchOSDiskUsageCheck();
174173
System.out.println("■ [ " + jsch.getServerName() + " Monitoring End ]\n\n");
175174
}

src/main/java/root/applications/CsvReportSeparatorApp.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
import java.util.regex.Pattern;
1111

1212
import root.core.repository.constracts.ReportRepository;
13-
import root.core.repository.implement.ReportRepositoryImpl;
13+
import root.core.repository.implement.ReportFileRepo;
1414
import root.utils.DateUtils;
1515

1616
public class CsvReportSeparatorApp {
1717

18-
public static ReportRepository reportRepository = ReportRepositoryImpl.getInstance();
18+
public static ReportRepository reportRepository = ReportFileRepo.getInstance();
1919

2020
public static void main(String[] args) throws IOException {
2121
/*

src/main/java/root/core/batch/ServerCheckBatch.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package root.core.batch;
22

33
import root.core.domain.AlertLogCommand;
4-
import root.core.domain.AlertLogCommandPeriod;
54
import root.core.usecase.constracts.ServerCheckUsecase;
65

76
public class ServerCheckBatch {
@@ -19,9 +18,9 @@ public void startBatchAlertLogCheck(AlertLogCommand alc) {
1918
}
2019
}
2120

22-
public void startBatchAlertLogCheckDuringPeriod(AlertLogCommandPeriod alcp) {
21+
public void startBatchAlertLogCheckDuringPeriod(AlertLogCommand alc, String startDate, String endDate) {
2322
try {
24-
this.serverCheckUsecase.printAlertLogDuringPeriod(alcp);
23+
this.serverCheckUsecase.printAlertLogDuringPeriod(alc, startDate, endDate);
2524
}catch(Exception e) {
2625
e.printStackTrace();
2726
}

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

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/main/java/root/core/repository/constracts/ServerCheckRepository.java

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

77
import root.core.domain.AlertLog;
88
import root.core.domain.AlertLogCommand;
9-
import root.core.domain.AlertLogCommandPeriod;
109
import root.core.domain.OSDiskUsage;
1110

1211
public interface ServerCheckRepository {
@@ -22,7 +21,7 @@ public interface ServerCheckRepository {
2221

2322
String checkAlertLog(AlertLogCommand alc);
2423

25-
AlertLog checkAlertLogDuringPeriod(AlertLogCommandPeriod alc);
24+
AlertLog checkAlertLogDuringPeriod(AlertLogCommand alc, String startDate, String endDate);
2625

2726
List<OSDiskUsage> checkOSDiskUsage();
2827
}

src/main/java/root/core/repository/implement/ServerCheckRepositoryImpl.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import root.common.server.implement.JschServer;
1818
import root.core.domain.AlertLog;
1919
import root.core.domain.AlertLogCommand;
20-
import root.core.domain.AlertLogCommandPeriod;
2120
import root.core.domain.Log;
2221
import root.core.domain.OSDiskUsage;
2322
import root.core.repository.constracts.ServerCheckRepository;
@@ -95,17 +94,15 @@ public String checkAlertLog(AlertLogCommand alc) {
9594
}
9695

9796
@Override
98-
public AlertLog checkAlertLogDuringPeriod(AlertLogCommandPeriod alcp) {
97+
public AlertLog checkAlertLogDuringPeriod(AlertLogCommand alc, String startDate, String endDate) {
9998
AlertLog alertLog = new AlertLog();
100-
int alertLogFileLineCnt = this.getAlertLogFileLineCount(alcp);
101-
String fullAlertLogString = this.checkAlertLog(alcp);
102-
String dateFormat = alcp.getDateFormat();
103-
String dateFormatRegex = alcp.getDateFormatRegex();
99+
int alertLogFileLineCnt = this.getAlertLogFileLineCount(alc);
100+
String fullAlertLogString = this.checkAlertLog(alc);
101+
String dateFormat = alc.getDateFormat();
102+
String dateFormatRegex = alc.getDateFormatRegex();
104103
int dateLength = dateFormat.equals("yyyy-MM-dd") ? 11 : 24;
105104

106105
try {
107-
String startDate = alcp.getFromDate();
108-
String endDate = alcp.getToDate();
109106

110107
// 조회시작일자의 로그를 모두 포함하도록 readLine 수를 점진적으로 늘리면서 읽는다.
111108
while(true) {
@@ -129,8 +126,8 @@ public AlertLog checkAlertLogDuringPeriod(AlertLogCommandPeriod alcp) {
129126
// 조회시작일자와 로그의 처음 기록일자를 비교한다.
130127
long diffTime = DateUtils.getDateDiffTime("yyyy-MM-dd", logDate, startDate);
131128
if(diffTime >= 0) { // 조회 Line 수를 더 늘려서 다시 조회
132-
alcp.setReadLine(String.valueOf(Integer.parseInt(alcp.getReadLine()) * 2));
133-
fullAlertLogString = this.checkAlertLog(alcp);
129+
alc.setReadLine(String.valueOf(Integer.parseInt(alc.getReadLine()) * 2));
130+
fullAlertLogString = this.checkAlertLog(alc);
134131
} else {
135132
break;
136133
}
@@ -199,7 +196,7 @@ public AlertLog checkAlertLogDuringPeriod(AlertLogCommandPeriod alcp) {
199196
alertLog.setFullLogString(sb.toString());
200197

201198
realNumberOfReadLine = readEndIndex - readStartIndex;
202-
System.out.println("\t▶ Alert Log READ LINE: " + realNumberOfReadLine + "/" + alcp.getReadLine());
199+
System.out.println("\t▶ Alert Log READ LINE: " + realNumberOfReadLine + "/" + alc.getReadLine());
203200

204201
} catch (Exception e) {
205202
e.printStackTrace();

src/main/java/root/core/usecase/constracts/ServerCheckUsecase.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44

55
import root.core.domain.AlertLog;
66
import root.core.domain.AlertLogCommand;
7-
import root.core.domain.AlertLogCommandPeriod;
87
import root.core.domain.OSDiskUsage;
98

109
public interface ServerCheckUsecase {
1110
void printAlertLog(AlertLogCommand alc);
1211

13-
void printAlertLogDuringPeriod(AlertLogCommandPeriod alcp);
12+
void printAlertLogDuringPeriod(AlertLogCommand alc, String startDate, String endDate);
1413

1514
void printOSDiskUsage();
1615

@@ -20,5 +19,5 @@ public interface ServerCheckUsecase {
2019

2120
List<OSDiskUsage> getCurrentOSDiskUsage();
2221

23-
AlertLog getAlertLogDuringPeriod(AlertLogCommandPeriod alcp);
22+
AlertLog getAlertLogDuringPeriod(AlertLogCommand alc, String startDate, String endDate);
2423
}

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import dnl.utils.text.table.csv.CsvTableModel;
2020
import root.core.domain.AlertLog;
2121
import root.core.domain.AlertLogCommand;
22-
import root.core.domain.AlertLogCommandPeriod;
2322
import root.core.domain.Log;
2423
import root.core.domain.OSDiskUsage;
2524
import root.core.repository.constracts.ReportRepository;
@@ -52,8 +51,8 @@ public void printAlertLog(AlertLogCommand alc) {
5251
}
5352

5453
@Override
55-
public void printAlertLogDuringPeriod(AlertLogCommandPeriod alcp) {
56-
AlertLog result = serverCheckRepository.checkAlertLogDuringPeriod(alcp);
54+
public void printAlertLogDuringPeriod(AlertLogCommand alc, String startDate, String endDate) {
55+
AlertLog result = serverCheckRepository.checkAlertLogDuringPeriod(alc, startDate, endDate);
5756
List<Log> logContents = result.getAlertLogs();
5857

5958
boolean isError = false;
@@ -264,8 +263,8 @@ public List<OSDiskUsage> getCurrentOSDiskUsage() {
264263
}
265264

266265
@Override
267-
public AlertLog getAlertLogDuringPeriod(AlertLogCommandPeriod alcp) {
268-
AlertLog result = serverCheckRepository.checkAlertLogDuringPeriod(alcp);
266+
public AlertLog getAlertLogDuringPeriod(AlertLogCommand alc, String startDate, String endDate) {
267+
AlertLog result = serverCheckRepository.checkAlertLogDuringPeriod(alc, startDate, endDate);
269268
return result;
270269
}
271270
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import javafx.scene.control.DatePicker;
1818
import root.common.server.implement.JschServer;
1919
import root.core.domain.AlertLog;
20-
import root.core.domain.AlertLogCommandPeriod;
2120
import root.core.domain.JschConnectionInfo;
2221
import root.core.domain.Log;
2322
import root.core.repository.constracts.ServerCheckRepository;
@@ -188,8 +187,8 @@ public void monitoringAlertLog(ActionEvent e) {
188187
ServerCheckRepository repo = new ServerCheckRepositoryImpl(server);
189188
ServerCheckUsecase usecase = new ServerCheckUsecaseImpl(repo, ReportFileRepo.getInstance());
190189

191-
AlertLogCommandPeriod alcp = new AlertLogCommandPeriod(connInfo.getAlc(), alertLogStartDay, alertLogEndDay);
192-
alertLogMonitoringResultMap.put(selectedServer, usecase.getAlertLogDuringPeriod(alcp));
190+
alertLogMonitoringResultMap.put(selectedServer,
191+
usecase.getAlertLogDuringPeriod(connInfo.getAlc(), alertLogStartDay, alertLogEndDay));
193192

194193
changeAlertLogListViewData(alertLogServerComboBox.getSelectionModel().getSelectedItem());
195194
}

0 commit comments

Comments
 (0)