-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-9915. [hsync] Interface to retrieve block info and finalize block in DN through ratis. #5783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7d9a538
3315a20
91a07b1
3c22927
69faf78
3085591
d073ba3
5a91a61
7a35a03
89a02ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,6 +94,7 @@ | |
| import org.apache.ratis.util.TaskQueue; | ||
| import org.apache.ratis.util.function.CheckedSupplier; | ||
| import org.apache.ratis.util.JavaUtils; | ||
| import org.jetbrains.annotations.Nullable; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
|
|
@@ -376,8 +377,20 @@ public TransactionContext startTransaction(RaftClientRequest request) | |
| ctxt.setException(ioe); | ||
| return ctxt; | ||
| } | ||
| if (proto.getCmdType() == Type.WriteChunk) { | ||
| if (proto.getCmdType() == Type.PutBlock) { | ||
| TransactionContext ctxt = rejectRequest(request, | ||
| proto.getContainerID(), proto.getPutBlock().getBlockData() | ||
| .getBlockID().getLocalID()); | ||
| if (ctxt != null) { | ||
| return ctxt; | ||
| } | ||
| } else if (proto.getCmdType() == Type.WriteChunk) { | ||
| final WriteChunkRequestProto write = proto.getWriteChunk(); | ||
| TransactionContext ctxt = rejectRequest(request, | ||
| proto.getContainerID(), write.getBlockID().getLocalID()); | ||
| if (ctxt != null) { | ||
| return ctxt; | ||
| } | ||
| // create the log entry proto | ||
| final WriteChunkRequestProto commitWriteChunkProto = | ||
| WriteChunkRequestProto.newBuilder() | ||
|
|
@@ -403,16 +416,32 @@ public TransactionContext startTransaction(RaftClientRequest request) | |
| .setStateMachineData(write.getData()) | ||
| .setLogData(commitContainerCommandProto.toByteString()) | ||
| .build(); | ||
| } else { | ||
| return TransactionContext.newBuilder() | ||
| } else if (proto.getCmdType() == Type.FinalizeBlock) { | ||
| containerController.addFinalizedBlock(proto.getContainerID(), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot add the finalize block in startTransaction, otherwise there is chance that valid write chunk or put block in applyTransaction will be failed because of this.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are rejecting request only in
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Currently finalized block is not checked in applyTransaction. Then it's fine. |
||
| proto.getFinalizeBlock().getBlockID().getLocalID()); | ||
| } | ||
| return TransactionContext.newBuilder() | ||
| .setClientRequest(request) | ||
| .setStateMachine(this) | ||
| .setServerRole(RaftPeerRole.LEADER) | ||
| .setStateMachineContext(startTime) | ||
| .setLogData(proto.toByteString()) | ||
| .build(); | ||
| } | ||
|
|
||
| @Nullable | ||
| private TransactionContext rejectRequest(RaftClientRequest request, | ||
| long containerId, long localId) { | ||
| if (containerController.isFinalizedBlockExist(containerId, localId)) { | ||
| TransactionContext ctxt = TransactionContext.newBuilder() | ||
| .setClientRequest(request) | ||
| .setStateMachine(this) | ||
| .setServerRole(RaftPeerRole.LEADER) | ||
| .setStateMachineContext(startTime) | ||
| .setLogData(proto.toByteString()) | ||
| .build(); | ||
| ctxt.setException(new IOException("Block already finalized")); | ||
| return ctxt; | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| private ByteString getStateMachineData(StateMachineLogEntryProto entryProto) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does PutBlock need change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to reject request from original client if there is any PUT block request after finalize block is called by recoverer client.