Search in sources :

Example 26 with AgentStatus

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

the class AgentStatusTimelineTest method multipleLifeCycles_noOverlap3.

@Test
public void multipleLifeCycles_noOverlap3() {
    // Given
    Range timelineRange = new Range(100, 200);
    List<AgentStatusTimelineSegment> expectedTimelineSegments = Arrays.asList(createSegment(100, 120, AgentState.SHUTDOWN), createSegment(120, 140, AgentState.RUNNING), createSegment(140, 160, AgentState.SHUTDOWN), createSegment(160, 180, AgentState.RUNNING), createSegment(180, 200, AgentState.SHUTDOWN));
    // When
    long agentA = 120;
    long agentB = 160;
    AgentStatus initialStatus = createAgentStatus(90, AgentLifeCycleState.SHUTDOWN);
    AgentStatusTimeline timeline = new AgentStatusTimelineBuilder(timelineRange, initialStatus).from(Arrays.asList(createAgentEvent(agentA, 120, AgentEventType.AGENT_CONNECTED), createAgentEvent(agentA, 140, AgentEventType.AGENT_UNEXPECTED_SHUTDOWN), createAgentEvent(agentB, 160, AgentEventType.AGENT_CONNECTED), createAgentEvent(agentB, 180, AgentEventType.AGENT_SHUTDOWN))).build();
    // Then
    Assert.assertEquals(expectedTimelineSegments, timeline.getTimelineSegments());
    Assert.assertFalse(timeline.isIncludeWarning());
}
Also used : AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) Range(com.navercorp.pinpoint.web.vo.Range) Test(org.junit.Test)

Example 27 with AgentStatus

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

the class AgentStatusTimelineTest method multipleLifeCycles_disconnected.

@Test
public void multipleLifeCycles_disconnected() {
    // Given
    Range timelineRange = new Range(100, 200);
    List<AgentStatusTimelineSegment> expectedTimelineSegments = Arrays.asList(createSegment(100, 150, AgentState.RUNNING), createSegment(150, 160, AgentState.UNKNOWN), createSegment(160, 200, AgentState.RUNNING));
    // When
    long agentA = 0;
    long agentB = 160;
    AgentStatus initialStatus = createAgentStatus(90, AgentLifeCycleState.RUNNING);
    AgentStatusTimeline timeline = new AgentStatusTimelineBuilder(timelineRange, initialStatus).from(Arrays.asList(createAgentEvent(agentA, 150, AgentEventType.AGENT_CLOSED_BY_SERVER), createAgentEvent(agentB, 160, AgentEventType.AGENT_CONNECTED), createAgentEvent(agentB, 180, AgentEventType.AGENT_PING))).build();
    // Then
    Assert.assertEquals(expectedTimelineSegments, timeline.getTimelineSegments());
    Assert.assertFalse(timeline.isIncludeWarning());
}
Also used : AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) Range(com.navercorp.pinpoint.web.vo.Range) Test(org.junit.Test)

Example 28 with AgentStatus

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

the class AgentStatusTimelineTest method singleLifeCycle_disconnected.

@Test
public void singleLifeCycle_disconnected() {
    // Given
    Range timelineRange = new Range(100, 200);
    List<AgentStatusTimelineSegment> expectedTimelineSegments = Collections.singletonList(createSegment(100, 200, AgentState.RUNNING));
    // When
    long agentA = 0;
    AgentStatus initialStatus = createAgentStatus(90, AgentLifeCycleState.RUNNING);
    AgentStatusTimeline timeline = new AgentStatusTimelineBuilder(timelineRange, initialStatus).from(Arrays.asList(createAgentEvent(agentA, 150, AgentEventType.AGENT_CLOSED_BY_SERVER), createAgentEvent(agentA, 160, AgentEventType.AGENT_CONNECTED), createAgentEvent(agentA, 180, AgentEventType.AGENT_PING))).build();
    // Then
    Assert.assertEquals(expectedTimelineSegments, timeline.getTimelineSegments());
    Assert.assertFalse(timeline.isIncludeWarning());
}
Also used : AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) Range(com.navercorp.pinpoint.web.vo.Range) Test(org.junit.Test)

