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