List of usage examples for io.netty.buffer ByteBufUtil appendPrettyHexDump
public static void appendPrettyHexDump(StringBuilder dump, ByteBuf buf)
From source file:herddb.network.netty.NettyChannel.java
License:Apache License
@Override public void sendOneWayMessage(ByteBuf message, SendResultCallback callback) { io.netty.channel.Channel _socket = this.socket; if (_socket == null || !_socket.isOpen()) { callback.messageSent(new Exception(this + " connection is closed")); return;//www . j ava 2 s. co m } if (LOGGER.isLoggable(Level.FINEST)) { StringBuilder dumper = new StringBuilder(); ByteBufUtil.appendPrettyHexDump(dumper, message); LOGGER.log(Level.FINEST, "Sending to {}: {}", new Object[] { _socket, dumper }); } _socket.writeAndFlush(message).addListener(new GenericFutureListener() { @Override public void operationComplete(Future future) throws Exception { if (future.isSuccess()) { callback.messageSent(null); } else { LOGGER.log(Level.SEVERE, this + ": error " + future.cause(), future.cause()); callback.messageSent(future.cause()); close(); } } }); unflushedWrites.incrementAndGet(); }
From source file:herddb.network.netty.ProtocolMessageDecoder.java
License:Apache License
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { ByteBuf in = (ByteBuf) msg;/*from w ww . j ava 2s . c o m*/ if (LOGGER.isLoggable(Level.FINEST)) { StringBuilder dumper = new StringBuilder(); ByteBufUtil.appendPrettyHexDump(dumper, in); LOGGER.log(Level.FINEST, "Received from {}: {}", new Object[] { ctx.channel(), dumper }); } try { Pdu pdu = PduCodec.decodePdu(in); ctx.fireChannelRead(pdu); } catch (Throwable err) { LOGGER.log(Level.SEVERE, "Error decoding PDU", err); ReferenceCountUtil.safeRelease(msg); } }