diff --git a/src/main/java/com/eactive/eai/agent/inflow/ReloadInflowGroupControlCommand.java b/src/main/java/com/eactive/eai/agent/inflow/ReloadInflowGroupControlCommand.java new file mode 100644 index 0000000..0582f01 --- /dev/null +++ b/src/main/java/com/eactive/eai/agent/inflow/ReloadInflowGroupControlCommand.java @@ -0,0 +1,56 @@ +package com.eactive.eai.agent.inflow; + +import com.eactive.eai.agent.command.Command; +import com.eactive.eai.agent.command.CommandException; +import com.eactive.eai.common.inflow.InflowControlManager; +import com.eactive.eai.common.util.Logger; + +public class ReloadInflowGroupControlCommand extends Command { + + private static final long serialVersionUID = 1L; + + public ReloadInflowGroupControlCommand() { + super("ReloadInflowGroupControlCommand"); + } + + public Object execute() throws CommandException { + Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT); + if (logger.isInfo()) + logger.info(this.name + " is executed"); + + if (!(args instanceof String)) { + String rspErrorCode = "RECEAIMCM001"; + String msg = makeException(rspErrorCode, null); + if (logger.isError()) + logger.error(msg); + throw new CommandException(msg); + } + + String keyName = (String) args; + try { + InflowControlManager manager = InflowControlManager.getInstance(); + + if (keyName != null) { + if ("ALL".equals(keyName)) { + manager.reloadGroup(); + if (logger.isWarn()) + logger.warn(this.name + "] all group rule Reload."); + } else { + manager.reloadGroup(keyName); + if (logger.isWarn()) + logger.warn(this.name + "] group " + keyName + " Reload."); + } + } + + } catch (Exception e) { + String rspErrorCode = "RECEAIMCM002"; + String msg = makeException(rspErrorCode, e); + if (logger.isError()) + logger.error(msg, e); + throw new CommandException(msg); + } + return "success"; + + } + +} diff --git a/src/main/java/com/eactive/eai/agent/inflow/RemoveInflowGroupControlCommand.java b/src/main/java/com/eactive/eai/agent/inflow/RemoveInflowGroupControlCommand.java new file mode 100644 index 0000000..a4bdf03 --- /dev/null +++ b/src/main/java/com/eactive/eai/agent/inflow/RemoveInflowGroupControlCommand.java @@ -0,0 +1,45 @@ +package com.eactive.eai.agent.inflow; + +import com.eactive.eai.agent.command.Command; +import com.eactive.eai.agent.command.CommandException; +import com.eactive.eai.common.inflow.InflowControlManager; +import com.eactive.eai.common.util.Logger; + +public class RemoveInflowGroupControlCommand extends Command { + + private static final long serialVersionUID = 1L; + + public RemoveInflowGroupControlCommand() { + super("RemoveInflowGroupControlCommand"); + } + + public Object execute() throws CommandException { + Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT); + if (logger.isInfo()) + logger.info(this.name + " is executed"); + + if (!(args instanceof String)) { + String rspErrorCode = "RECEAIMCM001"; + String msg = makeException(rspErrorCode, null); + if (logger.isError()) + logger.error(msg); + throw new CommandException(msg); + } + + String key = (String) args; + try { + InflowControlManager manager = InflowControlManager.getInstance(); + manager.removeGroup(key); + if (logger.isWarn()) + logger.warn(this.name + "] group " + key + " removed."); + } catch (Exception e) { + String rspErrorCode = "RECEAIMCM002"; + String msg = makeException(rspErrorCode, e); + if (logger.isError()) + logger.error(msg, e); + throw new CommandException(msg); + } + return "success"; + } + +} diff --git a/src/main/java/com/eactive/eai/common/inflow/Bucket.java b/src/main/java/com/eactive/eai/common/inflow/Bucket.java index 51db277..3896171 100644 --- a/src/main/java/com/eactive/eai/common/inflow/Bucket.java +++ b/src/main/java/com/eactive/eai/common/inflow/Bucket.java @@ -6,4 +6,9 @@ public interface Bucket { public InflowTargetVO getAdapterInflowThreashold(String adapter); public InflowTargetVO getInterfaceInflowThreashold(String inter); public InflowTargetVO getInflowThreashold(String inter); + + // 그룹 관련 메서드 + public boolean isGroupPass(String groupId); + public InflowGroupVO getGroupInflowThreshold(String groupId); + public String getGroupIdByInterface(String interfaceId); } diff --git a/src/main/java/com/eactive/eai/common/inflow/InflowControlDAO.java b/src/main/java/com/eactive/eai/common/inflow/InflowControlDAO.java index b294bc7..8ff7b3a 100644 --- a/src/main/java/com/eactive/eai/common/inflow/InflowControlDAO.java +++ b/src/main/java/com/eactive/eai/common/inflow/InflowControlDAO.java @@ -12,10 +12,14 @@ import org.springframework.transaction.annotation.Transactional; import com.eactive.eai.common.dao.BaseDAO; import com.eactive.eai.common.dao.DAOException; import com.eactive.eai.common.exception.ExceptionUtil; +import com.eactive.eai.common.inflow.loader.InflowControlGroupLoader; +import com.eactive.eai.common.inflow.loader.InflowControlGroupMappingLoader; import com.eactive.eai.common.inflow.loader.InflowControlLoader; import com.eactive.eai.common.inflow.loader.InflowControlLogLogger; import com.eactive.eai.common.util.Logger; import com.eactive.eai.data.entity.onl.inflow.InflowControl; +import com.eactive.eai.data.entity.onl.inflow.InflowControlGroup; +import com.eactive.eai.data.entity.onl.inflow.InflowControlGroupMapping; import com.eactive.eai.data.entity.onl.inflow.InflowControlLog; import com.eactive.eai.data.entity.onl.inflow.InflowControlLogId; @@ -30,6 +34,12 @@ public class InflowControlDAO extends BaseDAO { @Autowired private InflowControlLogLogger inflowControlLogLogger; + @Autowired + private InflowControlGroupLoader inflowControlGroupLoader; + + @Autowired + private InflowControlGroupMappingLoader inflowControlGroupMappingLoader; + public List getInflowAdapterList() throws DAOException { return getInflowList("01"); } @@ -132,4 +142,89 @@ public class InflowControlDAO extends BaseDAO { throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICMM101")); } } + + // ==================== 그룹 관련 메서드 ==================== + + /** + * 활성화된 유량제어 그룹 목록 조회 + */ + public List getInflowGroupList() throws DAOException { + try { + Iterable groups = inflowControlGroupLoader.findActiveGroups(); + List groupList = new ArrayList<>(); + logger.info("[ @@ Load InflowControlGroup Configuration - starting >>>>>>>>>>>>>>>>> ]"); + + for (InflowControlGroup group : groups) { + InflowGroupVO vo = convertToGroupVO(group); + // 그룹에 속한 인터페이스 목록 조회 + Iterable mappings = inflowControlGroupMappingLoader.findActiveByGroupId(group.getGroupId()); + for (InflowControlGroupMapping mapping : mappings) { + vo.addInterface(mapping.getInterfaceId()); + } + groupList.add(vo); + } + logger.info("[>>Load InflowControlGroup Configuration - ended. count=" + groupList.size() + " ]"); + return groupList; + } catch (Exception e) { + throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICMM101")); + } + } + + /** + * 인터페이스ID → 그룹ID 매핑 조회 + */ + public Map getInterfaceToGroupMap() throws DAOException { + try { + Iterable mappings = inflowControlGroupMappingLoader.findActiveMappings(); + Map interfaceToGroupMap = new HashMap<>(); + logger.info("[ @@ Load InterfaceToGroupMap Configuration - starting >>>>>>>>>>>>>>>>> ]"); + + for (InflowControlGroupMapping mapping : mappings) { + interfaceToGroupMap.put(mapping.getInterfaceId(), mapping.getGroupId()); + } + logger.info("[>>Load InterfaceToGroupMap Configuration - ended. count=" + interfaceToGroupMap.size() + " ]"); + return interfaceToGroupMap; + } catch (Exception e) { + throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICMM101")); + } + } + + /** + * 특정 그룹 조회 + */ + public Map getInflowTargetByGroup(String groupId) throws DAOException { + try { + Iterable groups = inflowControlGroupLoader.findByConditions(groupId); + Map groupMap = new HashMap<>(); + logger.info("[ @@ Load InflowControlGroup getInflowTargetByGroup Configuration - starting >>>>>>>>>>>>>>>>> ]"); + + for (InflowControlGroup group : groups) { + InflowGroupVO vo = convertToGroupVO(group); + // 그룹에 속한 인터페이스 목록 조회 + Iterable mappings = inflowControlGroupMappingLoader.findActiveByGroupId(group.getGroupId()); + for (InflowControlGroupMapping mapping : mappings) { + vo.addInterface(mapping.getInterfaceId()); + } + groupMap.put(vo.getGroupId(), vo); + } + logger.info("[>>Load InflowControlGroup getInflowTargetByGroup Configuration - ended ]"); + return groupMap; + } catch (Exception e) { + throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICMM101")); + } + } + + /** + * Entity → VO 변환 + */ + private InflowGroupVO convertToGroupVO(InflowControlGroup group) { + InflowGroupVO vo = new InflowGroupVO(); + vo.setGroupId(group.getGroupId()); + vo.setGroupName(group.getGroupName()); + vo.setThreshold(group.getThreshold() != null ? group.getThreshold() : 0); + vo.setThresholdPerSecond(group.getThresholdPerSecond() != null ? group.getThresholdPerSecond() : 0); + vo.setThresholdTimeUnit(group.getThresholdTimeUnit()); + vo.setActivate(!"0".equals(group.getUseYn())); + return vo; + } } \ No newline at end of file diff --git a/src/main/java/com/eactive/eai/common/inflow/InflowControlManager.java b/src/main/java/com/eactive/eai/common/inflow/InflowControlManager.java index 1f33788..5b2d6d3 100644 --- a/src/main/java/com/eactive/eai/common/inflow/InflowControlManager.java +++ b/src/main/java/com/eactive/eai/common/inflow/InflowControlManager.java @@ -40,6 +40,9 @@ public class InflowControlManager implements Lifecycle, Bucket { private Map adapterBucketList = new HashMap<>(); private Map interfaceBucketList = new HashMap<>(); + private Map groupBucketList = new HashMap<>(); + private Map interfaceToGroupMap = new HashMap<>(); + private Map groupVoMap = new HashMap<>(); private boolean started; private LifecycleSupport lifecycle = new LifecycleSupport(this); @@ -91,6 +94,7 @@ public class InflowControlManager implements Lifecycle, Bucket { private void init() throws Exception { initAdapter(); initInterface(); + initGroup(); } private void initAdapter() throws Exception { @@ -121,6 +125,33 @@ public class InflowControlManager implements Lifecycle, Bucket { } } + private void initGroup() throws Exception { + groupBucketList = new HashMap<>(); + interfaceToGroupMap = new HashMap<>(); + groupVoMap = new HashMap<>(); + + List inflowGroupVoList = inflowControlDAO.getInflowGroupList(); + + for (InflowGroupVO groupVo : inflowGroupVoList) { + if (isInflowGroupTarget(groupVo)) { + CustomBucket bucket = makeBucketUsingGroupVO(groupVo); + if (bucket != null) { + groupBucketList.put(groupVo.getGroupId(), bucket); + groupVoMap.put(groupVo.getGroupId(), groupVo); + // 인터페이스 → 그룹 매핑 등록 + for (String interfaceId : groupVo.getInterfaceList()) { + interfaceToGroupMap.put(interfaceId, groupVo.getGroupId()); + } + } + } + } + + if (logger.isInfo()) { + logger.info("InflowControlManager] initGroup completed. groups=" + groupBucketList.size() + + ", mappings=" + interfaceToGroupMap.size()); + } + } + public synchronized void reloadAdapter() throws Exception { if (logger.isWarn()) { logger.warn("InflowControlManager] reload all Started ..."); @@ -200,6 +231,61 @@ public class InflowControlManager implements Lifecycle, Bucket { } } + public synchronized void reloadGroup() throws Exception { + if (logger.isWarn()) { + logger.warn("InflowControlManager] reloadGroup all Started ..."); + } + initGroup(); + if (logger.isWarn()) { + logger.warn("InflowControlManager] reloadGroup all finished ..."); + } + } + + public synchronized void reloadGroup(String groupId) throws Exception { + if (logger.isWarn()) { + logger.warn("InflowControlManager] reloadGroup Started ... groupId=" + groupId); + } + Map map = inflowControlDAO.getInflowTargetByGroup(groupId); + if (map != null) { + // 기존 그룹에 속한 인터페이스 매핑 제거 + Iterator> mappingIt = interfaceToGroupMap.entrySet().iterator(); + while (mappingIt.hasNext()) { + Map.Entry entry = mappingIt.next(); + if (groupId.equals(entry.getValue())) { + mappingIt.remove(); + } + } + + Iterator it = map.keySet().iterator(); + while (it.hasNext()) { + String key = it.next(); + InflowGroupVO groupVo = map.get(key); + + if (isInflowGroupTarget(groupVo)) { + CustomBucket bucket = makeBucketUsingGroupVO(groupVo); + if (bucket != null) { + groupBucketList.put(groupVo.getGroupId(), bucket); + groupVoMap.put(groupVo.getGroupId(), groupVo); + // 인터페이스 → 그룹 매핑 재등록 + for (String interfaceId : groupVo.getInterfaceList()) { + interfaceToGroupMap.put(interfaceId, groupVo.getGroupId()); + } + } else { + groupBucketList.remove(groupVo.getGroupId()); + groupVoMap.remove(groupVo.getGroupId()); + } + } else { + groupBucketList.remove(groupVo.getGroupId()); + groupVoMap.remove(groupVo.getGroupId()); + } + } + } + + if (logger.isWarn()) { + logger.warn("InflowControlManager] reloadGroup finished ..."); + } + } + public void stop() throws LifecycleException { // Validate and update our current component state if (!started) @@ -210,6 +296,9 @@ public class InflowControlManager implements Lifecycle, Bucket { adapterBucketList.clear(); interfaceBucketList.clear(); + groupBucketList.clear(); + interfaceToGroupMap.clear(); + groupVoMap.clear(); started = false; // Notify our interested LifecycleListeners @@ -260,6 +349,29 @@ public class InflowControlManager implements Lifecycle, Bucket { interfaceBucketList.remove(inter); } + public void removeGroup(String groupId) { + groupBucketList.remove(groupId); + groupVoMap.remove(groupId); + // 해당 그룹에 속한 인터페이스 매핑도 제거 + Iterator> it = interfaceToGroupMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + if (groupId.equals(entry.getValue())) { + it.remove(); + } + } + } + + public String[] getGroupAllKeys() { + Iterator it = this.groupBucketList.keySet().iterator(); + String[] groupIds = new String[this.groupBucketList.size()]; + for (int i = 0; it.hasNext(); i++) { + groupIds[i] = it.next(); + } + Arrays.sort(groupIds); + return groupIds; + } + private CustomBucket makeBucketUsingInflowVO(InflowTargetVO inflowTarget) { if (InflowControlManager.isInflowTarget(inflowTarget)) { LocalBucketBuilder builder = Bucket4j.builder(); @@ -278,6 +390,32 @@ public class InflowControlManager implements Lifecycle, Bucket { return null; } + private CustomBucket makeBucketUsingGroupVO(InflowGroupVO groupVo) { + if (isInflowGroupTarget(groupVo)) { + LocalBucketBuilder builder = Bucket4j.builder(); + if (groupVo.getThresholdPerSecond() > 0) { + builder.addLimit(Bandwidth.simple(groupVo.getThresholdPerSecond(), Duration.ofSeconds(1))); + } + + if (groupVo.getThreshold() > 0 && StringUtils.isNotBlank(groupVo.getThresholdTimeUnit())) { + builder.addLimit(Bandwidth.simple(groupVo.getThreshold(), + InflowControlManager.getPeriod(groupVo.getThresholdTimeUnit()))); + } + + // InflowTargetVO로 변환하여 CustomBucket 생성 + InflowTargetVO targetVo = new InflowTargetVO(); + targetVo.setName(groupVo.getGroupId()); + targetVo.setThreshold(groupVo.getThreshold()); + targetVo.setThresholdPerSecond(groupVo.getThresholdPerSecond()); + targetVo.setThresholdTimeUnit(groupVo.getThresholdTimeUnit()); + targetVo.setActivate(groupVo.isActivate()); + + return new CustomBucket(builder.build(), targetVo); + } + + return null; + } + @Override public boolean isAdapterPass(String adapter) { CustomBucket b = adapterBucketList.get(adapter); @@ -327,6 +465,30 @@ public class InflowControlManager implements Lifecycle, Bucket { return getInterfaceInflowThreashold(inter); } + @Override + public boolean isGroupPass(String groupId) { + CustomBucket b = groupBucketList.get(groupId); + + if (b == null) + return true; + + return b.getLocalBucket().tryConsume(1); + } + + @Override + public InflowGroupVO getGroupInflowThreshold(String groupId) { + return groupVoMap.get(groupId); + } + + @Override + public String getGroupIdByInterface(String interfaceId) { + return interfaceToGroupMap.get(interfaceId); + } + + public InflowGroupVO getGroupInflow(String groupId) { + return getGroupInflowThreshold(groupId); + } + public static boolean isInflowTarget(InflowTargetVO inflowTarget) { if (inflowTarget == null || !inflowTarget.isActivate()) { return false; @@ -338,6 +500,16 @@ public class InflowControlManager implements Lifecycle, Bucket { } + public static boolean isInflowGroupTarget(InflowGroupVO groupVo) { + if (groupVo == null || !groupVo.isActivate()) { + return false; + } + + return groupVo.getThresholdPerSecond() > 0 || (groupVo.getThreshold() > 0 && StringUtils + .equalsAnyIgnoreCase(groupVo.getThresholdTimeUnit(), QUOTA_TIMEUNIT_DAY, QUOTA_TIMEUNIT_SECOND, + QUOTA_TIMEUNIT_MINUTE, QUOTA_TIMEUNIT_HOUR, QUOTA_TIMEUNIT_DAY, QUOTA_TIMEUNIT_MONTH)); + } + public static Duration getPeriod(String timeUnit) { if (StringUtils.equalsIgnoreCase(timeUnit, QUOTA_TIMEUNIT_SECOND)) { return Duration.ofSeconds(1); diff --git a/src/main/java/com/eactive/eai/common/inflow/InflowGroupVO.java b/src/main/java/com/eactive/eai/common/inflow/InflowGroupVO.java new file mode 100644 index 0000000..4c05bdc --- /dev/null +++ b/src/main/java/com/eactive/eai/common/inflow/InflowGroupVO.java @@ -0,0 +1,102 @@ +package com.eactive.eai.common.inflow; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +@SuppressWarnings("serial") +public class InflowGroupVO implements Serializable { + private String groupId; + private String groupName; + private long thresholdPerSecond; + private long threshold; + private String thresholdTimeUnit; + private boolean activate; + private List interfaceList = new ArrayList<>(); + + @Override + public boolean equals(Object obj) { + if (obj instanceof InflowGroupVO) { + return groupId.equals(((InflowGroupVO) obj).getGroupId()); + } + return false; + } + + @Override + public int hashCode() { + return groupId != null ? groupId.hashCode() : 0; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public long getThresholdPerSecond() { + return thresholdPerSecond; + } + + public void setThresholdPerSecond(long thresholdPerSecond) { + this.thresholdPerSecond = thresholdPerSecond; + } + + public long getThreshold() { + return threshold; + } + + public void setThreshold(long threshold) { + this.threshold = threshold; + } + + public String getThresholdTimeUnit() { + return thresholdTimeUnit; + } + + public void setThresholdTimeUnit(String thresholdTimeUnit) { + this.thresholdTimeUnit = thresholdTimeUnit; + } + + public boolean isActivate() { + return activate; + } + + public void setActivate(boolean activate) { + this.activate = activate; + } + + public List getInterfaceList() { + return interfaceList; + } + + public void setInterfaceList(List interfaceList) { + this.interfaceList = interfaceList; + } + + public void addInterface(String interfaceId) { + if (this.interfaceList == null) { + this.interfaceList = new ArrayList<>(); + } + this.interfaceList.add(interfaceId); + } + + @Override + public String toString() { + return "InflowGroupVO [groupId=" + groupId + ", groupName=" + groupName + + ", thresholdPerSecond=" + thresholdPerSecond + + ", threshold=" + threshold + + ", thresholdTimeUnit=" + thresholdTimeUnit + + ", activate=" + activate + + ", interfaceCount=" + (interfaceList != null ? interfaceList.size() : 0) + "]"; + } +} diff --git a/src/main/java/com/eactive/eai/common/logger/mapper/HttpAdapterExtraHeaderMapper.java b/src/main/java/com/eactive/eai/common/logger/mapper/HttpAdapterExtraHeaderMapper.java deleted file mode 100644 index b609dee..0000000 --- a/src/main/java/com/eactive/eai/common/logger/mapper/HttpAdapterExtraHeaderMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -//package com.eactive.eai.common.logger.mapper; -// -//import com.eactive.eai.common.logger.HttpAdapterExtraHeaderVo; -//import com.eactive.eai.data.entity.onl.logger.HttpAdapterExtraHeader; -//import com.eactive.eai.data.mapper.BaseMapperConfig; -//import com.eactive.eai.data.mapper.GenericMapper; -// -//import org.mapstruct.InheritInverseConfiguration; -//import org.mapstruct.Mapper; -//import org.mapstruct.Mapping; -// -//@Mapper(config = BaseMapperConfig.class) -//public interface HttpAdapterExtraHeaderMapper extends GenericMapper { -// -// @Override -// @Mapping(source = "id.name", target = "name") -// HttpAdapterExtraHeaderVo toVo(HttpAdapterExtraHeader entity); -// -// @Override -// @InheritInverseConfiguration -// HttpAdapterExtraHeader toEntity(HttpAdapterExtraHeaderVo vo); -//} diff --git a/src/main/java/com/eactive/eai/inbound/processor/RequestProcessor.java b/src/main/java/com/eactive/eai/inbound/processor/RequestProcessor.java index 54b1a12..5ed8d8b 100644 --- a/src/main/java/com/eactive/eai/inbound/processor/RequestProcessor.java +++ b/src/main/java/com/eactive/eai/inbound/processor/RequestProcessor.java @@ -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()); }