Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,7 @@ public TransactionContext startTransaction(
@Override
public TransactionContext preAppendTransaction(TransactionContext trx)
throws IOException {
OMRequest request = OMRatisHelper.convertByteStringToOMRequest(
trx.getStateMachineLogEntry().getLogData());
final OMRequest request = (OMRequest) trx.getStateMachineContext();
OzoneManagerProtocolProtos.Type cmdType = request.getCmdType();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these validations should be on startTransaction as well. The creation of UGI is quite expensive as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UGI is only for upgrade Prepare. Let's don't optimize it here.

OzoneManagerPrepareState prepareState = ozoneManager.getPrepareState();
Expand Down Expand Up @@ -314,7 +313,11 @@ public TransactionContext preAppendTransaction(TransactionContext trx)
@Override
public CompletableFuture<Message> applyTransaction(TransactionContext trx) {
try {
OMRequest request = OMRatisHelper.convertByteStringToOMRequest(
// For the Leader, the OMRequest is set in trx in startTransaction.
// For Followers, the OMRequest hast to be converted from the log entry.
final Object context = trx.getStateMachineContext();
final OMRequest request = context != null ? (OMRequest) context
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the followers need to deserialize. That's OK if applyTransaction on the followers does not slow the commit phase down. Is that the case?
I think applyTransaction is done after the majority commit, just wanna double check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... applyTransaction is done after the majority commit, ...

That is correct.

: OMRatisHelper.convertByteStringToOMRequest(
trx.getStateMachineLogEntry().getLogData());
long trxLogIndex = trx.getLogEntry().getIndex();
// In the current approach we have one single global thread executor.
Expand Down Expand Up @@ -554,6 +557,7 @@ private TransactionContext handleStartTransactionRequests(
.setStateMachine(this)
.setServerRole(RaftProtos.RaftPeerRole.LEADER)
.setLogData(raftClientRequest.getMessage().getContent())
.setStateMachineContext(omRequest)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ private TransactionContext mockTransactionContext(OMRequest request) {

TransactionContext mockTrx = Mockito.mock(TransactionContext.class);
when(mockTrx.getStateMachineLogEntry()).thenReturn(logEntry);
when(mockTrx.getStateMachineContext()).thenReturn(request);

return mockTrx;
}
Expand Down