io.netty.buffer.ByteBufUtil#appendPrettyHexDump ( )源码实例Demo

下面列出了io.netty.buffer.ByteBufUtil#appendPrettyHexDump ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: vertx-sql-client   文件: DB2Decoder.java
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();
  }
}
 
源代码2 项目: herddb   文件: ProtocolMessageDecoder.java
@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);
    }

}
 
源代码3 项目: jetlinks-community   文件: TcpMessage.java
@Override
public String toString() {
    StringBuilder builder = new StringBuilder();

    ByteBufUtil.appendPrettyHexDump(builder,payload);

    return builder.toString();
}
 
源代码4 项目: herddb   文件: NettyChannel.java
@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();
}
 
源代码5 项目: rsocket-java   文件: FrameUtil.java
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();
}