org.apache.kafka.common.utils.Utils.readBytes()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(180)

本文整理了Java中org.apache.kafka.common.utils.Utils.readBytes()方法的一些代码示例,展示了Utils.readBytes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.readBytes()方法的具体详情如下:
包路径:org.apache.kafka.common.utils.Utils
类名称:Utils
方法名:readBytes

Utils.readBytes介绍

[英]Read the given byte buffer into a Byte array
[中]将给定的字节缓冲区读入字节数组

代码示例

代码示例来源:origin: apache/kafka

/**
 * Read the given byte buffer into a Byte array
 */
public static byte[] readBytes(ByteBuffer buffer) {
  return Utils.readBytes(buffer, 0, buffer.limit());
}

代码示例来源:origin: apache/kafka

private void subTest(ByteBuffer buffer) {
  // The first byte should be 'A'
  assertEquals('A', (Utils.readBytes(buffer, 0, 1))[0]);
  // The offset is 2, so the first 2 bytes should be skipped.
  byte[] results = Utils.readBytes(buffer, 2, 3);
  assertEquals('y', results[0]);
  assertEquals(' ', results[1]);
  assertEquals('S', results[2]);
  assertEquals(3, results.length);
  // test readBytes without offset and length specified.
  results = Utils.readBytes(buffer);
  assertEquals('A', results[0]);
  assertEquals('t', results[buffer.limit() - 1]);
  assertEquals(buffer.limit(), results.length);
}

代码示例来源:origin: apache/kafka

private byte[] receiveToken() throws IOException {
  if (saslAuthenticateVersion == DISABLE_KAFKA_SASL_AUTHENTICATE_HEADER) {
    return receiveResponseOrToken();
  } else {
    SaslAuthenticateResponse response = (SaslAuthenticateResponse) receiveKafkaResponse();
    if (response != null) {
      Errors error = response.error();
      if (error != Errors.NONE) {
        setSaslState(SaslState.FAILED);
        String errMsg = response.errorMessage();
        throw errMsg == null ? error.exception() : error.exception(errMsg);
      }
      long sessionLifetimeMs = response.sessionLifetimeMs();
      if (sessionLifetimeMs > 0L)
        reauthInfo.positiveSessionLifetimeMs = sessionLifetimeMs;
      return Utils.readBytes(response.saslAuthBytes());
    } else
      return null;
  }
}

代码示例来源:origin: apache/kafka

byte[] responseToken = saslServer.evaluateResponse(Utils.readBytes(saslAuthenticateRequest.saslAuthBytes()));
if (reauthInfo.reauthenticating() && saslServer.isComplete())
  reauthInfo.ensurePrincipalUnchanged(principal());

代码示例来源:origin: org.apache.kafka/connect-api

byte[] bytes = Utils.readBytes((ByteBuffer) value);
  append(sb, bytes, embedded);
} else if (value instanceof List) {

相关文章