ResourceMonitoringController.java 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package com.its.op.controller;
  2. import com.its.op.dto.ThreadMonitoringDto;
  3. import com.its.op.dto.WebsocketMonitoringDto;
  4. import com.its.op.service.ResourceMonitoringService;
  5. import io.swagger.annotations.Api;
  6. import io.swagger.annotations.ApiOperation;
  7. import io.swagger.annotations.ApiParam;
  8. import lombok.RequiredArgsConstructor;
  9. import lombok.extern.slf4j.Slf4j;
  10. import org.springframework.http.MediaType;
  11. import org.springframework.http.ResponseEntity;
  12. import org.springframework.validation.annotation.Validated;
  13. import org.springframework.web.bind.annotation.*;
  14. import java.util.List;
  15. @Slf4j
  16. @RequiredArgsConstructor
  17. @Validated
  18. @RestController
  19. @RequestMapping("/api/resource")
  20. @Api(tags = "00.공통-99.리소스 모니터링")
  21. public class ResourceMonitoringController {
  22. private final ResourceMonitoringService resourceMonitoringService;
  23. @ApiOperation(value = "스레드 리소스 현재값 저장", response = ThreadMonitoringDto.class, responseContainer = "ArrayList")
  24. @PutMapping(path="/threads/save/{tag}", produces = MediaType.APPLICATION_JSON_VALUE)
  25. public ResponseEntity<List<ThreadMonitoringDto>> threadMonitoringSave(@PathVariable final String tag) {
  26. List<ThreadMonitoringDto> result = this.resourceMonitoringService.threadMonitoringSave(tag);
  27. return ResponseEntity.ok(result);
  28. }
  29. @ApiOperation(value = "스레드 리소스 삭제", response = ThreadMonitoringDto.class, responseContainer = "ArrayList")
  30. @DeleteMapping(path="/threads/delete/{tag}", produces = MediaType.APPLICATION_JSON_VALUE)
  31. public ResponseEntity<List<ThreadMonitoringDto>> threadMonitoringDelete(@PathVariable final String tag) {
  32. List<ThreadMonitoringDto> result = this.resourceMonitoringService.threadMonitoringDelete(tag);
  33. return ResponseEntity.ok(result);
  34. //return ResponseEntity.ok().build();
  35. }
  36. @ApiOperation(value = "스레드 리소스 저장값 조회", response = ThreadMonitoringDto.class, responseContainer = "ArrayList")
  37. @GetMapping(path="/threads/query/{tag}", produces = MediaType.APPLICATION_JSON_VALUE)
  38. public ResponseEntity<List<ThreadMonitoringDto>> threadMonitoringQuery(@PathVariable final String tag) {
  39. List<ThreadMonitoringDto> result = this.resourceMonitoringService.threadMonitoringQuery(tag);
  40. return ResponseEntity.ok(result);
  41. }
  42. @ApiOperation(value = "스레드 리소스 저장값과 현재값 비교", response = ThreadMonitoringDto.class, responseContainer = "ArrayList")
  43. @GetMapping(path="/threads/diff/{tag}", produces = MediaType.APPLICATION_JSON_VALUE)
  44. public ResponseEntity<List<ThreadMonitoringDto>> threadMonitoringDiff(@PathVariable final String tag) {
  45. List<ThreadMonitoringDto> result = this.resourceMonitoringService.threadMonitoringDiff(tag);
  46. return ResponseEntity.ok(result);
  47. }
  48. @ApiOperation(value = "스레드 리소스 현재값 조회", response = ThreadMonitoringDto.class, responseContainer = "ArrayList")
  49. @GetMapping(path="/threads", produces = MediaType.APPLICATION_JSON_VALUE)
  50. public ResponseEntity<List<ThreadMonitoringDto>> threadMonitoringCurrent() {
  51. List<ThreadMonitoringDto> result = this.resourceMonitoringService.threadMonitoringCurrent();
  52. return ResponseEntity.ok(result);
  53. }
  54. @ApiOperation(value = "웹소켓 조회", response = WebsocketMonitoringDto.class, responseContainer = "ArrayList")
  55. @GetMapping(path="/websocket/list", produces = MediaType.APPLICATION_JSON_VALUE)
  56. public ResponseEntity<List<WebsocketMonitoringDto>> getWebsocketList() {
  57. List<WebsocketMonitoringDto> result = this.resourceMonitoringService.getWebsocketList();
  58. return ResponseEntity.ok(result);
  59. }
  60. @ApiOperation(value = "웹소켓 디버그 조회", response = String.class, responseContainer = "ArrayList")
  61. @GetMapping(path="/websocket/debug/{flag}", produces = MediaType.APPLICATION_JSON_VALUE)
  62. public ResponseEntity<String> getWebsocketDebug(
  63. @ApiParam(name = "flag", value = "디버그 설정(0 or 1", example = "0", required = true)
  64. @PathVariable("flag") String flag
  65. ) {
  66. String result = this.resourceMonitoringService.getWebsocketDebug(flag);
  67. return ResponseEntity.ok(result);
  68. }
  69. }