Search in sources :

Example 16 with AgentStatus

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

the class HbaseAgentLifeCycleDaoTest method agentInfos_should_be_populated_accordingly_even_with_nulls.

@Test
public void agentInfos_should_be_populated_accordingly_even_with_nulls() {
    // Given
    final String expectedAgentId = "test-agent";
    final long expectedTimestamp = 1000L;
    final AgentLifeCycleState expectedAgentLifeCycleState = AgentLifeCycleState.RUNNING;
    final AgentLifeCycleBo scannedLifeCycleBo = createAgentLifeCycleBo(expectedAgentId, expectedTimestamp, expectedAgentLifeCycleState);
    when(this.hbaseOperations2.findParallel(any(TableName.class), anyListOf(Scan.class), any(ResultsExtractor.class))).thenReturn(Arrays.asList(scannedLifeCycleBo, scannedLifeCycleBo));
    AgentInfo nonNullAgentInfo = new AgentInfo();
    nonNullAgentInfo.setAgentId(expectedAgentId);
    nonNullAgentInfo.setStartTimestamp(expectedTimestamp);
    AgentInfo nullAgentInfo = null;
    List<AgentInfo> givenAgentInfos = Arrays.asList(nonNullAgentInfo, nullAgentInfo, nonNullAgentInfo, nullAgentInfo);
    // When
    this.agentLifeCycleDao.populateAgentStatuses(givenAgentInfos, expectedTimestamp);
    // Then
    Assert.assertEquals(nonNullAgentInfo, givenAgentInfos.get(0));
    Assert.assertEquals(nullAgentInfo, givenAgentInfos.get(1));
    Assert.assertEquals(nonNullAgentInfo, givenAgentInfos.get(2));
    Assert.assertEquals(nullAgentInfo, givenAgentInfos.get(3));
    AgentStatus nonNullAgentInfoStatus = nonNullAgentInfo.getStatus();
    Assert.assertEquals(expectedAgentId, nonNullAgentInfoStatus.getAgentId());
    Assert.assertEquals(expectedTimestamp, nonNullAgentInfoStatus.getEventTimestamp());
    Assert.assertEquals(expectedAgentLifeCycleState, nonNullAgentInfoStatus.getState());
}
Also used : ResultsExtractor(com.navercorp.pinpoint.common.hbase.ResultsExtractor) TableName(org.apache.hadoop.hbase.TableName) AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) Scan(org.apache.hadoop.hbase.client.Scan) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) AgentLifeCycleBo(com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo) AgentLifeCycleState(com.navercorp.pinpoint.common.server.util.AgentLifeCycleState) Test(org.junit.Test)

Example 17 with AgentStatus

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

the class HbaseAgentLifeCycleDaoTest method agentInfo_should_be_populated_as_unknown_if_status_cannot_be_found.

@Test
public void agentInfo_should_be_populated_as_unknown_if_status_cannot_be_found() {
    // Given
    final String expectedAgentId = "test-agent";
    final long expectedTimestamp = 0L;
    final AgentLifeCycleState expectedAgentLifeCycleState = AgentLifeCycleState.UNKNOWN;
    final AgentLifeCycleBo scannedLifeCycleBo = null;
    when(this.hbaseOperations2.find(any(TableName.class), any(Scan.class), any(ResultsExtractor.class))).thenReturn(scannedLifeCycleBo);
    AgentInfo givenAgentInfo = new AgentInfo();
    givenAgentInfo.setAgentId(expectedAgentId);
    givenAgentInfo.setStartTimestamp(expectedTimestamp);
    // When
    this.agentLifeCycleDao.populateAgentStatus(givenAgentInfo, expectedTimestamp);
    // Then
    AgentStatus actualAgentStatus = givenAgentInfo.getStatus();
    Assert.assertEquals(expectedAgentId, actualAgentStatus.getAgentId());
    Assert.assertEquals(expectedTimestamp, actualAgentStatus.getEventTimestamp());
    Assert.assertEquals(expectedAgentLifeCycleState, actualAgentStatus.getState());
}
Also used : ResultsExtractor(com.navercorp.pinpoint.common.hbase.ResultsExtractor) TableName(org.apache.hadoop.hbase.TableName) AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) Scan(org.apache.hadoop.hbase.client.Scan) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) AgentLifeCycleBo(com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo) AgentLifeCycleState(com.navercorp.pinpoint.common.server.util.AgentLifeCycleState) Test(org.junit.Test)

