use of org.apache.ratis.proto.ExamplesProtos.FileStoreRequestProto in project incubator-ratis by apache.
the class FileStoreClient method getStreamOutput.
public DataStreamOutput getStreamOutput(String path, long dataSize, RoutingTable routingTable) {
final StreamWriteRequestProto header = StreamWriteRequestProto.newBuilder().setPath(ProtoUtils.toByteString(path)).setLength(dataSize).build();
final FileStoreRequestProto request = FileStoreRequestProto.newBuilder().setStream(header).build();
return client.getDataStreamApi().stream(request.toByteString().asReadOnlyByteBuffer(), routingTable);
}
use of org.apache.ratis.proto.ExamplesProtos.FileStoreRequestProto in project incubator-ratis by apache.
the class FileStoreClient method writeImpl.
private static <OUTPUT, THROWABLE extends Throwable> OUTPUT writeImpl(CheckedFunction<ByteString, OUTPUT, THROWABLE> sendFunction, String path, long offset, boolean close, ByteBuffer data, boolean sync) throws THROWABLE {
final WriteRequestHeaderProto.Builder header = WriteRequestHeaderProto.newBuilder().setPath(ProtoUtils.toByteString(path)).setOffset(offset).setLength(data.remaining()).setClose(close).setSync(sync);
final WriteRequestProto.Builder write = WriteRequestProto.newBuilder().setHeader(header).setData(ByteString.copyFrom(data));
final FileStoreRequestProto request = FileStoreRequestProto.newBuilder().setWrite(write).build();
return sendFunction.apply(request.toByteString());
}
use of org.apache.ratis.proto.ExamplesProtos.FileStoreRequestProto in project incubator-ratis by apache.
the class FileStoreStateMachine method startTransaction.
@Override
public TransactionContext startTransaction(RaftClientRequest request) throws IOException {
final ByteString content = request.getMessage().getContent();
final FileStoreRequestProto proto = FileStoreRequestProto.parseFrom(content);
final TransactionContext.Builder b = TransactionContext.newBuilder().setStateMachine(this).setClientRequest(request);
if (proto.getRequestCase() == FileStoreRequestProto.RequestCase.WRITE) {
final WriteRequestProto write = proto.getWrite();
final FileStoreRequestProto newProto = FileStoreRequestProto.newBuilder().setWriteHeader(write.getHeader()).build();
b.setLogData(newProto.toByteString()).setStateMachineData(write.getData());
} else {
b.setLogData(content);
}
return b.build();
}
Aggregations