Java Code Examples for io.netty.buffer.ByteBufUtil#appendPrettyHexDump()
The following examples show how to use
io.netty.buffer.ByteBufUtil#appendPrettyHexDump() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DB2Decoder.java From vertx-sql-client with Apache License 2.0 | 6 votes |
private void decodePayload(ByteBuf payload, int payloadLength) { CommandCodec<?, ?> ctx = inflight.peek(); int startIndex = payload.readerIndex(); try { if (LOG.isDebugEnabled()) LOG.debug("<<< DECODE " + ctx + " (" + payloadLength + " bytes)"); ctx.decodePayload(payload, payloadLength); } catch (DB2Exception connex) { // A common connection error occurred, so don't bother with a hex dump and // generic error message ctx.completionHandler.handle(CommandResponse.failure(connex)); } catch (Throwable t) { int i = payload.readerIndex(); payload.readerIndex(startIndex); StringBuilder sb = new StringBuilder( "FATAL: Error parsing buffer at index " + i + " / 0x" + Integer.toHexString(i) + "\n"); ByteBufUtil.appendPrettyHexDump(sb, payload); LOG.error(sb.toString(), t); ctx.completionHandler.handle(CommandResponse.failure(t)); } finally { payload.clear(); payload.release(); } }
Example 2
Source File: ProtocolMessageDecoder.java From herddb with Apache License 2.0 | 6 votes |
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { ByteBuf in = (ByteBuf) msg; 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); } }
Example 3
Source File: TcpMessage.java From jetlinks-community with Apache License 2.0 | 5 votes |
@Override public String toString() { StringBuilder builder = new StringBuilder(); ByteBufUtil.appendPrettyHexDump(builder,payload); return builder.toString(); }
Example 4
Source File: NettyChannel.java From herddb with Apache License 2.0 | 5 votes |
@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; } 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(); }
Example 5
Source File: FrameUtil.java From rsocket-java with Apache License 2.0 | 5 votes |
public static String toString(ByteBuf frame) { FrameType frameType = FrameHeaderCodec.frameType(frame); int streamId = FrameHeaderCodec.streamId(frame); StringBuilder payload = new StringBuilder(); payload .append("\nFrame => Stream ID: ") .append(streamId) .append(" Type: ") .append(frameType) .append(" Flags: 0b") .append(Integer.toBinaryString(FrameHeaderCodec.flags(frame))) .append(" Length: " + frame.readableBytes()); if (frameType.hasInitialRequestN()) { payload.append(" InitialRequestN: ").append(RequestStreamFrameCodec.initialRequestN(frame)); } if (frameType == FrameType.REQUEST_N) { payload.append(" RequestN: ").append(RequestNFrameCodec.requestN(frame)); } if (FrameHeaderCodec.hasMetadata(frame)) { payload.append("\nMetadata:\n"); ByteBufUtil.appendPrettyHexDump(payload, getMetadata(frame, frameType)); } payload.append("\nData:\n"); ByteBufUtil.appendPrettyHexDump(payload, getData(frame, frameType)); return payload.toString(); }