Example 18 with AgentStatus

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

the class AgentStatusTimelineTest method agentStatus.

@Test
public void agentStatus() {
    // Given
    Range timelineRange = new Range(100, 200);
    AgentLifeCycleState expectedState = AgentLifeCycleState.RUNNING;
    List<AgentStatusTimelineSegment> expectedTimelineSegments = Collections.singletonList(createSegment(100, 200, AgentState.fromAgentLifeCycleState(expectedState)));
    // When
    AgentStatus initialStatus = createAgentStatus(50, expectedState);
    AgentStatusTimeline timeline = new AgentStatusTimelineBuilder(timelineRange, initialStatus).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) AgentLifeCycleState(com.navercorp.pinpoint.common.server.util.AgentLifeCycleState) Test(org.junit.Test)

Example 19 with AgentStatus

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

the class AgentStatusTimelineTest method agentStatus_nullAgentEvents.

@Test
public void agentStatus_nullAgentEvents() {
    // Given
    Range timelineRange = new Range(100, 200);
    AgentLifeCycleState expectedState = AgentLifeCycleState.RUNNING;
    List<AgentStatusTimelineSegment> expectedTimelineSegments = Collections.singletonList(createSegment(100, 200, AgentState.fromAgentLifeCycleState(expectedState)));
    // When
    AgentStatus initialStatus = createAgentStatus(50, expectedState);
    AgentStatusTimeline timeline = new AgentStatusTimelineBuilder(timelineRange, initialStatus).from(null).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) AgentLifeCycleState(com.navercorp.pinpoint.common.server.util.AgentLifeCycleState) Test(org.junit.Test)

Example 20 with AgentStatus

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

the class AgentStatusTimelineTest method multipleLifeCycles_mixed.

@Test
public void multipleLifeCycles_mixed() {
    // Given
    Range timelineRange = new Range(100, 300);
    List<AgentStatusTimelineSegment> expectedTimelineSegments = Arrays.asList(createSegment(100, 150, AgentState.RUNNING), createSegment(150, 160, AgentState.UNKNOWN), createSegment(160, 250, AgentState.RUNNING), createSegment(250, 260, AgentState.SHUTDOWN), createSegment(260, 290, AgentState.RUNNING), createSegment(290, 300, AgentState.UNKNOWN));
    // When
    long agentA = 90;
    long agentB = 160;
    long agentC = 220;
    long agentD = 260;
    AgentStatus initialStatus = createAgentStatus(90, AgentLifeCycleState.RUNNING);
    AgentStatusTimeline timeline = new AgentStatusTimelineBuilder(timelineRange, initialStatus).from(Arrays.asList(createAgentEvent(agentA, 120, AgentEventType.AGENT_PING), createAgentEvent(agentA, 150, AgentEventType.AGENT_UNEXPECTED_CLOSE_BY_SERVER), createAgentEvent(agentB, 160, AgentEventType.AGENT_CONNECTED), createAgentEvent(agentB, 200, AgentEventType.AGENT_PING), createAgentEvent(agentC, 220, AgentEventType.AGENT_CONNECTED), createAgentEvent(agentB, 220, AgentEventType.AGENT_CLOSED_BY_SERVER), createAgentEvent(agentC, 250, AgentEventType.AGENT_SHUTDOWN), createAgentEvent(agentD, 260, AgentEventType.AGENT_CONNECTED), createAgentEvent(agentD, 290, AgentEventType.AGENT_CLOSED_BY_SERVER))).build();
    // Then
    Assert.assertEquals(expectedTimelineSegments, timeline.getTimelineSegments());
    Assert.assertTrue(timeline.isIncludeWarning());
}
Also used : AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) Range(com.navercorp.pinpoint.web.vo.Range) Test(org.junit.Test)

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