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();
}
}
}
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());
}
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());
}
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());
}
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());
}
Aggregations