Merge pull request 'spotless' (#202) from feat/infer_dev_260107 into develop

Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/202
This commit is contained in:
2026-01-12 19:40:45 +09:00
7 changed files with 71 additions and 80 deletions

View File

@@ -221,17 +221,17 @@ public class InferenceResultApiController {
@Operation(summary = "추론관리 추론진행 서버 현황", description = "추론관리 추론진행 서버 현황") @Operation(summary = "추론관리 추론진행 서버 현황", description = "추론관리 추론진행 서버 현황")
@ApiResponses( @ApiResponses(
value = { value = {
@ApiResponse( @ApiResponse(
responseCode = "200", responseCode = "200",
description = "검색 성공", description = "검색 성공",
content = content =
@Content( @Content(
mediaType = "application/json", mediaType = "application/json",
schema = @Schema(implementation = Page.class))), schema = @Schema(implementation = Page.class))),
@ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content), @ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
}) })
@GetMapping("/serverStatus") @GetMapping("/serverStatus")
public ApiResponseDto<List<InferenceServerStatusDto>> getInferenceServerStatusList() { public ApiResponseDto<List<InferenceServerStatusDto>> getInferenceServerStatusList() {

View File

@@ -205,81 +205,69 @@ public class InferenceResultDto {
public static class InferenceServerStatusDto { public static class InferenceServerStatusDto {
private String serverName; private String serverName;
@JsonIgnore @JsonIgnore private float cpu_user;
private float cpu_user;
@JsonIgnore private float cpu_system; @JsonIgnore private float cpu_system;
@JsonIgnore private float memused; @JsonIgnore private float memused;
private Long kbmemused; private Long kbmemused;
private float gpuUtil; private float gpuUtil;
//private String cpuStatusName;
//private String memStatusName;
//private String gpuStatusName;
//private float cpu_use_rate;
//private float gpu_use_rate;
//private float mem_use_rate;
public float getCpuUseRate() // private String cpuStatusName;
{ // private String memStatusName;
return this.cpu_user+this.cpu_system; // private String gpuStatusName;
// private float cpu_use_rate;
// private float gpu_use_rate;
// private float mem_use_rate;
public float getCpuUseRate() {
return this.cpu_user + this.cpu_system;
} }
public String getServerStatus() public String getServerStatus() {
{
String enumId = "SAFETY"; String enumId = "SAFETY";
//if( this.cpu_user+this.cpu_system >= 80 )enumId = "CAUTION"; // if( this.cpu_user+this.cpu_system >= 80 )enumId = "CAUTION";
return enumId; return enumId;
} }
public String getServerStatusName() public String getServerStatusName() {
{ // String enumId = "SAFETY";
//String enumId = "SAFETY"; // if( this.cpu_user+this.cpu_system >= 80 )enumId = "CAUTION";
//if( this.cpu_user+this.cpu_system >= 80 )enumId = "CAUTION";
return ServerStatus.SAFETY.getText(); return ServerStatus.SAFETY.getText();
} }
public String getCpuStatus() public String getCpuStatus() {
{
String enumId = "SAFETY"; String enumId = "SAFETY";
if( this.cpu_user+this.cpu_system >= 80 )enumId = "CAUTION"; if (this.cpu_user + this.cpu_system >= 80) enumId = "CAUTION";
return enumId; return enumId;
} }
public String getGpuStatus() public String getGpuStatus() {
{
String enumId = "SAFETY"; String enumId = "SAFETY";
if( this.gpuUtil >= 80 )enumId = "CAUTION"; if (this.gpuUtil >= 80) enumId = "CAUTION";
return enumId; return enumId;
} }
public String getMemStatus() public String getMemStatus() {
{
String enumId = "SAFETY"; String enumId = "SAFETY";
if( this.memused >= 80 )enumId = "CAUTION"; if (this.memused >= 80) enumId = "CAUTION";
return enumId; return enumId;
} }
public String getCpuStatusName() public String getCpuStatusName() {
{ if (this.cpu_user + this.cpu_system >= 80) return ServerStatus.CAUTION.getText();
if( this.cpu_user+this.cpu_system >= 80 )return ServerStatus.CAUTION.getText();
return ServerStatus.SAFETY.getText(); return ServerStatus.SAFETY.getText();
} }
public String getGpuStatusName() public String getGpuStatusName() {
{ if (this.gpuUtil >= 80) return ServerStatus.CAUTION.getText();
if( this.gpuUtil >= 80 )return ServerStatus.CAUTION.getText();
return ServerStatus.SAFETY.getText(); return ServerStatus.SAFETY.getText();
} }
public String getMemStatusName() public String getMemStatusName() {
{ if (this.memused >= 80) return ServerStatus.CAUTION.getText();
if( this.memused >= 80 )return ServerStatus.CAUTION.getText();
return ServerStatus.SAFETY.getText(); return ServerStatus.SAFETY.getText();
} }
} }
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum ServerStatus implements EnumType { public enum ServerStatus implements EnumType {

View File

@@ -228,6 +228,7 @@ public class InferenceResultCoreService {
entity.setStatus(status); entity.setStatus(status);
} }
public List<InferenceServerStatusDto> getInferenceServerStatusList(){return mapSheetLearnRepository.getInferenceServerStatusList(); public List<InferenceServerStatusDto> getInferenceServerStatusList() {
return mapSheetLearnRepository.getInferenceServerStatusList();
} }
} }

View File

@@ -44,5 +44,4 @@ public class GpuMetricEntity {
@Column(name = "gpu_mem_total") @Column(name = "gpu_mem_total")
private Float gpuMemTotal; private Float gpuMemTotal;
} }

View File

@@ -55,5 +55,4 @@ public class SystemMetricEntity {
@Column(name = "memused") @Column(name = "memused")
private Float memused; private Float memused;
} }

View File

@@ -3,9 +3,9 @@ package com.kamco.cd.kamcoback.postgres.repository.Inference;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto; import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceServerStatusDto; import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceServerStatusDto;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearnEntity; import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearnEntity;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import java.util.List;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
public interface MapSheetLearnRepositoryCustom { public interface MapSheetLearnRepositoryCustom {

View File

@@ -94,34 +94,38 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto
BooleanBuilder builder = new BooleanBuilder(); BooleanBuilder builder = new BooleanBuilder();
List<Integer> latestIds = queryFactory List<Integer> latestIds =
.select(systemMetricEntity.id1.max()) queryFactory
.from(systemMetricEntity) .select(systemMetricEntity.id1.max())
.groupBy(systemMetricEntity.serverName) .from(systemMetricEntity)
.fetch(); .groupBy(systemMetricEntity.serverName)
.fetch();
List<Integer> latestGpuIds = queryFactory List<Integer> latestGpuIds =
.select(gpuMetricEntity.id1.max()) queryFactory
.from(gpuMetricEntity) .select(gpuMetricEntity.id1.max())
.groupBy(gpuMetricEntity.serverName) .from(gpuMetricEntity)
.fetch(); .groupBy(gpuMetricEntity.serverName)
.fetch();
List<InferenceServerStatusDto> foundContent = queryFactory List<InferenceServerStatusDto> foundContent =
.select(Projections.constructor( queryFactory
InferenceServerStatusDto.class, .select(
systemMetricEntity.serverName, Projections.constructor(
systemMetricEntity.cpuUser, InferenceServerStatusDto.class,
systemMetricEntity.cpuSystem, systemMetricEntity.serverName,
systemMetricEntity.memused, systemMetricEntity.cpuUser,
systemMetricEntity.kbmemused, systemMetricEntity.cpuSystem,
gpuMetricEntity.gpuUtil systemMetricEntity.memused,
)) systemMetricEntity.kbmemused,
.from(systemMetricEntity) gpuMetricEntity.gpuUtil))
.leftJoin(gpuMetricEntity).on(gpuMetricEntity.serverName.eq(systemMetricEntity.serverName)) .from(systemMetricEntity)
.where(systemMetricEntity.id1.in(latestIds)) // In 절 사용 .leftJoin(gpuMetricEntity)
.orderBy(systemMetricEntity.serverName.asc()) .on(gpuMetricEntity.serverName.eq(systemMetricEntity.serverName))
.limit(4) .where(systemMetricEntity.id1.in(latestIds)) // In 절 사용
.fetch(); .orderBy(systemMetricEntity.serverName.asc())
.limit(4)
.fetch();
return foundContent; return foundContent;
} }