public ByteBuffer readNext()

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


  public ByteBuffer readNext() throws IOException {

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

      currentRecordId++;

      if (proto.getLogRecordCount() > 0) {
        return ByteBuffer.wrap(proto.getLogRecord(0).toByteArray());
      } else {
        return null;
      }
    } catch (Exception e) {
      throw new IOException(e);
    }
  }