Search in sources :

Example 1 with ReadRequestProto

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

the class FileStoreStateMachine method query.

@Override
public CompletableFuture<Message> query(Message request) {
    final ReadRequestProto proto;
    try {
        proto = ReadRequestProto.parseFrom(request.getContent());
    } catch (InvalidProtocolBufferException e) {
        return FileStoreCommon.completeExceptionally("Failed to parse " + request, e);
    }
    final String path = proto.getPath().toStringUtf8();
    return files.read(path, proto.getOffset(), proto.getLength(), true).thenApply(reply -> Message.valueOf(reply.toByteString()));
}
Also used : ReadRequestProto(org.apache.ratis.proto.ExamplesProtos.ReadRequestProto) InvalidProtocolBufferException(org.apache.ratis.thirdparty.com.google.protobuf.InvalidProtocolBufferException) ByteString(org.apache.ratis.thirdparty.com.google.protobuf.ByteString)

Aggregations

ReadRequestProto (org.apache.ratis.proto.ExamplesProtos.ReadRequestProto)1 ByteString (org.apache.ratis.thirdparty.com.google.protobuf.ByteString)1 InvalidProtocolBufferException (org.apache.ratis.thirdparty.com.google.protobuf.InvalidProtocolBufferException)1