Search in sources :

Example 11 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 12 with AgentStatus

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);
}
Also used : AgentEventFilter(com.navercorp.pinpoint.web.filter.agent.AgentEventFilter) AgentEventTimeline(com.navercorp.pinpoint.web.vo.timeline.inspector.AgentEventTimeline) AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) AgentStatusTimeline(com.navercorp.pinpoint.web.vo.timeline.inspector.AgentStatusTimeline) AgentEventTimelineBuilder(com.navercorp.pinpoint.web.vo.timeline.inspector.AgentEventTimelineBuilder) InspectorTimeline(com.navercorp.pinpoint.web.vo.timeline.inspector.InspectorTimeline) AgentEvent(com.navercorp.pinpoint.web.vo.AgentEvent) AgentStatusTimelineBuilder(com.navercorp.pinpoint.web.vo.timeline.inspector.AgentStatusTimelineBuilder)

Example 13 with AgentStatus

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;
}
Also used : AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) HashSet(java.util.HashSet)

Example 14 with AgentStatus

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();
}
Also used : AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) MatcherGroup(com.navercorp.pinpoint.web.applicationmap.link.MatcherGroup) LinkInfo(com.navercorp.pinpoint.web.applicationmap.link.LinkInfo)

Example 15 with AgentStatus

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

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