Example 29 with AgentStatus

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

the class HbaseAgentLifeCycleDao method populateAgentStatuses.

@Override
public void populateAgentStatuses(Collection<AgentInfo> agentInfos, long timestamp) {
    if (CollectionUtils.isEmpty(agentInfos)) {
        return;
    }
    List<Scan> scans = new ArrayList<>(agentInfos.size());
    for (AgentInfo agentInfo : agentInfos) {
        if (agentInfo != null) {
            final String agentId = agentInfo.getAgentId();
            // startTimestamp is stored in reverse order
            final long toTimestamp = agentInfo.getStartTimestamp();
            final long fromTimestamp = toTimestamp - 1;
            scans.add(createScan(agentId, fromTimestamp, toTimestamp));
        }
    }
    List<AgentLifeCycleBo> agentLifeCycles = this.hbaseOperations2.findParallel(HBaseTables.AGENT_LIFECYCLE, scans, new MostRecentAgentLifeCycleResultsExtractor(this.agentLifeCycleMapper, timestamp));
    int idx = 0;
    for (AgentInfo agentInfo : agentInfos) {
        if (agentInfo != null) {
            AgentStatus agentStatus = createAgentStatus(agentInfo.getAgentId(), agentLifeCycles.get(idx++));
            agentInfo.setStatus(agentStatus);
        }
    }
}
Also used : AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) ArrayList(java.util.ArrayList) Scan(org.apache.hadoop.hbase.client.Scan) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) AgentLifeCycleBo(com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo)

Example 30 with AgentStatus

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

the class HbaseAgentLifeCycleDao method populateAgentStatus.

@Override
public void populateAgentStatus(AgentInfo agentInfo, long timestamp) {
    if (agentInfo == null) {
        return;
    }
    Assert.isTrue(timestamp >= 0, "timestamp must not be less than 0");
    final String agentId = agentInfo.getAgentId();
    // startTimestamp is stored in reverse order
    final long toTimestamp = agentInfo.getStartTimestamp();
    final long fromTimestamp = toTimestamp - 1;
    Scan scan = createScan(agentId, fromTimestamp, toTimestamp);
    AgentLifeCycleBo agentLifeCycleBo = this.hbaseOperations2.find(HBaseTables.AGENT_LIFECYCLE, scan, new MostRecentAgentLifeCycleResultsExtractor(this.agentLifeCycleMapper, timestamp));
    AgentStatus agentStatus = createAgentStatus(agentId, agentLifeCycleBo);
    agentInfo.setStatus(agentStatus);
}
Also used : AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) Scan(org.apache.hadoop.hbase.client.Scan) AgentLifeCycleBo(com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo)

Aggregations

AgentStatus (com.navercorp.pinpoint.web.vo.AgentStatus)30 Test (org.junit.Test)21 Range (com.navercorp.pinpoint.web.vo.Range)16 AgentLifeCycleBo (com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo)7 AgentLifeCycleState (com.navercorp.pinpoint.common.server.util.AgentLifeCycleState)7 AgentInfo (com.navercorp.pinpoint.web.vo.AgentInfo)7 Scan (org.apache.hadoop.hbase.client.Scan)7 ResultsExtractor (com.navercorp.pinpoint.common.hbase.ResultsExtractor)5 TableName (org.apache.hadoop.hbase.TableName)5 HashSet (java.util.HashSet)2 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)1 AgentTimeHistogram (com.navercorp.pinpoint.web.applicationmap.histogram.AgentTimeHistogram)1 ApplicationTimeHistogram (com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogram)1 Histogram (com.navercorp.pinpoint.web.applicationmap.histogram.Histogram)1 NodeHistogram (com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram)1 LinkInfo (com.navercorp.pinpoint.web.applicationmap.link.LinkInfo)1 MatcherGroup (com.navercorp.pinpoint.web.applicationmap.link.MatcherGroup)1 AgentHistogram (com.navercorp.pinpoint.web.applicationmap.rawdata.AgentHistogram)1 AgentEventFilter (com.navercorp.pinpoint.web.filter.agent.AgentEventFilter)1 AgentEvent (com.navercorp.pinpoint.web.vo.AgentEvent)1