use of com.navercorp.pinpoint.rpc.server.ChannelProperties in project pinpoint by naver.
the class AgentLifeCycleAsyncTaskServiceTest method runAndVerifyAgentLifeCycle.
private void runAndVerifyAgentLifeCycle(ManagedAgentLifeCycle managedAgentLifeCycle) {
// given
final AgentLifeCycleState expectedLifeCycleState = managedAgentLifeCycle.getMappedState();
final int expectedEventCounter = managedAgentLifeCycle.getEventCounter();
final long expectedEventIdentifier = createEventIdentifier(TEST_SOCKET_ID, expectedEventCounter);
ArgumentCaptor<AgentLifeCycleBo> argCaptor = ArgumentCaptor.forClass(AgentLifeCycleBo.class);
// when
ChannelPropertiesFactory channelPropertiesFactory = new ChannelPropertiesFactory();
ChannelProperties channelProperties = channelPropertiesFactory.newChannelProperties(TEST_CHANNEL_PROPERTIES);
AgentProperty agentProperty = new AgentPropertyChannelAdaptor(channelProperties);
long eventIdentifier = AgentLifeCycleAsyncTaskService.createEventIdentifier(TEST_SOCKET_ID, expectedEventCounter);
this.agentLifeCycleAsyncTaskService.handleLifeCycleEvent(agentProperty, TEST_EVENT_TIMESTAMP, expectedLifeCycleState, eventIdentifier);
verify(this.agentLifeCycleService, 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.rpc.server.ChannelProperties in project pinpoint by naver.
the class AgentLifeCycleChangeEventHandler method stateUpdated.
@Override
public void stateUpdated(PinpointServer pinpointServer, SocketStateCode updatedStateCode) {
ManagedAgentLifeCycle managedAgentLifeCycle = ManagedAgentLifeCycle.getManagedAgentLifeCycleByStateCode(updatedStateCode);
if (managedAgentLifeCycle == STATE_NOT_MANAGED) {
return;
} else {
logger.info("stateUpdated(). pinpointServer:{}, updatedStateCode:{}", pinpointServer, updatedStateCode);
final long eventTimestamp = System.currentTimeMillis();
final Map<Object, Object> channelPropertiesMap = pinpointServer.getChannelProperties();
// nullable
final ChannelProperties channelProperties = channelPropertiesFactory.newChannelProperties(channelPropertiesMap);
if (channelProperties == null) {
logger.debug("channelProperties is null {}", pinpointServer);
return;
}
final AgentProperty agentProperty = new AgentPropertyChannelAdaptor(channelProperties);
final AgentLifeCycleState agentLifeCycleState = managedAgentLifeCycle.getMappedState();
final long eventIdentifier = AgentLifeCycleAsyncTaskService.createEventIdentifier(channelProperties.getSocketId(), managedAgentLifeCycle.getEventCounter());
this.agentLifeCycleAsyncTaskService.handleLifeCycleEvent(agentProperty, eventTimestamp, agentLifeCycleState, eventIdentifier);
AgentEventType agentEventType = managedAgentLifeCycle.getMappedEvent();
this.agentEventAsyncTaskService.handleEvent(agentProperty, eventTimestamp, agentEventType);
}
}
use of com.navercorp.pinpoint.rpc.server.ChannelProperties in project pinpoint by naver.
the class AgentEventAsyncTaskServiceTest method handler_should_handle_events_with_empty_message_body.
@Test
public void handler_should_handle_events_with_empty_message_body() {
// given
final AgentEventType expectedEventType = AgentEventType.AGENT_CONNECTED;
ArgumentCaptor<AgentEventBo> argCaptor = ArgumentCaptor.forClass(AgentEventBo.class);
// when
ChannelProperties channelProperties = channelPropertiesFactory.newChannelProperties(TEST_CHANNEL_PROPERTIES);
AgentProperty agentProperty = new AgentPropertyChannelAdaptor(channelProperties);
this.agentEventAsyncTaskService.handleEvent(agentProperty, TEST_EVENT_TIMESTAMP, expectedEventType);
verify(this.agentEventService, times(1)).insert(argCaptor.capture());
// then
AgentEventBo actualAgentEventBo = argCaptor.getValue();
assertEquals(TEST_AGENT_ID, actualAgentEventBo.getAgentId());
assertEquals(TEST_START_TIMESTAMP, actualAgentEventBo.getStartTimestamp());
assertEquals(TEST_EVENT_TIMESTAMP, actualAgentEventBo.getEventTimestamp());
assertEquals(expectedEventType, actualAgentEventBo.getEventType());
assertEquals(0, actualAgentEventBo.getEventBody().length);
}
use of com.navercorp.pinpoint.rpc.server.ChannelProperties in project pinpoint by naver.
the class ClusterPointStateChangedEventHandler method stateUpdated.
@Override
public void stateUpdated(PinpointServer pinpointServer, SocketStateCode updatedStateCode) {
logger.info("stateUpdated() started. (PinpointServer={}, updatedStateCode={})", pinpointServer, updatedStateCode);
Map<Object, Object> channelPropertiesMap = pinpointServer.getChannelProperties();
ChannelProperties channelProperties = channelPropertiesFactory.newChannelProperties(channelPropertiesMap);
// skip when applicationName and agentId is unknown
if (skipAgent(channelProperties)) {
return;
}
if (SocketStateCode.RUN_DUPLEX == updatedStateCode) {
ClusterPoint<byte[]> pinpointServerClusterPoint = newClusterPoint(pinpointServer, channelProperties);
profilerClusterManager.register(pinpointServerClusterPoint);
} else if (SocketStateCode.isClosed(updatedStateCode)) {
ClusterPoint<byte[]> pinpointServerClusterPoint = newClusterPoint(pinpointServer, channelProperties);
profilerClusterManager.unregister(pinpointServerClusterPoint);
}
}
Aggregations