Skip to content

Commit

Permalink
[#209]
Browse files Browse the repository at this point in the history
type : feature
body : [fix #209] MGMT CDC Monitoring add kafka restart process
  • Loading branch information
Jeong-Yoon committed Sep 13, 2021
1 parent a89f683 commit 6adf834
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,6 @@ public interface TransMonitoringService {
* @param transVO, param
* @return JSONObject
*/
public JSONObject transKafkaConnectRestart(TransVO transVO);
public Map<String, Object> transKafkaConnectRestart(TransVO transVO, Map<String, Object> param);

}
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,13 @@ public List<Map<String, Object>> selectTargetErrorInfo(int trans_id) {
public List<Map<String, Object>> selectAllErrorList() {
return selectList("transMonitoringSql.selectAllErrorList");
}

/**
* kafka connect 정보 조회
*
* @return Map<String, Object>
*/
public Map<String, Object> selectKafkaConnectInfo(int trans_id){
return selectOne("transMonitoringSql.selectKafkaConnectInfo", trans_id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,13 @@ public Map<String, Object> getLogFile(TransVO transVO, Map<String, Object> param

try {
int db_svr_id = transVO.getDb_svr_id();

int trans_id = transVO.getTrans_id();
System.out.println("trans_id : " + trans_id);
AES256 dec = new AES256(AES256_KEY.ENC_KEY);

// kafka 정보 조회
Map<String, Object> kafkaInfo = transMonitoringDAO.selectKafkaConnectInfo(trans_id);

//db 서버 조회
DbServerVO schDbServerVO = new DbServerVO();
schDbServerVO.setDb_svr_id(db_svr_id);
Expand All @@ -309,9 +313,9 @@ public Map<String, Object> getLogFile(TransVO transVO, Map<String, Object> param
vo.setIPADR(strIpAdr);
AgentInfoVO agentInfo = (AgentInfoVO) cmmnServerInfoDAO.selectAgentInfo(vo);

String IP = dbServerVO.getIpadr();
String IP = String.valueOf(kafkaInfo.get("kc_ip"));
// int PORT = Integer.parseInt(String.valueOf(kafkaInfo.get("kc_port")));
int PORT = agentInfo.getSOCKET_PORT();

dbServerVO.setSvr_spr_scm_pwd(dec.aesDecode(dbServerVO.getSvr_spr_scm_pwd_old()));
dbServerVO.setUsr_id(transVO.getFrst_regr_id());

Expand All @@ -337,20 +341,16 @@ public Map<String, Object> getLogFile(TransVO transVO, Map<String, Object> param
* @return JSONObject
*/
@Override
public JSONObject transKafkaConnectRestart(TransVO transVO) {
public Map<String, Object> transKafkaConnectRestart(TransVO transVO, Map<String, Object> param) {
JSONObject jObj = new JSONObject();
JSONObject resultObj = new JSONObject();

boolean executeFlag = false;

String resultLog = "";
String errMsg = "";
Map<String, Object> resultObj = new HashMap<String, Object>();

try {
int db_svr_id = transVO.getDb_svr_id();

int trans_id = transVO.getTrans_id();
AES256 dec = new AES256(AES256_KEY.ENC_KEY);

Map<String, Object> kafkaInfo = transMonitoringDAO.selectKafkaConnectInfo(trans_id);

//db 서버 조회
DbServerVO schDbServerVO = new DbServerVO();
schDbServerVO.setDb_svr_id(db_svr_id);
Expand All @@ -362,16 +362,22 @@ public JSONObject transKafkaConnectRestart(TransVO transVO) {
vo.setIPADR(strIpAdr);
AgentInfoVO agentInfo = (AgentInfoVO) cmmnServerInfoDAO.selectAgentInfo(vo);

String IP = dbServerVO.getIpadr();
// String IP = dbServerVO.getIpadr();
String IP = String.valueOf(kafkaInfo.get("kc_ip"));
int PORT = agentInfo.getSOCKET_PORT();

dbServerVO.setSvr_spr_scm_pwd(dec.aesDecode(dbServerVO.getSvr_spr_scm_pwd_old()));
dbServerVO.setUsr_id(transVO.getFrst_regr_id());

System.out.println(dbServerVO.toString());
jObj.put(ClientProtocolID.DX_EX_CODE, ClientTranCodeType.DxT044);

jObj.put(ClientProtocolID.USER_ID, param.get("lst_mdfr_id"));
jObj.put(ClientProtocolID.KC_IP, IP);
jObj.put(ClientProtocolID.KC_PORT,kafkaInfo.get("kc_port"));
jObj.put("kc_id", kafkaInfo.get("kc_id"));
System.out.println(jObj.toJSONString());
ClientInfoCmmn cic = new ClientInfoCmmn();
resultObj = cic.kafkaConnectRestart(IP, PORT, dbServerVO, jObj);
System.out.println("resultObj : " + resultObj.toString());
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.json.simple.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.k4m.dx.tcontrol.admin.dbserverManager.service.DbServerVO;
import com.k4m.dx.tcontrol.common.service.CmmnServerInfoService;
import com.k4m.dx.tcontrol.common.service.HistoryVO;
import com.k4m.dx.tcontrol.login.service.LoginVO;
import com.k4m.dx.tcontrol.transfer.service.TransMonitoringService;
import com.k4m.dx.tcontrol.transfer.service.TransVO;

Expand Down Expand Up @@ -307,7 +307,7 @@ public ModelAndView transConnectorLogViewAjax(@ModelAttribute("historyVO") Histo
int db_svr_id = Integer.parseInt(request.getParameter("db_svr_id"));
String strTransId = request.getParameter("trans_id");
String type = request.getParameter("type");
// int trans_id = Integer.parseInt(strTransId);
int trans_id = Integer.parseInt(strTransId);
String strSeek = request.getParameter("seek");
String strReadLine = request.getParameter("readLine");
String dwLen = request.getParameter("dwLen");
Expand All @@ -316,7 +316,7 @@ public ModelAndView transConnectorLogViewAjax(@ModelAttribute("historyVO") Histo

TransVO transVO = new TransVO();
transVO.setDb_svr_id(db_svr_id);

transVO.setTrans_id(trans_id);
Map<String, Object> param = new HashMap<>();
param.put("seek", strSeek);
param.put("readLine", strReadLine);
Expand Down Expand Up @@ -344,18 +344,30 @@ public ModelAndView transConnectorLogViewAjax(@ModelAttribute("historyVO") Histo
* trans Kafka Connect 재시작
*
* @param historyVO, request
* @return JSONObject
* @return ModelAndView
*/
@RequestMapping("/transKafkaConnectRestart.do")
public @ResponseBody JSONObject transKafkaConnectRestart(@ModelAttribute("historyVO") HistoryVO historyVO, HttpServletRequest request) {
JSONObject resultObj = new JSONObject();
int db_svr_id = Integer.parseInt(request.getParameter("db_svr_id"));

TransVO transVO = new TransVO();
transVO.setDb_svr_id(db_svr_id);

resultObj = transMonitoringService.transKafkaConnectRestart(transVO);

return resultObj;
public ModelAndView transKafkaConnectRestart(@ModelAttribute("historyVO") HistoryVO historyVO, HttpServletRequest request) {
ModelAndView mv = new ModelAndView("jsonView");
HttpSession session = request.getSession();
try {
LoginVO loginVo = (LoginVO) session.getAttribute("session");
Map<String, Object> param = new HashMap<String, Object>();
param.put("lst_mdfr_id", loginVo.getUsr_id() == null ? "" : loginVo.getUsr_id().toString());

int db_svr_id = Integer.parseInt(request.getParameter("db_svr_id"));
int trans_id = Integer.parseInt(request.getParameter("trans_id"));
TransVO transVO = new TransVO();
transVO.setDb_svr_id(db_svr_id);
transVO.setTrans_id(trans_id);
Map<String, Object> resultObj = transMonitoringService.transKafkaConnectRestart(transVO, param);
System.out.println(resultObj.toString());
System.out.println(resultObj.get("RESULT_DATA"));
mv.addObject("data", resultObj.get("RESULT_DATA"));
} catch (Exception e) {
e.printStackTrace();
}

return mv;
}
}

0 comments on commit 6adf834

Please sign in to comment.