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());
}
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;
}
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;
}
}
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;
}
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;
}
Aggregations