HDDS-6551. Introduce StatefulService in scm#3307
Merged
nandakumar131 merged 12 commits intoapache:masterfrom May 5, 2022
Merged
HDDS-6551. Introduce StatefulService in scm#3307nandakumar131 merged 12 commits intoapache:masterfrom
nandakumar131 merged 12 commits intoapache:masterfrom
Conversation
Contributor
Author
|
@nandakumar131 @lokeshj1703 can you please review? |
Contributor
nandakumar131
left a comment
There was a problem hiding this comment.
Overall the change looks good.
Comment on lines
62
to
67
| protected final Message readConfiguration(Message defaultInstanceForType) | ||
| throws IOException { | ||
| return defaultInstanceForType.getParserForType() | ||
| .parseFrom(stateManager.readConfiguration(getServiceName())); | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
Suggested change
| protected final Message readConfiguration(Message defaultInstanceForType) | |
| throws IOException { | |
| return defaultInstanceForType.getParserForType() | |
| .parseFrom(stateManager.readConfiguration(getServiceName())); | |
| } | |
| } | |
| protected final <T extends GeneratedMessage> T readConfiguration(Class<T> configType) | |
| throws IOException { | |
| try { | |
| return configType.cast(ReflectionUtil.getMethod(configType, | |
| "parseFrom", ByteString.class) | |
| .invoke(null, stateManager.readConfiguration(getServiceName()))); | |
| } catch (NoSuchMethodException | IllegalAccessException | |
| | InvocationTargetException ex) { | |
| ex.printStackTrace(); | |
| throw new InvalidProtocolBufferException( | |
| "GeneratedMessage cannot be decoded: " + ex.getMessage()); | |
| } | |
| } |
Contributor
There was a problem hiding this comment.
With this change the return type will be the exact Proto object which can be used by the service. There is no need for any type-cast by the service implementation.
| return this; | ||
| } | ||
|
|
||
| public StatefulServiceStateManager build() { |
Contributor
There was a problem hiding this comment.
Add
Preconditions.checkNotNull(statefulServiceConfig);
Preconditions.checkNotNull(transactionBuffer);
Preconditions.checkNotNull(scmRatisServer);
Contributor
Author
There was a problem hiding this comment.
Can we exclude the not null check for scmRatisServer? SCMHAInvocationHandler takes care of the null case by calling the invokeLocal method.
Contributor
Author
|
@nandakumar131 thanks for the review. Updated. |
# Conflicts: # hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java
nandakumar131
approved these changes
May 5, 2022
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?
A
StatefulServiceis anSCMServicewith an API to persist/read configuration to RocksDB and replicate it through RATIS. The configuration would be provided as a Protobuf message. This change includes an interfaceStatefulServiceStateManagerand its implementationStatefulServiceStateManagerImpl.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-6551
How was this patch tested?
Added a unit test.