Search in sources :

Example 1 with ByteBufReadAction

use of com.ctrip.xpipe.netty.ByteBufReadAction in project x-pipe by ctripcorp.

the class NettySlaveHandler method doChannelRead.

@Override
protected void doChannelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    ByteBuf byteBuf = (ByteBuf) msg;
    byteBufReadPolicy.read(ctx.channel(), byteBuf, new ByteBufReadAction() {

        @Override
        public void read(Channel channel, ByteBuf byteBuf) throws ByteBufReadActionException {
            try {
                redisMasterReplication.handleResponse(channel, byteBuf);
            } catch (XpipeException e) {
                throw new ByteBufReadActionException("handle:" + channel, e);
            }
        }
    });
}
Also used : ByteBufReadActionException(com.ctrip.xpipe.netty.ByteBufReadActionException) Channel(io.netty.channel.Channel) ByteBufReadAction(com.ctrip.xpipe.netty.ByteBufReadAction) ByteBuf(io.netty.buffer.ByteBuf) XpipeException(com.ctrip.xpipe.exception.XpipeException)

Example 2 with ByteBufReadAction

use of com.ctrip.xpipe.netty.ByteBufReadAction in project x-pipe by ctripcorp.

the class NettyClientHandler method channelRead.

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    ByteBuf byteBuf = (ByteBuf) msg;
    final NettyClient nettyClient = ctx.channel().attr(KEY_CLIENT).get();
    byteBufReadPolicy.read(ctx.channel(), byteBuf, new ByteBufReadAction() {

        @Override
        public void read(Channel channel, ByteBuf byteBuf) throws ByteBufReadActionException {
            nettyClient.handleResponse(channel, byteBuf);
        }
    });
    super.channelRead(ctx, msg);
}
Also used : ByteBufReadActionException(com.ctrip.xpipe.netty.ByteBufReadActionException) Channel(io.netty.channel.Channel) ByteBufReadAction(com.ctrip.xpipe.netty.ByteBufReadAction) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

ByteBufReadAction (com.ctrip.xpipe.netty.ByteBufReadAction)2 ByteBufReadActionException (com.ctrip.xpipe.netty.ByteBufReadActionException)2 ByteBuf (io.netty.buffer.ByteBuf)2 Channel (io.netty.channel.Channel)2 XpipeException (com.ctrip.xpipe.exception.XpipeException)1