use of org.apache.ratis.statemachine.impl.TransactionContextImpl 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 SMLogEntryProto log;
if (proto.getRequestCase() == FileStoreRequestProto.RequestCase.WRITE) {
final WriteRequestProto write = proto.getWrite();
final FileStoreRequestProto newProto = FileStoreRequestProto.newBuilder().setWriteHeader(write.getHeader()).build();
log = SMLogEntryProto.newBuilder().setData(newProto.toByteString()).setStateMachineData(write.getData()).build();
} else {
log = SMLogEntryProto.newBuilder().setData(content).build();
}
return new TransactionContextImpl(this, request, log);
}
Aggregations