Search in sources :

Example 1 with AgentStatus

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

the class ActiveThreadCountResponseAggregator method addWebSocketSession.

@Override
public void addWebSocketSession(WebSocketSession webSocketSession) {
    if (webSocketSession == null) {
        return;
    }
    logger.info("addWebSocketSession. applicationName:{}, webSocketSession:{}", applicationName, webSocketSession);
    List<AgentInfo> agentInfoList = agentService.getRecentAgentInfoList(applicationName);
    synchronized (workerManagingLock) {
        if (isStopped) {
            return;
        }
        for (AgentInfo agentInfo : agentInfoList) {
            AgentStatus agentStatus = agentInfo.getStatus();
            if (agentStatus != null && agentStatus.getState() != AgentLifeCycleState.UNKNOWN) {
                activeWorker(agentInfo);
            } else if (agentService.isConnected(agentInfo)) {
                activeWorker(agentInfo);
            }
        }
        boolean added = webSocketSessions.add(webSocketSession);
        if (added && webSocketSessions.size() == 1) {
            workerActiveManager.startAgentCheckJob();
        }
    }
}
Also used : AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo)

Example 2 with AgentStatus

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

the class HbaseAgentLifeCycleDaoTest method status_should_be_unknown_if_status_cannot_be_found.

@Test
public void status_should_be_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);
    // When
    AgentStatus agentStatus = this.agentLifeCycleDao.getAgentStatus(expectedAgentId, expectedTimestamp);
    // Then
    Assert.assertEquals(expectedAgentId, agentStatus.getAgentId());
    Assert.assertEquals(expectedTimestamp, agentStatus.getEventTimestamp());
    Assert.assertEquals(expectedAgentLifeCycleState, agentStatus.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) AgentLifeCycleBo(com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo) AgentLifeCycleState(com.navercorp.pinpoint.common.server.util.AgentLifeCycleState) Test(org.junit.Test)

Example 3 with AgentStatus

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

the class HbaseAgentLifeCycleDaoTest method status_should_be_set_appropriately_if_status_is_known.

@Test
public void status_should_be_set_appropriately_if_status_is_known() {
    // 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.find(any(TableName.class), any(Scan.class), any(ResultsExtractor.class))).thenReturn(scannedLifeCycleBo);
    // When
    AgentStatus agentStatus = this.agentLifeCycleDao.getAgentStatus(expectedAgentId, expectedTimestamp);
    // Then
    Assert.assertEquals(expectedAgentId, agentStatus.getAgentId());
    Assert.assertEquals(expectedTimestamp, agentStatus.getEventTimestamp());
    Assert.assertEquals(expectedAgentLifeCycleState, agentStatus.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) AgentLifeCycleBo(com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo) AgentLifeCycleState(com.navercorp.pinpoint.common.server.util.AgentLifeCycleState) Test(org.junit.Test)

Example 4 with AgentStatus

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

the class AgentStatusTimelineTest method singleLifeCycle_endedBeforeTimelineEndTimestamp.

@Test
public void singleLifeCycle_endedBeforeTimelineEndTimestamp() {
    // Given
    Range timelineRange = new Range(100, 200);
    List<AgentStatusTimelineSegment> expectedTimelineSegments = Arrays.asList(createSegment(100, 180, AgentState.RUNNING), createSegment(180, 200, AgentState.SHUTDOWN));
    // When
    long agentA = 0;
    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_PING), createAgentEvent(agentA, 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 5 with AgentStatus

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

the class AgentStatusTimelineTest method singleLifeCycle_startedAfterTimelineStartTimestamp_initialStateShutdown.

@Test
public void singleLifeCycle_startedAfterTimelineStartTimestamp_initialStateShutdown() {
    // Given
    Range timelineRange = new Range(100, 200);
    List<AgentStatusTimelineSegment> expectedTimelineSegments = Arrays.asList(createSegment(100, 150, AgentState.SHUTDOWN), createSegment(150, 200, AgentState.RUNNING));
    // When
    long agentA = 150;
    AgentStatus initialStatus = createAgentStatus(50, AgentLifeCycleState.SHUTDOWN);
    AgentStatusTimeline timeline = new AgentStatusTimelineBuilder(timelineRange, initialStatus).from(Arrays.asList(createAgentEvent(agentA, 150, 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)

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