Files
eapim-online/src/main/java/com/eactive/eai/manage/inflow/InflowTargetBucketController.java
T
curry772 d46fa8bd1a refactor: 클라이언트 버킷 상태 모니터링 custom.inflow 패키지로 분리
- InflowTargetBucketService/Controller에서 클라이언트 관련 메서드/엔드포인트 제거
- ClientInflowTargetBucketService/Controller를 custom.inflow 패키지에 신규 생성
  (ClientInflowTargetMetricService/Controller 패턴과 일치)
- 관련 단위 테스트 추가 및 기존 테스트에서 클라이언트 케이스 제거

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-08 10:22:15 +09:00

89 lines
3.6 KiB
Java

package com.eactive.eai.manage.inflow;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 어댑터/인터페이스/클라이언트 버킷 상태 모니터링 API.
*
* DualInflowControlManager 가 활성화된 환경에서만 정상 응답한다.
* 비활성화 환경에서는 success=false 또는 빈 목록을 반환한다.
*
* GET /manage/inflow/adapter/bucket-status → 전체 어댑터 버킷 상태
* GET /manage/inflow/adapter/{adapterId}/bucket-status → 특정 어댑터 버킷 상태
* GET /manage/inflow/interface/bucket-status → 전체 인터페이스 버킷 상태
* GET /manage/inflow/interface/{interfaceId}/bucket-status → 특정 인터페이스 버킷 상태
*/
@RestController
@RequestMapping("/manage/inflow")
public class InflowTargetBucketController {
@Autowired
private InflowTargetBucketService bucketService;
// =========================================================================
// 어댑터
// =========================================================================
@GetMapping("/adapter/bucket-status")
public ResponseEntity<?> getAllAdapterBucketStatus() {
List<TargetBucketStatusDTO> list = bucketService.getAllAdapterBucketStatus();
return ok(list);
}
@GetMapping("/adapter/{adapterId}/bucket-status")
public ResponseEntity<?> getAdapterBucketStatus(@PathVariable String adapterId) {
TargetBucketStatusDTO dto = bucketService.getAdapterBucketStatus(adapterId);
return single(dto, "어댑터를 찾을 수 없습니다: " + adapterId);
}
// =========================================================================
// 인터페이스
// =========================================================================
@GetMapping("/interface/bucket-status")
public ResponseEntity<?> getAllInterfaceBucketStatus() {
List<TargetBucketStatusDTO> list = bucketService.getAllInterfaceBucketStatus();
return ok(list);
}
@GetMapping("/interface/{interfaceId}/bucket-status")
public ResponseEntity<?> getInterfaceBucketStatus(@PathVariable String interfaceId) {
TargetBucketStatusDTO dto = bucketService.getInterfaceBucketStatus(interfaceId);
return single(dto, "인터페이스를 찾을 수 없습니다: " + interfaceId);
}
// =========================================================================
// Helpers
// =========================================================================
private ResponseEntity<?> ok(List<TargetBucketStatusDTO> list) {
Map<String, Object> result = new HashMap<>();
result.put("success", true);
result.put("data", list);
result.put("count", list.size());
return ResponseEntity.ok(result);
}
private ResponseEntity<?> single(TargetBucketStatusDTO dto, String notFoundMsg) {
if (dto == null) {
Map<String, Object> error = new HashMap<>();
error.put("success", false);
error.put("message", notFoundMsg);
return ResponseEntity.ok(error);
}
Map<String, Object> result = new HashMap<>();
result.put("success", true);
result.put("data", dto);
return ResponseEntity.ok(result);
}
}