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

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

/**
 * Creates a new instance.
 *
 * @param fingerprints a list of SHA1 fingerprints
 */
public FingerprintTrustManagerFactory(byte[]... fingerprints) {
    if (fingerprints == null) {
        throw new NullPointerException("fingerprints");
    }

    List<byte[]> list = new ArrayList<byte[]>(fingerprints.length);
    for (byte[] f: fingerprints) {
        if (f == null) {
            break;
        }
        if (f.length != SHA1_BYTE_LEN) {
            throw new IllegalArgumentException("malformed fingerprint: " +
                    ByteBufUtil.hexDump(Unpooled.wrappedBuffer(f)) + " (expected: SHA1)");
        }
        list.add(f.clone());
    }

    this.fingerprints = list.toArray(new byte[list.size()][]);
}
 
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
  try {
    if (logger.isLoggable(Level.FINE)) {
      Object loggedMsg = msg instanceof ByteBuf ? ByteBufUtil.hexDump((ByteBuf) msg) : msg;
      logger.log(
          Level.FINE,
          "Unexpected channelRead()->{0} reached end of pipeline {1}",
          new Object[] {loggedMsg, ctx.pipeline().names()});
    }
    exceptionCaught(
        ctx,
        Status.INTERNAL.withDescription(
            "channelRead() missed by ProtocolNegotiator handler: " + msg)
            .asRuntimeException());
  } finally {
    ReferenceCountUtil.safeRelease(msg);
  }
}
 
@Test
public void testOutBoundAndInboundSpan() throws Exception {
  TracingConfig tracingConfig =
      new TracingConfig(
          "tracingHandlerClientIntegrationTest", config().getConfig("settings.tracing"));
  val client = newClient(new FakeTracer(tracingConfig));

  val request =
      DefaultSegmentedRequest.builder()
          .method(GET)
          .path("/v1/authinit")
          .host("127.0.0.1" + ":" + server.getPort())
          .build();

  client.write(request);
  // We wait on the local future because this signals the full roundtrip between outbound and
  // return trip from the Application Handler out and then back in.
  local.get();
  assertEquals(reportedSpans.size(), 1);

  val responseHex = ByteBufUtil.hexDump(((SegmentedData) response).content());
  byte[] bytes = Hex.decodeHex(responseHex.toCharArray());
  assertEquals(expectedResponse, new String(bytes, "UTF-8"));
}
 
/**
 * Creates a new instance.
 *
 * @param fingerprints a list of SHA1 fingerprints
 */
public FingerprintTrustManagerFactory(byte[]... fingerprints) {
    if (fingerprints == null) {
        throw new NullPointerException("fingerprints");
    }

    List<byte[]> list = new ArrayList<byte[]>();
    for (byte[] f: fingerprints) {
        if (f == null) {
            break;
        }
        if (f.length != SHA1_BYTE_LEN) {
            throw new IllegalArgumentException("malformed fingerprint: " +
                    ByteBufUtil.hexDump(Unpooled.wrappedBuffer(f)) + " (expected: SHA1)");
        }
        list.add(f.clone());
    }

    this.fingerprints = list.toArray(new byte[list.size()][]);
}
 
源代码5 项目: jt808-server   文件: DarkRepulsor.java
@Override
public void write(ByteBuf buf, Property prop, Object value) {
    int before = buf.writerIndex();
    super.write(buf, prop, value);
    int after = buf.writerIndex();

    String hex = ByteBufUtil.hexDump(buf, before, after - before);
    System.out.println(prop.index() + "\t" + hex + "\t" + prop.desc() + "\t" + String.valueOf(value));
}
 
源代码6 项目: jt808-server   文件: Elucidator.java
@Override
public Object read(ByteBuf buf, Property prop, int length, PropertyDescriptor pd) {
    buf.markReaderIndex();
    String hex = ByteBufUtil.hexDump(buf.readSlice(length));
    buf.resetReaderIndex();

    Object value = super.read(buf, prop, length, pd);
    System.out.println(prop.index() + "\t" + hex + "\t" + prop.desc() + "\t" + String.valueOf(value));
    return value;
}
 
源代码7 项目: netty-4.1.22   文件: Http2FrameLogger.java
private String toString(ByteBuf buf) {
    if (!logger.isEnabled(level)) {
        return StringUtil.EMPTY_STRING;
    }

    if (level == InternalLogLevel.TRACE || buf.readableBytes() <= BUFFER_LENGTH_THRESHOLD) {
        // Log the entire buffer.
        return ByteBufUtil.hexDump(buf);
    }

    // Otherwise just log the first 64 bytes.
    int length = Math.min(buf.readableBytes(), BUFFER_LENGTH_THRESHOLD);
    return ByteBufUtil.hexDump(buf, buf.readerIndex(), length) + "...";
}
 
