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 AgentInfoServiceImpl method getAgentStatusTimeline.
@Override
public InspectorTimeline getAgentStatusTimeline(String agentId, Range range, int... excludeAgentEventTypeCodes) {
Assert.notNull(agentId, "agentId must not be null");
Assert.notNull(range, "range must not be null");
AgentStatus initialStatus = getAgentStatus(agentId, range.getFrom());
List<AgentEvent> agentEvents = agentEventService.getAgentEvents(agentId, range);
AgentStatusTimelineBuilder agentStatusTimelinebuilder = new AgentStatusTimelineBuilder(range, initialStatus);
agentStatusTimelinebuilder.from(agentEvents);
AgentStatusTimeline agentStatusTimeline = agentStatusTimelinebuilder.build();
AgentEventTimelineBuilder agentEventTimelineBuilder = new AgentEventTimelineBuilder(range);
agentEventTimelineBuilder.from(agentEvents);
agentEventTimelineBuilder.addFilter(new AgentEventFilter.ExcludeFilter(excludeAgentEventTypeCodes));
AgentEventTimeline agentEventTimeline = agentEventTimelineBuilder.build();
return new InspectorTimeline(agentStatusTimeline, agentEventTimeline);
}
use of com.navercorp.pinpoint.web.vo.AgentStatus in project pinpoint by naver.
the class AgentInfoServiceImpl method getRecentAgentsByApplicationName.
@Override
public Set<AgentInfo> getRecentAgentsByApplicationName(String applicationName, long timestamp, long timeDiff) {
if (timeDiff > timestamp) {
throw new IllegalArgumentException("timeDiff must not be greater than timestamp");
}
Set<AgentInfo> unfilteredAgentInfos = this.getAgentsByApplicationName(applicationName, timestamp);
final long eventTimestampFloor = timestamp - timeDiff;
Set<AgentInfo> filteredAgentInfos = new HashSet<>();
for (AgentInfo agentInfo : unfilteredAgentInfos) {
AgentStatus agentStatus = agentInfo.getStatus();
if (AgentLifeCycleState.UNKNOWN == agentStatus.getState() || eventTimestampFloor <= agentStatus.getEventTimestamp()) {
filteredAgentInfos.add(agentInfo);
}
}
return filteredAgentInfos;
}
use of com.navercorp.pinpoint.web.vo.AgentStatus in project pinpoint by naver.
the class AgentInfoSerializer method serialize.
@Override
public void serialize(AgentInfo agentInfo, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
jgen.writeStartObject();
jgen.writeStringField("applicationName", agentInfo.getApplicationName());
jgen.writeStringField("agentId", agentInfo.getAgentId());
jgen.writeNumberField("startTimestamp", agentInfo.getStartTimestamp());
jgen.writeStringField("hostName", agentInfo.getHostName());
jgen.writeStringField("ip", agentInfo.getIp());
jgen.writeStringField("ports", agentInfo.getPorts());
final ServiceType serviceType = serviceTypeRegistryService.findServiceType(agentInfo.getServiceTypeCode());
jgen.writeStringField("serviceType", serviceType.getDesc());
jgen.writeNumberField("pid", agentInfo.getPid());
jgen.writeStringField("vmVersion", agentInfo.getVmVersion());
jgen.writeStringField("agentVersion", agentInfo.getAgentVersion());
jgen.writeObjectField("serverMetaData", agentInfo.getServerMetaData());
jgen.writeObjectField("jvmInfo", agentInfo.getJvmInfo());
AgentStatus status = agentInfo.getStatus();
if (status != null) {
jgen.writeObjectField("status", status);
}
jgen.writeNumberField("initialStartTimestamp", agentInfo.getInitialStartTimestamp());
if (matcherGroupList != null) {
jgen.writeFieldName("linkList");
jgen.writeStartArray();
for (MatcherGroup matcherGroup : matcherGroupList) {
if (matcherGroup.ismatchingType(agentInfo)) {
LinkInfo linkInfo = matcherGroup.makeLinkInfo(agentInfo);
jgen.writeStartObject();
jgen.writeStringField("linkName", linkInfo.getLinkName());
jgen.writeStringField("linkURL", linkInfo.getLinkUrl());
jgen.writeStringField("linkType", linkInfo.getLinktype());
jgen.writeEndObject();
}
}
jgen.writeEndArray();
}
jgen.writeEndObject();
}
use of com.navercorp.pinpoint.web.vo.AgentStatus in project pinpoint by naver.
the class HbaseAgentLifeCycleDaoTest method agentInfo_should_be_populated_appropriately_if_status_is_known.
@Test
public void agentInfo_should_be_populated_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
AgentInfo givenAgentInfo = new AgentInfo();
givenAgentInfo.setAgentId(expectedAgentId);
givenAgentInfo.setStartTimestamp(expectedTimestamp);
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());
}
Aggregations