public List readBulk()

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


  public List<ByteBuffer> readBulk(int numRecords) throws IOException {
    Preconditions.checkArgument(numRecords > 0, "number of records must be greater than 0");

    try {
      RaftClientReply reply = raftClient
          .io().sendReadOnly(Message.valueOf(LogServiceProtoUtil
              .toReadLogRequestProto(parent.getName(), currentRecordId, numRecords).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());
      }
      int n = proto.getLogRecordCount();

      // TODO correct current record
      currentRecordId += n;
      List<ByteBuffer> ret = new ArrayList<ByteBuffer>();
      for (int i = 0; i < n; i++) {
        ret.add(ByteBuffer.wrap(proto.getLogRecord(i).toByteArray()));
      }
      return ret;
    } catch (Exception e) {
      throw new IOException(e);
    }
  }