Search in sources :

Example 1 with ChannelProperties

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());
}
Also used : ChannelProperties(com.navercorp.pinpoint.rpc.server.ChannelProperties) AgentPropertyChannelAdaptor(com.navercorp.pinpoint.collector.service.async.AgentPropertyChannelAdaptor) ChannelPropertiesFactory(com.navercorp.pinpoint.rpc.server.ChannelPropertiesFactory) AgentProperty(com.navercorp.pinpoint.collector.service.async.AgentProperty) AgentLifeCycleBo(com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo) AgentLifeCycleState(com.navercorp.pinpoint.common.server.util.AgentLifeCycleState)

Example 2 with ChannelProperties

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);
    }
}
Also used : ChannelProperties(com.navercorp.pinpoint.rpc.server.ChannelProperties) AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType) AgentPropertyChannelAdaptor(com.navercorp.pinpoint.collector.service.async.AgentPropertyChannelAdaptor) ManagedAgentLifeCycle(com.navercorp.pinpoint.collector.util.ManagedAgentLifeCycle) AgentProperty(com.navercorp.pinpoint.collector.service.async.AgentProperty) AgentLifeCycleState(com.navercorp.pinpoint.common.server.util.AgentLifeCycleState)

Example 3 with ChannelProperties

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);
}
Also used : ChannelProperties(com.navercorp.pinpoint.rpc.server.ChannelProperties) AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType) AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo) AgentPropertyChannelAdaptor(com.navercorp.pinpoint.collector.service.async.AgentPropertyChannelAdaptor) AgentProperty(com.navercorp.pinpoint.collector.service.async.AgentProperty) Test(org.junit.Test)

Example 4 with ChannelProperties

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);
    }
}
Also used : ChannelProperties(com.navercorp.pinpoint.rpc.server.ChannelProperties)

Aggregations

ChannelProperties (com.navercorp.pinpoint.rpc.server.ChannelProperties)4 AgentProperty (com.navercorp.pinpoint.collector.service.async.AgentProperty)3 AgentPropertyChannelAdaptor (com.navercorp.pinpoint.collector.service.async.AgentPropertyChannelAdaptor)3 AgentEventType (com.navercorp.pinpoint.common.server.util.AgentEventType)2 AgentLifeCycleState (com.navercorp.pinpoint.common.server.util.AgentLifeCycleState)2 ManagedAgentLifeCycle (com.navercorp.pinpoint.collector.util.ManagedAgentLifeCycle)1 AgentLifeCycleBo (com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo)1 AgentEventBo (com.navercorp.pinpoint.common.server.bo.event.AgentEventBo)1 ChannelPropertiesFactory (com.navercorp.pinpoint.rpc.server.ChannelPropertiesFactory)1 Test (org.junit.Test)1