| 
					
				 | 
			
			
				@@ -1,12 +1,12 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.its.icmp.service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.its.app.utils.SysUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.its.app.AppUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.its.app.utils.SysUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.its.icmp.dao.IcmpPingDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.its.icmp.thread.IcmpPingThread; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.its.icmp.vo.IcmpPingVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.its.icmp.vo.IcmpCtlrVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.its.icmp.vo.IcmpCtlrSttsVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.its.icmp.vo.IcmpCtlrVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.its.icmp.vo.IcmpPingVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.Getter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.slf4j.MDC; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -21,17 +21,21 @@ import java.util.concurrent.ConcurrentHashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Slf4j 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Getter 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//@AllArgsConstructor 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Transactional(rollbackFor = { Exception.class }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class IcmpPingService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private IcmpPingDao ctlrMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private IcmpPingDao icmpPingDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private IcmpPingThread icmpPingThread; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	private ConcurrentHashMap<String, ConcurrentHashMap<String, IcmpCtlrVo>> icmpCtlrMap = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@PostConstruct 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	private void init() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		log.info("IcmpPingService.init"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		this.ctlrMapper = (IcmpPingDao) AppUtils.getBean(IcmpPingDao.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		this.icmpPingDao = (IcmpPingDao)AppUtils.getBean(IcmpPingDao.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		this.icmpPingThread = (IcmpPingThread)AppUtils.getBean(IcmpPingThread.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		this.icmpCtlrMap = new ConcurrentHashMap<String, ConcurrentHashMap<String, IcmpCtlrVo>>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -41,20 +45,25 @@ public class IcmpPingService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public void loadDb(String name) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		log.info("loadDb: {} start.", name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		log.info("IcmpPingService.loadDb: {} start.", name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if (null == this.icmpCtlrMap.get(name)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			initMap(name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			List<IcmpCtlrVo> list = this.ctlrMapper.selectAll(name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			List<IcmpCtlrVo> list = this.icmpPingDao.selectAll(name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			for (IcmpCtlrVo obj : list) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				obj.setStts(IcmpCtlrSttsVo.builder() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						.CTLR_NMBR(obj.getCTLR_NMBR()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						.CMNC_STTS_CD("CMS1") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						.UPDT_DT("19700101000000") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						.build()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				this.icmpCtlrMap.get(name).put(obj.getCTLR_NMBR(), obj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			log.error("Service.loadDb-{}: Exception: {}", name, e.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			log.error("IcmpPingService.loadDb-{}: Exception: {}", name, e.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		log.info("loadDb: {} ..end. {} EA.", name, this.icmpCtlrMap.get(name).size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		log.info("IcmpPingService.loadDb: {} ..end. {} EA.", name, this.icmpCtlrMap.get(name).size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public void initDb(String name) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -66,14 +75,14 @@ public class IcmpPingService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			loadDb(name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			log.error("Service.initJob: Exception: {}", e.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			log.error("IcmpPingService.initDb: Exception: {}", e.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public void doJob(IcmpPingVo icmp) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		MDC.put("id", icmp.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		log.info("Service.doJob Start...:: {}", icmp.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		log.info("IcmpPingService.doJob Start...:: {}", icmp.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		boolean insHs = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Calendar cal = Calendar.getInstance(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -88,32 +97,26 @@ public class IcmpPingService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		String UPDT_DT = SysUtils.getSysTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		for (Map.Entry<String, IcmpCtlrVo> obj : this.icmpCtlrMap.get(icmp.getName()).entrySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				if (obj.getValue().getDEL_YN().equals("Y")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					log.info("Service.doJob: app {}: {}, {}, {}, DELETED.", icmp.getName(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							obj.getValue().getCTLR_NMBR(), obj.getValue().getISTL_LCTN_NM(), obj.getValue().getCTLR_IP()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				IcmpPingThread handler = (IcmpPingThread) AppUtils.getBean(IcmpPingThread.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				if (handler != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					handler.setPingTimeout(icmp.getTimeout()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					if(obj.getValue().getCTLR_IP() != null && !obj.getValue().getCTLR_IP().equals("NULL") && !obj.getValue().getCTLR_IP().equals("")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						handler.run(insHs, UPDT_DT, obj.getValue(), icmp.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if (obj.getValue().getDEL_YN().equals("Y")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				log.info("Service.doJob: app {}: {}, {}, {}, DELETED.", icmp.getName(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						obj.getValue().getCTLR_NMBR(), obj.getValue().getISTL_LCTN_NM(), obj.getValue().getCTLR_IP()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if (obj.getValue().getCTLR_IP() != null && !obj.getValue().getCTLR_IP().equals("NULL") && !obj.getValue().getCTLR_IP().equals("")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				this.icmpPingThread.run(insHs, UPDT_DT, obj.getValue(), icmp.getName(), icmp.getTimeout()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		log.info("Service.doJob ..End...:: {}", icmp.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		log.info("IcmpPingService.doJob ..End...:: {}", icmp.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		MDC.remove(icmp.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		MDC.clear(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public void updateCtlrStts(boolean isRun, String name) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		MDC.put("id", name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		String CMNC_STTS_CD = isRun ? "CMS0" : "CMS1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		String UPDT_DT = SysUtils.getSysTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		for (Map.Entry<String, IcmpCtlrVo> obj : this.icmpCtlrMap.get(name).entrySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -124,11 +127,13 @@ public class IcmpPingService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				IcmpCtlrSttsVo stts = new IcmpCtlrSttsVo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				stts.setCTLR_NMBR(obj.getValue().getCTLR_NMBR()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				stts.setUPDT_DT(UPDT_DT); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				stts.setCMNC_STTS_CD("CMS1"); // 비정상으로 기본 설정 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				this.ctlrMapper.updateStts(name, stts); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				IcmpCtlrSttsVo stts = IcmpCtlrSttsVo.builder() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						.CTLR_NMBR(obj.getValue().getCTLR_NMBR()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						.UPDT_DT(UPDT_DT) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						.CMNC_STTS_CD(CMNC_STTS_CD) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						.build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				obj.getValue().setStts(stts); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				this.icmpPingDao.updateStts(name, stts); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |