use of org.apache.ratis.proto.ExamplesProtos.WriteRequestProto 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