Search in sources :

Example 41 with Range

use of com.navercorp.pinpoint.web.vo.Range 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 42 with Range

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

the class AgentStatDataCollector method collect.

@Override
public void collect() {
    if (init.get()) {
        return;
    }
    Range range = Range.createUncheckedRange(timeSlotEndTime - slotInterval, timeSlotEndTime);
    List<String> agentIds = applicationIndexDao.selectAgentIds(application.getName());
    for (String agentId : agentIds) {
        List<JvmGcBo> jvmGcBos = jvmGcDao.getAgentStatList(agentId, range);
        List<CpuLoadBo> cpuLoadBos = cpuLoadDao.getAgentStatList(agentId, range);
        long totalHeapSize = 0;
        long usedHeapSize = 0;
        long jvmCpuUsaged = 0;
        for (JvmGcBo jvmGcBo : jvmGcBos) {
            totalHeapSize += jvmGcBo.getHeapMax();
            usedHeapSize += jvmGcBo.getHeapUsed();
        }
        for (CpuLoadBo cpuLoadBo : cpuLoadBos) {
            jvmCpuUsaged += cpuLoadBo.getJvmCpuLoad() * 100;
        }
        if (!jvmGcBos.isEmpty()) {
            long percent = calculatePercent(usedHeapSize, totalHeapSize);
            agentHeapUsageRate.put(agentId, percent);
            long accruedLastGcCount = jvmGcBos.get(0).getGcOldCount();
            long accruedFirstGcCount = jvmGcBos.get(jvmGcBos.size() - 1).getGcOldCount();
            agentGcCount.put(agentId, accruedLastGcCount - accruedFirstGcCount);
        }
        if (!cpuLoadBos.isEmpty()) {
            long percent = calculatePercent(jvmCpuUsaged, 100 * cpuLoadBos.size());
            agentJvmCpuUsageRate.put(agentId, percent);
        }
    }
    init.set(true);
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) CpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo) Range(com.navercorp.pinpoint.web.vo.Range)

Example 43 with Range

use of com.navercorp.pinpoint.web.vo.Range 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 44 with Range

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

the class HeapUsageRateCheckerTest method before.

@BeforeClass
public static void before() {
    jvmGcDao = new AgentStatDao<JvmGcBo>() {

        @Override
        public List<JvmGcBo> getAgentStatList(String agentId, Range range) {
            List<JvmGcBo> jvmGcs = new LinkedList<>();
            for (int i = 0; i < 36; i++) {
                JvmGcBo jvmGcBo = new JvmGcBo();
                jvmGcBo.setHeapUsed(70L);
                jvmGcBo.setHeapMax(100L);
                jvmGcs.add(jvmGcBo);
            }
            return jvmGcs;
        }

        @Override
        public boolean agentStatExists(String agentId, Range range) {
            return true;
        }
    };
    cpuLoadDao = new AgentStatDao<CpuLoadBo>() {

        @Override
        public List<CpuLoadBo> getAgentStatList(String agentId, Range range) {
            return Collections.emptyList();
        }

        @Override
        public boolean agentStatExists(String agentId, Range range) {
            return false;
        }
    };
    applicationIndexDao = new ApplicationIndexDao() {

        @Override
        public List<Application> selectAllApplicationNames() {
            throw new UnsupportedOperationException();
        }

        @Override
        public List<String> selectAgentIds(String applicationName) {
            if (SERVICE_NAME.equals(applicationName)) {
                List<String> agentIds = new LinkedList<String>();
                agentIds.add("local_tomcat");
                return agentIds;
            }
            throw new IllegalArgumentException();
        }

        @Override
        public void deleteApplicationName(String applicationName) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void deleteAgentIds(Map<String, List<String>> applicationAgentIdMap) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void deleteAgentId(String applicationName, String agentId) {
            throw new UnsupportedOperationException();
        }
    };
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) CpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo) ApplicationIndexDao(com.navercorp.pinpoint.web.dao.ApplicationIndexDao) Range(com.navercorp.pinpoint.web.vo.Range) List(java.util.List) LinkedList(java.util.LinkedList) BeforeClass(org.junit.BeforeClass)

Example 45 with Range

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

the class LinkCallDataTest method addCallData.

@Test
public void addCallData() {
    LinkKey key = new LinkKey("fromApplication", ServiceType.STAND_ALONE, "toApplication", ServiceType.STAND_ALONE);
    long currentTime = System.currentTimeMillis();
    LinkCallData data1 = new LinkCallData(key);
    data1.addCallData(currentTime, (short) 100, 1L);
    data1.addCallData(currentTime + ONE_MINUTE, (short) 100, 1L);
    data1.addCallData(currentTime + ONE_MINUTE + ONE_MINUTE, (short) 100, 1L);
    data1.addCallData(currentTime + ONE_MINUTE + ONE_MINUTE + ONE_MINUTE, (short) 100, 1L);
    data1.addCallData(currentTime + ONE_MINUTE + ONE_MINUTE + ONE_MINUTE + ONE_MINUTE, (short) 100, 1L);
    logger.debug("{}", data1.getTimeHistogram().size());
    Range range = new Range(currentTime, currentTime + SIX_HOURS);
    TimeWindow window = new TimeWindow(range, TimeWindowDownSampler.SAMPLER);
    LinkCallData data2 = new LinkCallData(key, window);
    data2.addCallData(currentTime, (short) 100, 1L);
    data2.addCallData(currentTime + ONE_MINUTE, (short) 100, 1L);
    data2.addCallData(currentTime + ONE_MINUTE + ONE_MINUTE, (short) 100, 1L);
    data2.addCallData(currentTime + ONE_MINUTE + ONE_MINUTE + ONE_MINUTE, (short) 100, 1L);
    data2.addCallData(currentTime + ONE_MINUTE + ONE_MINUTE + ONE_MINUTE + ONE_MINUTE, (short) 100, 1L);
    logger.debug("{}", data2.getTimeHistogram().size());
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) Range(com.navercorp.pinpoint.web.vo.Range) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) Test(org.junit.Test)

Aggregations

Range (com.navercorp.pinpoint.web.vo.Range)101 Test (org.junit.Test)62 TimeWindow (com.navercorp.pinpoint.web.util.TimeWindow)23 AgentStatus (com.navercorp.pinpoint.web.vo.AgentStatus)16 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)16 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)15 Application (com.navercorp.pinpoint.web.vo.Application)12 SampledAgentStatResultExtractor (com.navercorp.pinpoint.web.mapper.stat.SampledAgentStatResultExtractor)9 List (java.util.List)8 AgentEvent (com.navercorp.pinpoint.web.vo.AgentEvent)7 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)7 CpuLoadBo (com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo)6 JvmGcBo (com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo)6 AgentStatDataPoint (com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint)5 TimeWindowSlotCentricSampler (com.navercorp.pinpoint.web.util.TimeWindowSlotCentricSampler)5 LegacyAgentStatChartGroup (com.navercorp.pinpoint.web.vo.stat.chart.LegacyAgentStatChartGroup)5 ArrayList (java.util.ArrayList)5 TimeWindowSampler (com.navercorp.pinpoint.web.util.TimeWindowSampler)4 StopWatch (org.springframework.util.StopWatch)4 ApplicationIndexDao (com.navercorp.pinpoint.web.dao.ApplicationIndexDao)3