Skip to content

Commit 9a1dc42

Browse files
committed
Refactoring: Convert field data type that 'AlertLogCommand.readLine 'from 'String' to 'int'
1 parent 6d867fb commit 9a1dc42

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@
66
@NoArgsConstructor
77
@Data
88
public class AlertLogCommand {
9-
private String readLine;
9+
private int readLine;
1010
private String readFilePath;
1111
private String dateFormat;
1212
private String dateFormatRegex;
1313
private String[] catchErrorMsg;
1414

15-
public AlertLogCommand(String readLine, String readFilePath) {
15+
public AlertLogCommand(int readLine, String readFilePath) {
1616
this.readLine = readLine;
1717
this.readFilePath = readFilePath;
1818
}
1919

20-
public AlertLogCommand(String readLine, String readFilePath, String dateFormat, String dateFormatRegex) {
20+
public AlertLogCommand(int readLine, String readFilePath, String dateFormat, String dateFormatRegex) {
2121
this.readLine = readLine;
2222
this.readFilePath = readFilePath;
2323
this.dateFormat = dateFormat;
2424
this.dateFormatRegex = dateFormatRegex;
2525
}
2626

27-
public AlertLogCommand(String readLine, String readFilePath, String... catchErrorMsg) {
27+
public AlertLogCommand(int readLine, String readFilePath, String... catchErrorMsg) {
2828
this.readLine = readLine;
2929
this.readFilePath = readFilePath;
3030
this.catchErrorMsg = catchErrorMsg;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ private String getAlertLogStringFromCertainDate(AlertLogCommand alc, String star
241241
// 조회시작일자와 로그의 처음 기록일자를 비교한다.
242242
long diffTime = DateUtils.getDateDiffTime("yyyy-MM-dd", logDate, startDate);
243243
if (diffTime >= 0) { // 조회 Line 수를 더 늘려서 다시 조회
244-
alc.setReadLine(String.valueOf(Integer.parseInt(alc.getReadLine()) * 2));
244+
alc.setReadLine(alc.getReadLine() * 2);
245245
fullAlertLogString = this.checkAlertLog(alc);
246246
} else {
247247
break;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ public JschConnectionInfo getJschConnectionInfo(String serverName) {
546546
@Override
547547
public AlertLogCommand getAlertLogCommand(String serverName) {
548548
String alertLogFilePath = connInfoConfig.getString(serverName + ".server.alertlog.filepath");
549-
String alertLogReadLine = connInfoConfig.getString(serverName + ".server.alertlog.readline");
549+
int alertLogReadLine = connInfoConfig.getInt(serverName + ".server.alertlog.readline");
550550
String alertLogDateFormat = connInfoConfig.getString(serverName + ".server.alertlog.dateformat");
551551
String alertLogDateFormatRegex = connInfoConfig.getString(serverName + ".server.alertlog.dateformatregex");
552552
AlertLogCommand alc = new AlertLogCommand(alertLogReadLine, alertLogFilePath, alertLogDateFormat,

src/test/java/root/core/repository/implement/LinuxServerMonitoringRepositoryTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static void after() {
8383
public void checkAlertLogTest() throws JSchException, IOException {
8484
// Arrange
8585
AlertLogCommand alc = mock(AlertLogCommand.class);
86-
alc.setReadLine("10");
86+
alc.setReadLine(10);
8787
alc.setReadFilePath("/test/alert_DB.log");
8888

8989
String command = String.format("tail -%d %s", alc.getReadLine(), alc.getReadFilePath());
@@ -100,7 +100,7 @@ public void checkAlertLogTest() throws JSchException, IOException {
100100
public void getAlertLogFileLineCountTest() throws IOException, JSchException {
101101
// Arrange
102102
AlertLogCommand alc = mock(AlertLogCommand.class);
103-
alc.setReadLine("10");
103+
alc.setReadLine(10);
104104
alc.setReadFilePath("/test/alert_DB.log");
105105

106106
String command = String.format("cat %s | wc -l", alc.getReadFilePath());
@@ -117,7 +117,7 @@ public void getAlertLogFileLineCountTest() throws IOException, JSchException {
117117
public void checkAlertLogDuringPeriod() throws JSchException, IOException {
118118
// Arrange
119119
AlertLogCommand alc = mock(AlertLogCommand.class);
120-
alc.setReadLine("10");
120+
alc.setReadLine(10);
121121
alc.setReadFilePath("/test/alert_DB.log");
122122

123123
String command1 = String.format("cat %s | wc -l", alc.getReadFilePath());

0 commit comments

Comments
 (0)