diff --git a/src/main/java/com/kamco/cd/kamcoback/Innopam/InnopamApiController.java b/src/main/java/com/kamco/cd/kamcoback/Innopam/InnopamApiController.java index b70631c0..cf4d49eb 100644 --- a/src/main/java/com/kamco/cd/kamcoback/Innopam/InnopamApiController.java +++ b/src/main/java/com/kamco/cd/kamcoback/Innopam/InnopamApiController.java @@ -4,16 +4,10 @@ import com.kamco.cd.kamcoback.Innopam.dto.ChngDetectMastDto; import com.kamco.cd.kamcoback.Innopam.dto.ChngDetectMastDto.ChnDetectMastReqDto; import com.kamco.cd.kamcoback.Innopam.dto.ChngDetectMastDto.ChngDetectMastSearchDto; import com.kamco.cd.kamcoback.Innopam.dto.ChngDetectMastDto.ResReturn; -import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto; import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.Basic; import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.DetectMastReq; -import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.DetectMastSearch; -import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.FeaturePnuDto; -import com.kamco.cd.kamcoback.Innopam.service.DetectMastService; import com.kamco.cd.kamcoback.Innopam.service.InnopamApiService; -import com.kamco.cd.kamcoback.config.api.ApiResponseDto; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -21,12 +15,9 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import java.util.List; -import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -57,55 +48,53 @@ public class InnopamApiController { @PostMapping("/mast/regist") public ChngDetectMastDto.Basic regist( @RequestBody @Valid ChngDetectMastDto.ChnDetectMastReqDto chnDetectMastReq) { - //innopamApiService.saveDetectMast(chnDetectMastReq); + // innopamApiService.saveDetectMast(chnDetectMastReq); return innopamApiService.regist(chnDetectMastReq); } - @Operation(summary = "탐지결과 삭제", description = "탐지결과 삭제") @ApiResponses( - value = { - @ApiResponse( - responseCode = "201", - description = "등록 성공", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = ChnDetectMastReqDto.class))), - @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), - @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) - }) + value = { + @ApiResponse( + responseCode = "201", + description = "등록 성공", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = ChnDetectMastReqDto.class))), + @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), + @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) + }) @PostMapping("/mast/remove") public ResReturn remove( - @RequestBody @Valid ChngDetectMastDto.ChnDetectMastReqDto chnDetectMastReq) { + @RequestBody @Valid ChngDetectMastDto.ChnDetectMastReqDto chnDetectMastReq) { return innopamApiService.remove(chnDetectMastReq); } @Operation(summary = "탐지결과 등록목록 조회", description = "탐지결과 등록목록 조회") @GetMapping("/mast/list") @ApiResponses( - value = { - @ApiResponse( - responseCode = "200", - description = "목록 성공", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = Basic.class))), - @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), - @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) - }) + value = { + @ApiResponse( + responseCode = "200", + description = "목록 성공", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = Basic.class))), + @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), + @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) + }) public List selectChangeDetectionList( - @RequestParam(required = false) String chnDtctId, - @RequestParam(required = false) String cprsYr, - @RequestParam(required = false) String crtrYr, - @RequestParam(required = false) String chnDtctSno) { - ChngDetectMastSearchDto searchDto = new ChngDetectMastSearchDto(); - searchDto.setChnDtctId(chnDtctId); - searchDto.setCprsYr(cprsYr); - searchDto.setCrtrYr(crtrYr); - searchDto.setChnDtctSno(chnDtctSno); + @RequestParam(required = false) String chnDtctId, + @RequestParam(required = false) String cprsYr, + @RequestParam(required = false) String crtrYr, + @RequestParam(required = false) String chnDtctSno) { + ChngDetectMastSearchDto searchDto = new ChngDetectMastSearchDto(); + searchDto.setChnDtctId(chnDtctId); + searchDto.setCprsYr(cprsYr); + searchDto.setCrtrYr(crtrYr); + searchDto.setChnDtctSno(chnDtctSno); return innopamApiService.list(searchDto); } - } diff --git a/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java b/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java index 28656121..fbe82c07 100644 --- a/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java +++ b/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java @@ -439,7 +439,6 @@ public class FIleChecker { String parentPath = path.getParent().toString(); String fullPath = path.toAbsolutePath().toString(); - File file = new File(fullPath); long fileSize = file.length(); String lastModified = dttmFormat.format(new Date(file.lastModified())); diff --git a/src/main/java/com/kamco/cd/kamcoback/config/resttemplate/ExternalHttpClient.java b/src/main/java/com/kamco/cd/kamcoback/config/resttemplate/ExternalHttpClient.java index 928e72d1..013e01b5 100644 --- a/src/main/java/com/kamco/cd/kamcoback/config/resttemplate/ExternalHttpClient.java +++ b/src/main/java/com/kamco/cd/kamcoback/config/resttemplate/ExternalHttpClient.java @@ -1,7 +1,5 @@ package com.kamco.cd.kamcoback.config.resttemplate; -import java.net.InetAddress; -import java.net.UnknownHostException; import lombok.RequiredArgsConstructor; import lombok.extern.log4j.Log4j2; import org.springframework.http.HttpEntity; @@ -71,6 +69,4 @@ public class ExternalHttpClient { } public record ExternalCallResult(int statusCode, boolean success, T body) {} - - } diff --git a/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultDto.java b/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultDto.java index 711e5006..657c5132 100644 --- a/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultDto.java +++ b/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultDto.java @@ -538,14 +538,15 @@ public class InferenceResultDto { public String getServerStatus() { String enumId = "SAFETY"; - if( this.cpu_user+this.cpu_system+this.gpuUtil+this.kbmemused == 0 )enumId = "FAILUR"; + if (this.cpu_user + this.cpu_system + this.gpuUtil + this.kbmemused == 0) enumId = "FAILUR"; // if( this.cpu_user+this.cpu_system >= 80 )enumId = "CAUTION"; return enumId; } public String getServerStatusName() { String enumStr = ServerStatus.SAFETY.getText(); - if( this.cpu_user+this.cpu_system+this.gpuUtil+this.kbmemused == 0 )enumStr = ServerStatus.FAILUR.getText(); + if (this.cpu_user + this.cpu_system + this.gpuUtil + this.kbmemused == 0) + enumStr = ServerStatus.FAILUR.getText(); return enumStr; } @@ -553,8 +554,7 @@ public class InferenceResultDto { String enumId = "SAFETY"; if (this.cpu_user + this.cpu_system >= 80) { enumId = "CAUTION"; - } - else if (this.cpu_user + this.cpu_system + this.memused == 0) { + } else if (this.cpu_user + this.cpu_system + this.memused == 0) { enumId = "FAILUR"; } return enumId; @@ -564,8 +564,7 @@ public class InferenceResultDto { String enumId = "SAFETY"; if (this.gpuUtil >= 80) { enumId = "CAUTION"; - } - else if (this.cpu_user + this.cpu_system == 0) { + } else if (this.cpu_user + this.cpu_system == 0) { enumId = "FAILUR"; } return enumId; @@ -575,8 +574,7 @@ public class InferenceResultDto { String enumId = "SAFETY"; if (this.memused >= 80) { enumId = "CAUTION"; - } - else if (this.cpu_user + this.cpu_system + this.memused == 0) { + } else if (this.cpu_user + this.cpu_system + this.memused == 0) { enumId = "FAILUR"; } return enumId; @@ -585,8 +583,7 @@ public class InferenceResultDto { public String getCpuStatusName() { if (this.cpu_user + this.cpu_system >= 80) { return ServerStatus.CAUTION.getText(); - } - else if (this.cpu_user + this.cpu_system + this.memused == 0) { + } else if (this.cpu_user + this.cpu_system + this.memused == 0) { return ServerStatus.FAILUR.getText(); } return ServerStatus.SAFETY.getText(); @@ -595,8 +592,7 @@ public class InferenceResultDto { public String getGpuStatusName() { if (this.gpuUtil >= 80) { return ServerStatus.CAUTION.getText(); - } - else if (this.cpu_user + this.cpu_system + this.memused == 0) { + } else if (this.cpu_user + this.cpu_system + this.memused == 0) { return ServerStatus.FAILUR.getText(); } return ServerStatus.SAFETY.getText(); @@ -605,8 +601,7 @@ public class InferenceResultDto { public String getMemStatusName() { if (this.memused >= 80) { return ServerStatus.CAUTION.getText(); - } - else if (this.cpu_user + this.cpu_system + this.memused == 0) { + } else if (this.cpu_user + this.cpu_system + this.memused == 0) { return ServerStatus.FAILUR.getText(); } return ServerStatus.SAFETY.getText(); diff --git a/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java b/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java index 04c63e15..49709195 100644 --- a/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java +++ b/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java @@ -1,8 +1,5 @@ package com.kamco.cd.kamcoback.inference.service; -import static com.kamco.cd.kamcoback.postgres.entity.QGpuMetricEntity.gpuMetricEntity; -import static com.kamco.cd.kamcoback.postgres.entity.QSystemMetricEntity.systemMetricEntity; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -519,17 +516,16 @@ public class InferenceResultService { public List getInferenceServerStatusList() { - List dtoList = inferenceResultCoreService.getInferenceServerStatusList(); + List dtoList = + inferenceResultCoreService.getInferenceServerStatusList(); int size = dtoList.size(); - System.out.println("size ="+size); + System.out.println("size =" + size); - if( size == 0 ) - { - for(int k=1; k<=4; k++) - { + if (size == 0) { + for (int k = 1; k <= 4; k++) { InferenceServerStatusDto dto = new InferenceServerStatusDto(); - dto.setServerName("server0"+k); + dto.setServerName("server0" + k); dto.setCpu_user(0); dto.setCpu_system(0); dto.setMemused(0); @@ -538,22 +534,18 @@ public class InferenceResultService { dtoList.add(dto); } - } - else - { - for(int k=1; k<=4; k++) - { - String srvNm = "server"+k; + } else { + for (int k = 1; k <= 4; k++) { + String srvNm = "server" + k; String srvNmChk = "N"; for (InferenceServerStatusDto dto : dtoList) { - if( srvNm.equals(dto.getServerName()) ){ + if (srvNm.equals(dto.getServerName())) { srvNmChk = "Y"; break; } } - if( srvNmChk.equals("N") ) - { + if (srvNmChk.equals("N")) { InferenceServerStatusDto dto = new InferenceServerStatusDto(); dto.setServerName(srvNm); dto.setCpu_user(0); @@ -563,9 +555,7 @@ public class InferenceResultService { dto.setGpuUtil(0); dtoList.add(dto); } - } - } dtoList.sort(Comparator.comparing(InferenceServerStatusDto::getServerName)); diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java index 82550b3b..813081e5 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java @@ -121,8 +121,8 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto queryFactory .select(systemMetricEntity.timestamp.max()) .from(systemMetricEntity) - .where(systemMetricEntity.timestamp.goe(OffsetDateTime.now().minusMinutes(5))) - //.where(systemMetricEntity.timestamp.goe(OffsetDateTime.now().minusSeconds(30))) + .where(systemMetricEntity.timestamp.goe(OffsetDateTime.now().minusMinutes(5))) + // .where(systemMetricEntity.timestamp.goe(OffsetDateTime.now().minusSeconds(30))) .groupBy(systemMetricEntity.serverName) .fetch(); @@ -131,7 +131,7 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto .select(gpuMetricEntity.timestamp.max()) .from(gpuMetricEntity) .where(gpuMetricEntity.timestamp.goe(OffsetDateTime.now().minusMinutes(5))) - //.where(gpuMetricEntity.timestamp.goe(OffsetDateTime.now().minusSeconds(30))) + // .where(gpuMetricEntity.timestamp.goe(OffsetDateTime.now().minusSeconds(30))) .groupBy(gpuMetricEntity.serverName) .fetch();