HDDS-14748. Implement ScmGeneratedMessageCodec without reflection#9878
Open
Russole wants to merge 9 commits intoapache:masterfrom
Open
HDDS-14748. Implement ScmGeneratedMessageCodec without reflection#9878Russole wants to merge 9 commits intoapache:masterfrom
Russole wants to merge 9 commits intoapache:masterfrom
Conversation
Contributor
Author
|
Hi @szetszwo, when you have time, could you please help review this PR? Thanks! |
Contributor
Author
|
Thanks @szetszwo for the review! |
szetszwo
reviewed
Mar 7, 2026
| throw new InvalidProtocolBufferException("Message cannot be decoded: " + ex.getMessage()); | ||
| return parser.parseFrom(value.toByteArray()); | ||
| } catch (com.google.protobuf.InvalidProtocolBufferException e) { | ||
| throw new IllegalArgumentException("Message cannot be decoded", e); |
Contributor
There was a problem hiding this comment.
We should throw org.apache.ratis.thirdparty.com.google.protobuf.InvalidProtocolBufferException
Contributor
There was a problem hiding this comment.
Sorry that this comment somehow was not included preiously.
Contributor
Author
|
Thanks @szetszwo for pointing out the exception type. I’ve updated the change accordingly. |
szetszwo
reviewed
Mar 7, 2026
Comment on lines
+50
to
+61
| codecs.put(ContainerID.class, | ||
| new ScmNonShadedGeneratedMessageCodec<>(ContainerID.parser())); | ||
| codecs.put(PipelineID.class, | ||
| new ScmNonShadedGeneratedMessageCodec<>(PipelineID.parser())); | ||
| codecs.put(Pipeline.class, | ||
| new ScmNonShadedGeneratedMessageCodec<>(Pipeline.parser())); | ||
| codecs.put(ContainerInfoProto.class, | ||
| new ScmNonShadedGeneratedMessageCodec<>(ContainerInfoProto.parser())); | ||
| codecs.put(DeletedBlocksTransaction.class, | ||
| new ScmNonShadedGeneratedMessageCodec<>(DeletedBlocksTransaction.parser())); | ||
| codecs.put(DeletedBlocksTransactionSummary.class, | ||
| new ScmNonShadedGeneratedMessageCodec<>(DeletedBlocksTransactionSummary.parser())); |
Contributor
There was a problem hiding this comment.
@Russole , I forgot to say we may use the getDefaultInstance() trick;
putProto(ContainerID.getDefaultInstance());
putProto(PipelineID.getDefaultInstance());
putProto(Pipeline.getDefaultInstance());
putProto(ContainerInfoProto.getDefaultInstance());
putProto(DeletedBlocksTransaction.getDefaultInstance());
putProto(DeletedBlocksTransactionSummary.getDefaultInstance()); static <T extends Message> void putProto(T proto) {
codecs.put(proto.getClass(), new ScmNonShadedGeneratedMessageCodec<>(proto.getParserForType()));
}
Contributor
Author
|
Thanks @szetszwo for the suggestion. I've updated the implementation accordingly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
ScmNonShadedGeneratedMessageCodec<>(T.parser()), including element types used in collection parameters such asList<T>.org.apache.ratis.thirdparty.com.google.protobuf.Messagewere found.ScmGeneratedMessageCodec())is removed.ScmNonShadedGeneratedMessageCodecto support generic typeScmNonShadedGeneratedMessageCodecfor each proto class.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-14748
How was this patch tested?