Search in sources :

Example 56 with Range

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

the class SampledAgentStatResultExtractorTest method one_to_one_sampler_should_not_down_sample_data_points.

@Test
public void one_to_one_sampler_should_not_down_sample_data_points() throws Exception {
    // Given
    final int numValues = 10;
    final long initialTimestamp = System.currentTimeMillis();
    final long finalTimestamp = initialTimestamp + (DEFAULT_TIME_INTERVAL * numValues);
    final TimeWindow timeWindow = new TimeWindow(new Range(initialTimestamp, finalTimestamp), ONE_TO_ONE_SAMPLER);
    final List<TestAgentStatDataPoint> dataPoints = createDataPoints(finalTimestamp, DEFAULT_TIME_INTERVAL, numValues);
    final Map<Long, List<TestAgentStatDataPoint>> expectedDataPointSlotMap = getExpectedDataPointSlotMap(timeWindow, dataPoints);
    when(this.rowMapper.mapRow(this.result, 0)).thenReturn(dataPoints);
    TestAgentStatSampler testAgentStatSampler = new TestAgentStatSampler();
    SampledAgentStatResultExtractor<TestAgentStatDataPoint, TestSampledAgentStatDataPoint> resultExtractor = new SampledAgentStatResultExtractor<>(timeWindow, this.rowMapper, testAgentStatSampler);
    // When
    List<TestSampledAgentStatDataPoint> sampledDataPoints = resultExtractor.extractData(this.resultScanner);
    // Then
    for (TestSampledAgentStatDataPoint sampledDataPoint : sampledDataPoints) {
        List<TestAgentStatDataPoint> expectedSampledDataPoints = expectedDataPointSlotMap.get(sampledDataPoint.getBaseTimestamp());
        Assert.assertEquals(expectedSampledDataPoints, sampledDataPoint.getDataPointsToSample());
    }
}
Also used : Range(com.navercorp.pinpoint.web.vo.Range) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) AgentStatDataPoint(com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint) SampledAgentStatDataPoint(com.navercorp.pinpoint.web.vo.stat.SampledAgentStatDataPoint) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 57 with Range

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

the class BFSLinkSelectorTest method testCallee_3tier.

@Test
public void testCallee_3tier() throws Exception {
    // APP_A -> APP_B -> APP_C
    when(calleeDao.selectCallee(any(Application.class), any(Range.class))).thenReturn(newEmptyLinkDataMap());
    int callCount_A_B = 30;
    LinkDataMap linkDataMap_A_B = new LinkDataMap();
    linkDataMap_A_B.addLinkData(APP_A, "agentA", APP_B, "agentB", 1000, BaseHistogramSchema.NORMAL_SCHEMA.getNormalSlot().getSlotTime(), callCount_A_B);
    when(calleeDao.selectCallee(eq(APP_B), any(Range.class))).thenReturn(linkDataMap_A_B);
    int callCount_B_C = 40;
    LinkDataMap linkDataMap_B_C = new LinkDataMap();
    linkDataMap_B_C.addLinkData(APP_B, "agentB", APP_C, "agentC", 1000, BaseHistogramSchema.NORMAL_SCHEMA.getNormalSlot().getSlotTime(), callCount_B_C);
    when(calleeDao.selectCallee(eq(APP_C), any(Range.class))).thenReturn(linkDataMap_B_C);
    when(callerDao.selectCaller(any(Application.class), any(Range.class))).thenReturn(newEmptyLinkDataMap());
    when(hostApplicationMapDao.findAcceptApplicationName(any(Application.class), any(Range.class))).thenReturn(new HashSet<AcceptApplication>());
    LinkSelector linkSelector = createLinkSelector();
    LinkDataDuplexMap linkData = linkSelector.select(APP_C, range, oneDepth);
    Assert.assertEquals(linkData.size(), 1);
    Assert.assertEquals(linkData.getTotalCount(), callCount_B_C);
    Assert.assertEquals(linkData.getSourceLinkDataList().size(), 0);
    Assert.assertEquals(linkData.getTargetLinkDataList().size(), 1);
    Assert.assertEquals(linkData.getTotalCount(), callCount_B_C);
    // depth 2
    LinkSelector linkSelector2 = createLinkSelector();
    LinkDataDuplexMap linkData_depth2 = linkSelector2.select(APP_C, range, twoDepth);
    Assert.assertEquals(linkData_depth2.size(), 2);
    LinkKey linkKey_A_B = new LinkKey(APP_A, APP_B);
    assertTarget_Source_TotalCount("APP_A->APP_B", linkData_depth2, linkKey_A_B, callCount_A_B);
    LinkKey linkKey_B_C = new LinkKey(APP_B, APP_C);
    assertTarget_Source_TotalCount("APP_B->APP_C", linkData_depth2, linkKey_B_C, callCount_B_C);
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) Range(com.navercorp.pinpoint.web.vo.Range) AcceptApplication(com.navercorp.pinpoint.web.service.map.AcceptApplication) Application(com.navercorp.pinpoint.web.vo.Application) AcceptApplication(com.navercorp.pinpoint.web.service.map.AcceptApplication) Test(org.junit.Test)

Example 58 with Range

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

the class DataSourceChartGroupSerializerTest method serializeTest.

