Search in sources :

Example 1 with ReadReplyProto

use of org.apache.ratis.proto.ExamplesProtos.ReadReplyProto in project incubator-ratis by apache.

the class FileStore method read.

CompletableFuture<ReadReplyProto> read(String relative, long offset, long length, boolean readCommitted) {
    final Supplier<String> name = () -> "read(" + relative + ", " + offset + ", " + length + ") @" + getId();
    final CheckedSupplier<ReadReplyProto, IOException> task = LogUtils.newCheckedSupplier(LOG, () -> {
        final FileInfo info = files.get(relative);
        final ReadReplyProto.Builder reply = ReadReplyProto.newBuilder().setResolvedPath(FileStoreCommon.toByteString(info.getRelativePath())).setOffset(offset);
        final ByteString bytes = info.read(this::resolve, offset, length, readCommitted);
        return reply.setData(bytes).build();
    }, name);
    return submit(task, reader);
}
Also used : ByteString(org.apache.ratis.thirdparty.com.google.protobuf.ByteString) ReadReplyProto(org.apache.ratis.proto.ExamplesProtos.ReadReplyProto) ByteString(org.apache.ratis.thirdparty.com.google.protobuf.ByteString) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 ReadReplyProto (org.apache.ratis.proto.ExamplesProtos.ReadReplyProto)1 ByteString (org.apache.ratis.thirdparty.com.google.protobuf.ByteString)1