Search in sources :

Example 6 with AgentLifeCycleState

use of com.navercorp.pinpoint.common.server.util.AgentLifeCycleState 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 7 with AgentLifeCycleState

use of com.navercorp.pinpoint.common.server.util.AgentLifeCycleState 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 8 with AgentLifeCycleState

use of com.navercorp.pinpoint.common.server.util.AgentLifeCycleState in project pinpoint by naver.

the class AgentLifeCycleChangeEventHandler method eventPerformed.

@Override
public void eventPerformed(PinpointServer pinpointServer, SocketStateCode stateCode) throws Exception {
    ManagedAgentLifeCycle managedAgentLifeCycle = ManagedAgentLifeCycle.getManagedAgentLifeCycleByStateCode(stateCode);
    if (managedAgentLifeCycle == STATE_NOT_MANAGED) {
        return;
    } else {
        logger.info("{} eventPerformed(). pinpointServer:{}, code:{}", this.getClass().getSimpleName(), pinpointServer, stateCode);
        long eventTimestamp = System.currentTimeMillis();
        AgentLifeCycleState agentLifeCycleState = managedAgentLifeCycle.getMappedState();
        this.agentLifeCycleHandler.handleLifeCycleEvent(pinpointServer, eventTimestamp, agentLifeCycleState, managedAgentLifeCycle.getEventCounter());
        AgentEventType agentEventType = managedAgentLifeCycle.getMappedEvent();
        this.agentEventHandler.handleEvent(pinpointServer, eventTimestamp, agentEventType);
    }
}
Also used : AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType) ManagedAgentLifeCycle(com.navercorp.pinpoint.collector.util.ManagedAgentLifeCycle) AgentLifeCycleState(com.navercorp.pinpoint.common.server.util.AgentLifeCycleState)

Example 9 with AgentLifeCycleState

use of com.navercorp.pinpoint.common.server.util.AgentLifeCycleState in project pinpoint by naver.

the class AgentLifeCycleHandlerTest method runAndVerifyAgentLifeCycle.

private void runAndVerifyAgentLifeCycle(ManagedAgentLifeCycle managedAgentLifeCycle) {
    // given
    final AgentLifeCycleState expectedLifeCycleState = managedAgentLifeCycle.getMappedState();
    final int expectedEventCounter = managedAgentLifeCycle.getEventCounter();
    final long expectedEventIdentifier = this.agentLifeCycleHandler.createEventIdentifier(TEST_SOCKET_ID, expectedEventCounter);
    ArgumentCaptor<AgentLifeCycleBo> argCaptor = ArgumentCaptor.forClass(AgentLifeCycleBo.class);
    // when
    this.agentLifeCycleHandler.handleLifeCycleEvent(this.pinpointServer, TEST_EVENT_TIMESTAMP, expectedLifeCycleState, expectedEventCounter);
    verify(this.agentLifeCycleDao, times(1)).insert(argCaptor.capture());
    // then
    AgentLifeCycleBo actualAgentLifeCycleBo = argCaptor.getValue();
    assertEquals(AgentLifeCycleBo.CURRENT_VERSION, actualAgentLifeCycleBo.getVersion());
    assertEquals(TEST_AGENT_ID, actualAgentLifeCycleBo.getAgentId());
    assertEquals(TEST_START_TIMESTAMP, actualAgentLifeCycleBo.getStartTimestamp());
    assertEquals(TEST_EVENT_TIMESTAMP, actualAgentLifeCycleBo.getEventTimestamp());
    assertEquals(expectedLifeCycleState, actualAgentLifeCycleBo.getAgentLifeCycleState());
    assertEquals(expectedEventIdentifier, actualAgentLifeCycleBo.getEventIdentifier());
}
Also used : AgentLifeCycleBo(com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo) AgentLifeCycleState(com.navercorp.pinpoint.common.server.util.AgentLifeCycleState)

Example 10 with AgentLifeCycleState

use of com.navercorp.pinpoint.common.server.util.AgentLifeCycleState in project pinpoint by naver.

the class AgentLifeCycleMapper method createAgentLifeCycleBo.

private AgentLifeCycleBo createAgentLifeCycleBo(Cell valueCell) {
    if (valueCell == null) {
        return null;
    }
    byte[] value = CellUtil.cloneValue(valueCell);
    final Buffer buffer = new FixedBuffer(value);
    final int version = buffer.readInt();
    switch(version) {
        case 0:
            final String agentId = buffer.readPrefixedString();
            final long startTimestamp = buffer.readLong();
            final long eventTimestamp = buffer.readLong();
            final long eventIdentifier = buffer.readLong();
            final AgentLifeCycleState agentLifeCycleState = AgentLifeCycleState.getStateByCode(buffer.readShort());
            final AgentLifeCycleBo agentLifeCycleBo = new AgentLifeCycleBo(agentId, startTimestamp, eventTimestamp, eventIdentifier, agentLifeCycleState);
            return agentLifeCycleBo;
        default:
            return null;
    }
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) AgentLifeCycleBo(com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo) AgentLifeCycleState(com.navercorp.pinpoint.common.server.util.AgentLifeCycleState)

Aggregations

AgentLifeCycleState (com.navercorp.pinpoint.common.server.util.AgentLifeCycleState)10 AgentLifeCycleBo (com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo)7 AgentStatus (com.navercorp.pinpoint.web.vo.AgentStatus)7 Test (org.junit.Test)7 ResultsExtractor (com.navercorp.pinpoint.common.hbase.ResultsExtractor)5 TableName (org.apache.hadoop.hbase.TableName)5 Scan (org.apache.hadoop.hbase.client.Scan)5 AgentInfo (com.navercorp.pinpoint.web.vo.AgentInfo)3 Range (com.navercorp.pinpoint.web.vo.Range)2 ManagedAgentLifeCycle (com.navercorp.pinpoint.collector.util.ManagedAgentLifeCycle)1 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)1 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)1 AgentEventType (com.navercorp.pinpoint.common.server.util.AgentEventType)1