[유치수] [NOBTS] monitor service 추가.

git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-web/trunk@1392 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
Chisu Yu
2013-04-02 06:29:44 +00:00
parent 28af026fff
commit d021c6786a
6 changed files with 78 additions and 12 deletions
@@ -9,9 +9,12 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.nhn.hippo.web.service.FlowChartService;
import com.nhn.hippo.web.service.MonitorService;
import com.nhn.hippo.web.vo.Application;
import com.profiler.common.bo.AgentInfoBo;
/**
*
@@ -20,18 +23,33 @@ import com.nhn.hippo.web.vo.Application;
@Controller
public class MainController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private FlowChartService flow;
@Autowired
private FlowChartService flow;
@RequestMapping(value = "/applications", method = RequestMethod.GET)
public String flow(Model model) {
List<Application> applications = flow.selectAllApplicationNames();
model.addAttribute("applications", applications);
@Autowired
private MonitorService monitor;
logger.debug("Applications, {}", applications);
@RequestMapping(value = "/applications", method = RequestMethod.GET)
public String flow(Model model) {
List<Application> applications = flow.selectAllApplicationNames();
model.addAttribute("applications", applications);
return "applications";
}
logger.debug("Applications, {}", applications);
return "applications";
}
@RequestMapping(value = "/agentStatus", method = RequestMethod.GET)
public String agentStatus(Model model, @RequestParam("agentId") String agentId) {
AgentInfoBo agentInfo = monitor.getAgentInfo(agentId);
long gap = System.currentTimeMillis() - agentInfo.getTimestamp();
model.addAttribute("gap", gap);
model.addAttribute("agentinfo", agentInfo);
return "agentstatus";
}
}
@@ -7,5 +7,5 @@ import com.profiler.common.bo.AgentInfoBo;
*/
public interface AgentInfoDao {
AgentInfoBo findAgentInfoBeforeStartTime(String agentInfo, long currentTime);
AgentInfoBo findAgentInfoBeforeStartTime(String agentId, long currentTime);
}
@@ -53,12 +53,15 @@ public class HbaseAgentInfoDao implements AgentInfoDao {
agentInfoBo.setAgentId(agentId);
agentInfoBo.setTimestamp(startTime);
agentInfoBo.readValue(value);
logger.debug("agent:{} startTime find {}", agentId, startTime);
return agentInfoBo;
}
}
logger.warn("agentInfo not found. agentId={}, time={}", agentId, currentTime);
return null;
}
});
@@ -0,0 +1,10 @@
package com.nhn.hippo.web.service;
import com.profiler.common.bo.AgentInfoBo;
/**
* @author netspider
*/
public interface MonitorService {
public AgentInfoBo getAgentInfo(String agentId);
}
@@ -0,0 +1,28 @@
package com.nhn.hippo.web.service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nhn.hippo.web.dao.AgentInfoDao;
import com.profiler.common.bo.AgentInfoBo;
/**
*
* @author netspider
*/
@Service
public class MonitorServiceImpl implements MonitorService {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private AgentInfoDao agentInfoDao;
public AgentInfoBo getAgentInfo(String agentId) {
AgentInfoBo agentInfo = agentInfoDao.findAgentInfoBeforeStartTime(agentId, System.currentTimeMillis());
logger.debug("Found agentInfo agentId={}, agentInfo={}", agentId, agentInfo);
return agentInfo;
}
}
@@ -0,0 +1,7 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
{
"gap" : ${gap},
"lastping" : ${agentinfo.timestamp}
}