public int readBulk()

in ratis-logservice/src/main/java/org/apache/ratis/logservice/impl/LogReaderImpl.java [163:189]


  public int readBulk(ByteBuffer[] buffers) throws IOException {
    Preconditions.checkNotNull(buffers, "list of buffers is NULL" );
    Preconditions.checkArgument(buffers.length > 0, "list of buffers is empty");

    try {
      RaftClientReply reply = raftClient.io().sendReadOnly(Message.valueOf(LogServiceProtoUtil
          .toReadLogRequestProto(parent.getName(), currentRecordId, buffers.length).toByteString()));
      if (reply.getException() != null) {
        throw new IOException(reply.getException());
      }

      ReadLogReplyProto proto = ReadLogReplyProto.parseFrom(reply.getMessage().getContent());
      if (proto.hasException()) {
        LogServiceException e = proto.getException();
        throw new IOException(e.getErrorMsg());
      }
      // TODO correct current record
      int n = proto.getLogRecordCount();
      currentRecordId += n;
      for (int i = 0; i < n; i++) {
        buffers[i] = ByteBuffer.wrap(proto.getLogRecord(i).toByteArray());
      }
      return n;
    } catch (Exception e) {
      throw new IOException(e);
    }
  }