Search in sources :

Example 1 with AgentCountStatistics

use of com.navercorp.pinpoint.web.vo.AgentCountStatistics in project pinpoint by naver.

the class MemoryAgentStatisticsDaoTest method simpleTest.

@Test
public void simpleTest() throws Exception {
    MemoryAgentStatisticsDao dao = new MemoryAgentStatisticsDao();
    for (AgentCountStatistics testData : testDataList) {
        dao.insertAgentCount(testData);
    }
    Range range = new Range(660L, 1320L);
    List<AgentCountStatistics> agentCountStatisticses = dao.selectAgentCount(range);
    Assert.assertEquals(7, agentCountStatisticses.size());
    range = new Range(7100L, System.currentTimeMillis());
    agentCountStatisticses = dao.selectAgentCount(range);
    Assert.assertEquals(30, agentCountStatisticses.size());
    range = new Range(0L, System.currentTimeMillis());
    agentCountStatisticses = dao.selectAgentCount(range);
    Assert.assertEquals(100, agentCountStatisticses.size());
    long currentTime = System.currentTimeMillis();
    range = new Range(currentTime, currentTime + 100);
    agentCountStatisticses = dao.selectAgentCount(range);
    Assert.assertEquals(0, agentCountStatisticses.size());
}
Also used : AgentCountStatistics(com.navercorp.pinpoint.web.vo.AgentCountStatistics) Range(com.navercorp.pinpoint.web.vo.Range) Test(org.junit.Test)

Example 2 with AgentCountStatistics

use of com.navercorp.pinpoint.web.vo.AgentCountStatistics in project pinpoint by naver.

the class MemoryAgentStatisticsDao method selectAgentCount.

@Override
public List<AgentCountStatistics> selectAgentCount(Range range) {
    Long to = range.getTo();
    long from = range.getFrom();
    List<AgentCountStatistics> result = new ArrayList<>();
    Iterator<Map.Entry<Long, Integer>> iterator = agentCountPerTime.entrySet().iterator();
    while (iterator.hasNext()) {
        Map.Entry<Long, Integer> next = iterator.next();
        Long key = next.getKey();
        if (key > to) {
            continue;
        }
        if (key < from) {
            break;
        }
        result.add(new AgentCountStatistics(next.getValue(), key));
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) AgentCountStatistics(com.navercorp.pinpoint.web.vo.AgentCountStatistics) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 3 with AgentCountStatistics

use of com.navercorp.pinpoint.web.vo.AgentCountStatistics in project pinpoint by naver.

the class AgentStatisticsController method insertAgentCount.

@RequestMapping(value = "/insertAgentCount", method = RequestMethod.GET, params = { "agentCount", "timestamp" })
@ResponseBody
public Map<String, String> insertAgentCount(@RequestParam("agentCount") int agentCount, @RequestParam("timestamp") long timestamp) {
    if (timestamp < 0) {
        Map<String, String> result = new HashMap<>();
        result.put("result", "FAIL");
        result.put("message", "negative timestamp.");
        return result;
    }
    AgentCountStatistics agentCountStatistics = new AgentCountStatistics(agentCount, DateUtils.timestampToMidNight(timestamp));
    boolean success = agentStatisticsService.insertAgentCount(agentCountStatistics);
    if (success) {
        Map<String, String> result = new HashMap<>();
        result.put("result", "SUCCESS");
        return result;
    } else {
        Map<String, String> result = new HashMap<>();
        result.put("result", "FAIL");
        result.put("message", "insert DAO error.");
        return result;
    }
}
Also used : HashMap(java.util.HashMap) AgentCountStatistics(com.navercorp.pinpoint.web.vo.AgentCountStatistics) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with AgentCountStatistics

use of com.navercorp.pinpoint.web.vo.AgentCountStatistics in project pinpoint by naver.

the class AgentStatisticsController method selectAgentCount.

@RequestMapping(value = "/selectAgentCount", method = RequestMethod.GET, params = { "from", "to" })
@ResponseBody
public List<AgentCountStatistics> selectAgentCount(@RequestParam("from") long from, @RequestParam("to") long to) {
    Range range = new Range(DateUtils.timestampToMidNight(from), DateUtils.timestampToMidNight(to), true);
    List<AgentCountStatistics> agentCountStatisticsList = agentStatisticsService.selectAgentCount(range);
    Collections.sort(agentCountStatisticsList, new Comparator<AgentCountStatistics>() {

        @Override
        public int compare(AgentCountStatistics o1, AgentCountStatistics o2) {
            if (o1.getTimestamp() > o2.getTimestamp()) {
                return -1;
            } else {
                return 1;
            }
        }
    });
    return agentCountStatisticsList;
}
Also used : AgentCountStatistics(com.navercorp.pinpoint.web.vo.AgentCountStatistics) Range(com.navercorp.pinpoint.web.vo.Range) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with AgentCountStatistics

use of com.navercorp.pinpoint.web.vo.AgentCountStatistics in project pinpoint by naver.

the class AgentCountProcessor method process.

@Override
public AgentCountStatistics process(ApplicationAgentList item) throws Exception {
    if (item == null) {
        return null;
    }
    int agentCount = getAgentCount(item.getApplicationAgentList());
    AgentCountStatistics agentCountStatistics = new AgentCountStatistics(agentCount, DateUtils.timestampToMidNight(System.currentTimeMillis()));
    return agentCountStatistics;
}
Also used : AgentCountStatistics(com.navercorp.pinpoint.web.vo.AgentCountStatistics)

Aggregations

AgentCountStatistics (com.navercorp.pinpoint.web.vo.AgentCountStatistics)7 Range (com.navercorp.pinpoint.web.vo.Range)2 ArrayList (java.util.ArrayList)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Test (org.junit.Test)1 JobExecutionException (org.springframework.batch.core.JobExecutionException)1