源代码8 项目: netty-4.1.22   文件: DefaultChannelId.java
@Override
public String asShortText() {
    String shortValue = this.shortValue;
    if (shortValue == null) {
        this.shortValue = shortValue = ByteBufUtil.hexDump(data, data.length - RANDOM_LEN, RANDOM_LEN);
    }
    return shortValue;
}
 
源代码9 项目: zuul   文件: DynamicHttp2FrameLogger.java
private String toString(ByteBuf buf) {
    if (level == InternalLogLevel.TRACE || buf.readableBytes() <= BUFFER_LENGTH_THRESHOLD) {
        // Log the entire buffer.
        return ByteBufUtil.hexDump(buf);
    }

    // Otherwise just log the first 64 bytes.
    int length = Math.min(buf.readableBytes(), BUFFER_LENGTH_THRESHOLD);
    return ByteBufUtil.hexDump(buf, buf.readerIndex(), length) + "...";
}
 
源代码10 项目: pulsar   文件: CompressorCodecTest.java
@DataProvider(name = "codec")
public Object[][] codecProvider() {
    return new Object[][] {
            { CompressionType.NONE, ByteBufUtil.hexDump(text.getBytes()) },
            { CompressionType.LZ4, lz4CompressedText },
            { CompressionType.ZLIB, zipCompressedText },
            { CompressionType.ZSTD, zstdCompressedText },
            { CompressionType.SNAPPY, snappyCompressedText }
    };
}
 
源代码11 项目: netty4.0.27Learn   文件: SctpMessage.java
@Override
public String toString() {
    if (refCnt() == 0) {
        return "SctpFrame{" +
                "streamIdentifier=" + streamIdentifier + ", protocolIdentifier=" + protocolIdentifier +
                ", data=(FREED)}";
    }
    return "SctpFrame{" +
            "streamIdentifier=" + streamIdentifier + ", protocolIdentifier=" + protocolIdentifier +
            ", data=" + ByteBufUtil.hexDump(content()) + '}';
}
 
源代码12 项目: redisson   文件: CommandAsyncService.java
private String calcSHA(String script) {
    String digest = SHA_CACHE.get(script);
    if (digest == null) {
        try {
            MessageDigest mdigest = MessageDigest.getInstance("SHA-1");
            byte[] s = mdigest.digest(script.getBytes());
            digest = ByteBufUtil.hexDump(s);
            SHA_CACHE.put(script, digest);
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
    }
    return digest;
}
 
源代码13 项目: jt808-server   文件: CoderTest.java
public static String transform(PackageData<Header> packageData) {
    ByteBuf buf = encoder.encode(packageData);
    String hex = ByteBufUtil.hexDump(buf);
    return hex;
}
 
源代码14 项目: redisson   文件: RedissonTransaction.java
protected static String generateId() {
    byte[] id = new byte[16];
    ThreadLocalRandom.current().nextBytes(id);
    return ByteBufUtil.hexDump(id);
}
 
源代码15 项目: turbo-rpc   文件: HexBenchmark.java
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public String toHexByNetty() {
	return ByteBufUtil.hexDump(bytes);
}
 
源代码16 项目: redisson   文件: RedissonExecutorService.java
protected String generateRequestId() {
    byte[] id = new byte[16];
    ThreadLocalRandom.current().nextBytes(id);
    return ByteBufUtil.hexDump(id);
}
 
private String readRemainPacket(final MySQLPacketPayload payload) {
    return ByteBufUtil.hexDump(payload.readStringFixByBytes(payload.getByteBuf().readableBytes()));
}
 
源代码18 项目: redisson   文件: LocalCacheListener.java
private RSemaphore getClearSemaphore(byte[] requestId) {
    String id = ByteBufUtil.hexDump(requestId);
    RSemaphore semaphore = new RedissonSemaphore(commandExecutor, name + ":clear:" + id);
    return semaphore;
}
 
源代码19 项目: redisson   文件: RequestId.java
@Override
public String toString() {
    return ByteBufUtil.hexDump(id);
}
 
源代码20 项目: redisson   文件: RedissonNode.java
private String generateId() {
    byte[] id = new byte[8];
    ThreadLocalRandom.current().nextBytes(id);
    return ByteBufUtil.hexDump(id);
}