Search in sources :

Example 6 with SocketStateChangeResult

use of com.navercorp.pinpoint.rpc.common.SocketStateChangeResult in project pinpoint by naver.

the class DefaultPinpointClientHandler method channelConnected.

@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
    Channel channel = ctx.getChannel();
    if ((null == channel) || (this.channel != channel)) {
        throw new IllegalArgumentException("Invalid channel variable. this.channel:" + this.channel + ", channel:" + channel + ".");
    }
    logger.info("{} channelConnected() started. channel:{}", objectUniqName, channel);
    SocketStateChangeResult stateChangeResult = state.toConnected();
    if (!stateChangeResult.isChange()) {
        throw new IllegalStateException("Invalid state:" + stateChangeResult.getCurrentState());
    }
    prepareChannel(channel);
    stateChangeResult = state.toRunWithoutHandshake();
    if (!stateChangeResult.isChange()) {
        throw new IllegalStateException("Failed to execute channelConnected() method. Error:" + stateChangeResult);
    }
    registerPing();
    Map<String, Object> handshakeData = new HashMap<String, Object>();
    handshakeData.putAll(clientFactory.getProperties());
    handshakeData.put("socketId", socketId);
    if (localClusterOption.isEnable()) {
        handshakeData.put("cluster", localClusterOption.getProperties());
    }
    handshaker.handshakeStart(channel, handshakeData);
    connectFuture.setResult(Result.SUCCESS);
    logger.info("{} channelConnected() completed.", objectUniqName);
}
Also used : HashMap(java.util.HashMap) SocketStateChangeResult(com.navercorp.pinpoint.rpc.common.SocketStateChangeResult)

Aggregations

SocketStateChangeResult (com.navercorp.pinpoint.rpc.common.SocketStateChangeResult)6 PinpointSocket (com.navercorp.pinpoint.rpc.PinpointSocket)1 HashMap (java.util.HashMap)1 ChannelFuture (org.jboss.netty.channel.ChannelFuture)1