UMS관련 정리
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
package com.eactive.eai.rms.ext.djb.apistatus;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional
|
||||||
|
public class ApiStatusDetectionService {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ApiStatusDetectionService.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 이벤트 감지
|
||||||
|
* @param event "CONTROL_START" : 점검시작
|
||||||
|
"CONTROL_END" : 점검종료
|
||||||
|
"ERROR_START" : 장애시작
|
||||||
|
"ERROR_END" : 장애종료
|
||||||
|
"DELAY_START" : 지연시작
|
||||||
|
"DELAY_END" : 지연종료
|
||||||
|
* @param apiIds API IDs
|
||||||
|
*/
|
||||||
|
public void detect(String event, List<String> apiIds) {
|
||||||
|
log.debug("이벤트 감지: {} {}", event, apiIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
// API FSM 내 아직 장애로 남아있는 API 목록
|
||||||
|
public void remainDownApiIds() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 정상 동작 - detect()에서 일괄 처리 (복구 = 점검종료, 장애종료, 지연종료)
|
||||||
|
// public void recovered(String event, String[] apiIds) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -39,9 +39,10 @@ public interface ApiStatusRepository extends BaseRepository<ApiStatus, String> {
|
|||||||
+ " FROM ("
|
+ " FROM ("
|
||||||
+ " SELECT A.EAISVCNAME"
|
+ " SELECT A.EAISVCNAME"
|
||||||
+ " , NVL(B.STATUS_CODE, 'N') AS STATUS_CODE"
|
+ " , NVL(B.STATUS_CODE, 'N') AS STATUS_CODE"
|
||||||
+ " , NVL(( SELECT 'Y' FROM EMSAPP.PTL_NOTICE_API X "
|
//TODO: 게시판 임시로 생성하여 사용. 유차장이 완료하면 변경할것
|
||||||
+ " WHERE EXISTS (SELECT 1 FROM EMSAPP.PTL_NOTICE Y WHERE X.NOTICE_ID = Y.ID "
|
+ " , NVL(( SELECT 'Y' FROM PTL_NOTICE_API X "
|
||||||
+ " AND TO_CHAR(SYSDATE, 'YYYYMMDDHH24MI') BETWEEN START_TIME AND END_TIME) "
|
+ " WHERE EXISTS (SELECT 1 FROM EMSAPP.PTL_NOTICE Y WHERE X.NOTICE_ID = Y.ID)"
|
||||||
|
//+ " AND TO_CHAR(SYSDATE, 'YYYYMMDDHH24MI') BETWEEN START_TIME AND END_TIME) "
|
||||||
+ " AND A.EAISVCNAME = X.API_NAME),'N') AS CTRL_YN "
|
+ " AND A.EAISVCNAME = X.API_NAME),'N') AS CTRL_YN "
|
||||||
+ " , (SELECT CASE WHEN TOTAL = 0 THEN 'X'"
|
+ " , (SELECT CASE WHEN TOTAL = 0 THEN 'X'"
|
||||||
+ " WHEN (TOTAL - SUCCESS) * 100 / TOTAL > :errorRate THEN 'Y'"
|
+ " WHEN (TOTAL - SUCCESS) * 100 / TOTAL > :errorRate THEN 'Y'"
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import com.eactive.eai.rms.data.entity.man.role.Role;
|
|||||||
import com.eactive.eai.rms.data.entity.onl.djb.apistatus.ApiStatus;
|
import com.eactive.eai.rms.data.entity.onl.djb.apistatus.ApiStatus;
|
||||||
import com.eactive.eai.rms.data.entity.onl.djb.apistatus.ApiStatusEvent;
|
import com.eactive.eai.rms.data.entity.onl.djb.apistatus.ApiStatusEvent;
|
||||||
import com.eactive.eai.rms.ext.djb.util.UmsManager;
|
import com.eactive.eai.rms.ext.djb.util.UmsManager;
|
||||||
import com.eactive.ext.djb.apistatus.DjbIncidentDetectionService;
|
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -32,7 +31,7 @@ public class ApiStatusService {
|
|||||||
private UmsManager ums;
|
private UmsManager ums;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DjbIncidentDetectionService djbService;
|
private ApiStatusDetectionService apiStatusDectionService;
|
||||||
|
|
||||||
|
|
||||||
public void updateApiStatus(HashMap<String, String> param) {
|
public void updateApiStatus(HashMap<String, String> param) {
|
||||||
@@ -83,7 +82,7 @@ public class ApiStatusService {
|
|||||||
ums.sendWebhook(event, apiIds);
|
ums.sendWebhook(event, apiIds);
|
||||||
|
|
||||||
//개발자포탈 API상태모니터링 화면을 위한 처리
|
//개발자포탈 API상태모니터링 화면을 위한 처리
|
||||||
djbService.detect(event, apiIds);
|
apiStatusDectionService.detect(event, apiIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.eactive.apim.portal.template.entity.MessageCode;
|
import com.eactive.apim.portal.template.entity.MessageCode;
|
||||||
import com.eactive.apim.portal.template.service.MessageHandlerService;
|
import com.eactive.apim.portal.template.service.MessageHandlerService;
|
||||||
import com.eactive.apim.portal.template.service.MessageRecipient;
|
import com.eactive.apim.portal.template.service.MessageRecipient;
|
||||||
import com.eactive.apim.portal.user.entity.UserInfo;
|
import com.eactive.apim.portal.user.entity.UserInfo;
|
||||||
import com.eactive.eai.rms.data.entity.man.role.Role;
|
|
||||||
import com.eactive.eai.rms.data.entity.man.user.UserInfoService;
|
import com.eactive.eai.rms.data.entity.man.user.UserInfoService;
|
||||||
import com.eactive.eai.rms.ext.djb.webhook.dto.WebhookSendRequest;
|
import com.eactive.eai.rms.ext.djb.webhook.dto.WebhookSendRequest;
|
||||||
import com.eactive.eai.rms.ext.djb.webhook.service.WebhookService;
|
import com.eactive.eai.rms.ext.djb.webhook.service.WebhookService;
|
||||||
@@ -75,10 +75,11 @@ public class UmsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* event를 구독중인 제휴사에게 웹훅 발송
|
* event를 구독중인 제휴사에게 웹훅 발송 (비동기)
|
||||||
* @param event
|
* @param event
|
||||||
* @param apiIds
|
* @param apiIds
|
||||||
*/
|
*/
|
||||||
|
@Async("webhookExecutor")
|
||||||
public void sendWebhook(String event, List<String> apiIds) {
|
public void sendWebhook(String event, List<String> apiIds) {
|
||||||
List<WebhookSendRequest> list = webhookService.findSendList(event, apiIds);
|
List<WebhookSendRequest> list = webhookService.findSendList(event, apiIds);
|
||||||
for (WebhookSendRequest req : list) {
|
for (WebhookSendRequest req : list) {
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.eactive.eai.rms.ext.djb.webhook.config;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableAsync
|
||||||
|
public class WebhookAsyncConfig {
|
||||||
|
|
||||||
|
@Bean(name = "webhookExecutor")
|
||||||
|
public Executor webhookExecutor() {
|
||||||
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||||
|
executor.setCorePoolSize(2);
|
||||||
|
executor.setMaxPoolSize(10);
|
||||||
|
executor.setQueueCapacity(100);
|
||||||
|
executor.setThreadNamePrefix("webhook-");
|
||||||
|
executor.setWaitForTasksToCompleteOnShutdown(true);
|
||||||
|
executor.setAwaitTerminationSeconds(30);
|
||||||
|
executor.initialize();
|
||||||
|
return executor;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user