@Test
public void serializeTest() throws Exception {
    long currentTimeMillis = System.currentTimeMillis();
    TimeWindow timeWindow = new TimeWindow(new Range(currentTimeMillis - 300000, currentTimeMillis));
    List<SampledDataSource> sampledDataSourceList = createSampledDataSourceList(timeWindow);
    DataSourceChartGroup dataSourceChartGroup = new DataSourceChartGroup(timeWindow, sampledDataSourceList, serviceTypeRegistryService);
    String jsonValue = mapper.writeValueAsString(dataSourceChartGroup);
    Map map = mapper.readValue(jsonValue, Map.class);
    Assert.assertTrue(map.containsKey("id"));
    Assert.assertTrue(map.containsKey("jdbcUrl"));
    Assert.assertTrue(map.containsKey("databaseName"));
    Assert.assertTrue(map.containsKey("serviceType"));
    Assert.assertTrue(map.containsKey("charts"));
}
Also used : DataSourceChartGroup(com.navercorp.pinpoint.web.vo.stat.chart.DataSourceChartGroup) SampledDataSource(com.navercorp.pinpoint.web.vo.stat.SampledDataSource) Range(com.navercorp.pinpoint.web.vo.Range) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) Map(java.util.Map) Test(org.junit.Test)

Example 59 with Range

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

the class LinkSerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    AgentHistogramList list = new AgentHistogramList();
    AgentHistogram histogram = new AgentHistogram(new Application("test", ServiceType.STAND_ALONE));
    list.addAgentHistogram(histogram);
    Node node1 = new Node(new Application("test1", ServiceType.STAND_ALONE));
    Node node2 = new Node(new Application("test1", ServiceType.STAND_ALONE));
    Link link = new Link(CreateType.Source, node1, node2, new Range(0, 1));
    ObjectWriter objectWriter = MAPPER.writerWithDefaultPrettyPrinter();
    String s = objectWriter.writeValueAsString(link);
    logger.debug(s);
}
Also used : Node(com.navercorp.pinpoint.web.applicationmap.Node) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) AgentHistogramList(com.navercorp.pinpoint.web.applicationmap.rawdata.AgentHistogramList) Range(com.navercorp.pinpoint.web.vo.Range) Application(com.navercorp.pinpoint.web.vo.Application) Link(com.navercorp.pinpoint.web.applicationmap.Link) AgentHistogram(com.navercorp.pinpoint.web.applicationmap.rawdata.AgentHistogram) Test(org.junit.Test)

Example 60 with Range

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

the class AgentEventTimelineTest method multipleFilters.

@Test
public void multipleFilters() {
    // Given
    Range timelineRange = new Range(100, 200);
    List<AgentEvent> agentEvents = Arrays.asList(createAgentEvent(110, AgentEventType.AGENT_PING), createAgentEvent(120, AgentEventType.AGENT_CONNECTED), createAgentEvent(130, AgentEventType.AGENT_SHUTDOWN), createAgentEvent(140, AgentEventType.AGENT_UNEXPECTED_SHUTDOWN), createAgentEvent(150, AgentEventType.AGENT_CLOSED_BY_SERVER), createAgentEvent(160, AgentEventType.AGENT_UNEXPECTED_CLOSE_BY_SERVER), createAgentEvent(170, AgentEventType.USER_THREAD_DUMP), createAgentEvent(180, AgentEventType.OTHER));
    Set<AgentEventType> includedAgentEventTypes = new HashSet<AgentEventType>() {

        {
            add(AgentEventType.AGENT_PING);
            add(AgentEventType.AGENT_CONNECTED);
            add(AgentEventType.AGENT_SHUTDOWN);
            add(AgentEventType.AGENT_CLOSED_BY_SERVER);
        }
    };
    AgentEventFilter excludeUnexpectedEventsFilter = new AgentEventFilter.ExcludeFilter(AgentEventType.AGENT_UNEXPECTED_SHUTDOWN, AgentEventType.AGENT_UNEXPECTED_CLOSE_BY_SERVER);
    AgentEventFilter excludeUserThreadDumpFilter = new AgentEventFilter.ExcludeFilter(AgentEventType.USER_THREAD_DUMP);
    AgentEventFilter excludeOtherFilter = new AgentEventFilter.ExcludeFilter(AgentEventType.OTHER);
    // When
    AgentEventTimeline timeline = new AgentEventTimelineBuilder(timelineRange, 1).from(agentEvents).addFilter(excludeUnexpectedEventsFilter).addFilter(excludeUserThreadDumpFilter).addFilter(excludeOtherFilter).build();
    // Then
    int allEventsTotalCount = 0;
    for (AgentEventTimelineSegment segment : timeline.getTimelineSegments()) {
        AgentEventMarker marker = segment.getValue();
        allEventsTotalCount += marker.getTotalCount();
        Map<AgentEventType, Integer> eventTypeCountMap = marker.getTypeCounts();
        Assert.assertTrue(includedAgentEventTypes.containsAll(eventTypeCountMap.keySet()));
        Assert.assertFalse(eventTypeCountMap.keySet().contains(AgentEventType.AGENT_UNEXPECTED_SHUTDOWN));
        Assert.assertFalse(eventTypeCountMap.keySet().contains(AgentEventType.AGENT_UNEXPECTED_CLOSE_BY_SERVER));
        Assert.assertFalse(eventTypeCountMap.keySet().contains(AgentEventType.USER_THREAD_DUMP));
        Assert.assertFalse(eventTypeCountMap.keySet().contains(AgentEventType.OTHER));
    }
    Assert.assertEquals(allEventsTotalCount, includedAgentEventTypes.size());
}
Also used : Range(com.navercorp.pinpoint.web.vo.Range) AgentEventFilter(com.navercorp.pinpoint.web.filter.agent.AgentEventFilter) AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType) AgentEvent(com.navercorp.pinpoint.web.vo.AgentEvent) HashSet(java.util.HashSet) 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