Search in sources :

Example 1 with TransactionContextImpl

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);
}
Also used : TransactionContextImpl(org.apache.ratis.statemachine.impl.TransactionContextImpl) SMLogEntryProto(org.apache.ratis.shaded.proto.RaftProtos.SMLogEntryProto) ByteString(org.apache.ratis.shaded.com.google.protobuf.ByteString)

Aggregations

ByteString (org.apache.ratis.shaded.com.google.protobuf.ByteString)1 SMLogEntryProto (org.apache.ratis.shaded.proto.RaftProtos.SMLogEntryProto)1 TransactionContextImpl (org.apache.ratis.statemachine.impl.TransactionContextImpl)1