inflow group 추가

This commit is contained in:
yunjy-hp
2025-12-11 10:04:24 +09:00
parent 5274ce811d
commit 39244dc0df
8 changed files with 508 additions and 31 deletions
@@ -27,6 +27,7 @@ import com.eactive.eai.common.exception.ExceptionUtil;
import com.eactive.eai.common.inflow.Bucket;
import com.eactive.eai.common.inflow.InflowControlDAO;
import com.eactive.eai.common.inflow.InflowControlUtil;
import com.eactive.eai.common.inflow.InflowGroupVO;
import com.eactive.eai.common.inflow.InflowTargetVO;
import com.eactive.eai.common.logger.EAILogSender;
import com.eactive.eai.common.message.EAIMessage;
@@ -1014,24 +1015,39 @@ public class RequestProcessor extends RequestProcessorSupport {
Bucket bucket = InflowControlUtil.getBucket();
String blockedType = "";
// Adapter 유량제어 체크
if (!bucket.isAdapterPass(vo.getAdapterGroupName())) {
blockedType += "A";
}
if (!bucket.isInterfacePass(vo.getEaiSvcCd())) {
blockedType += "I";
// 그룹 우선, 없으면 인터페이스 유량제어 체크
String groupId = bucket.getGroupIdByInterface(vo.getEaiSvcCd());
if (groupId != null) {
// 그룹에 속한 인터페이스 → 그룹 유량제어 체크
if (!bucket.isGroupPass(groupId)) {
blockedType += "G";
}
} else {
// 그룹에 속하지 않은 인터페이스 → 인터페이스 유량제어 체크
if (!bucket.isInterfacePass(vo.getEaiSvcCd())) {
blockedType += "I";
}
}
if (blockedType.length() > 0) {
InflowTargetVO inflowTargetVO = null;
InflowGroupVO inflowGroupVO = null;
if (blockedType.startsWith("A")) {
inflowTargetVO = bucket.getAdapterInflowThreashold(vo.getAdapterGroupName());
} else if (blockedType.contains("G")) {
inflowGroupVO = bucket.getGroupInflowThreshold(groupId);
} else {
inflowTargetVO = bucket.getInterfaceInflowThreashold(vo.getEaiSvcCd());
}
// 에러처리
vo.setRspErrorCode(EAIMessageKeys.EAI_INFLOW_BLOCKED_CODE);
vo.setRspErrorMsg(ExceptionUtil.make(vo.getRspErrorCode(), vo.getEaiSvcCd() ) + ", "
+ inflowTargetVO.toString());
String inflowInfo = (inflowGroupVO != null) ? inflowGroupVO.toString() :
(inflowTargetVO != null ? inflowTargetVO.toString() : "N/A");
vo.setRspErrorMsg(ExceptionUtil.make(vo.getRspErrorCode(), vo.getEaiSvcCd() ) + ", " + inflowInfo);
// eaiMsg.setRspErrCd(vo.getRspErrorCode());
// eaiMsg.setRspErrMsg(vo.getRspErrorMsg());
@@ -1040,16 +1056,21 @@ public class RequestProcessor extends RequestProcessorSupport {
try {
Properties inFlowProp = PropManager.getInstance().getProperties("INFLOW");
String controlInflowHistory = inFlowProp.getProperty("inflow.control.history.yn", "N");
if (StringUtils.equalsIgnoreCase(controlInflowHistory, "Y") && inflowTargetVO != null) {
if (StringUtils.equalsIgnoreCase(controlInflowHistory, "Y") && (inflowTargetVO != null || inflowGroupVO != null)) {
DAOFactory factory = DAOFactory.newInstance();
// InflowControlDAO restrictDao = (InflowControlDAO) factory.create(InflowControlDAO.class);
// InflowControlDAO를 서비스로 만들어서 factory.create로 하면 안됨.
InflowControlDAO restrictDao = (InflowControlDAO) ApplicationContextProvider.getContext().getBean(InflowControlDAO.class);
// 그룹 유량제어 정보가 있으면 그룹 정보로, 없으면 기존 inflowTargetVO 정보로 로그
long thresholdPerSecond = (inflowGroupVO != null) ? inflowGroupVO.getThresholdPerSecond() : inflowTargetVO.getThresholdPerSecond();
long threshold = (inflowGroupVO != null) ? inflowGroupVO.getThreshold() : inflowTargetVO.getThreshold();
String thresholdTimeUnit = (inflowGroupVO != null) ? inflowGroupVO.getThresholdTimeUnit() : inflowTargetVO.getThresholdTimeUnit();
String logGroupName = (inflowGroupVO != null) ? inflowGroupVO.getGroupId() : vo.getAdapterGroupName();
restrictDao.addInflowServicetLog(eaiMsg.getBwkCls(),
DatetimeUtil.getCurrentTime(eaiMsg.getMsgRcvTm()), eaiMsg.getSvcOgNo(),
eaiServerManager.getLocalServerName(), eaiMsg.getEAISvcCd(), vo.getAdapterGroupName(),
inflowTargetVO.getThresholdPerSecond(), inflowTargetVO.getThreshold(),
inflowTargetVO.getThresholdTimeUnit());
eaiServerManager.getLocalServerName(), eaiMsg.getEAISvcCd(), logGroupName,
thresholdPerSecond, threshold, thresholdTimeUnit);
}
} catch (Exception ex) {
if (logger.isError()) {
@@ -1060,7 +1081,10 @@ public class RequestProcessor extends RequestProcessorSupport {
sb.append("EAISevrInstncName [" + eaiServerManager.getLocalServerName() + "]\n");
sb.append("EAISvcName [" + eaiMsg.getEAISvcCd() + "]\n");
sb.append("ADPTRBZWKGROUPNAME[" + vo.getAdapterGroupName() + "]\n");
sb.append("InflowTargetVO [" + inflowTargetVO.toString() + "]\n");
sb.append("InflowInfo [" + inflowInfo + "]\n");
if (groupId != null) {
sb.append("InflowGroupId [" + groupId + "]\n");
}
logger.error(guidLogPrefix + " 유량제어 건수 Log 실패 - " + ex.toString() + "\n" + sb.toString());
}