HDDS-14735. ComponentVersions should not be compared using int values.#9841
Conversation
All serialization and functionality remains identical
Use one method called serialize to get the int version.
* HDDS-14496-zdu: HDDS-14712. Rename DatanodeVersion to HDDSVersion (apache#9822) HDDS-14646. SCM should not close Ratis pipelines on Finalize (apache#9779)
client: CURRENT_VERSION -> CURRENT.serialize() server: CURRENT_VERSION -> SOFTWARE_VERSION
This reverts commit 89fc4ca.
* HDDS-14496-zdu: HDDS-14723. Create one common interface for LayoutFeature and ComponentVersion (apache#9832) Conflicts: hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockOutputStream.java hadoop-hdds/client/src/main/java/org/apache/hadoop/ozone/client/io/BlockInputStreamFactoryImpl.java hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/ComponentVersion.java hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HDDSVersion.java hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/upgrade/HDDSLayoutFeature.java hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/ClientVersion.java hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/OzoneManagerVersion.java hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/protocol/TestDatanodeDetails.java hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/protocol/StorageContainerLocationProtocolServerSideTranslatorPB.java hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestBlockDataStreamOutput.java hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/VersionExtractor.java hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/validation/TestVersionExtractor.java
|
There are some cases that are calling
Given the size of this change it would probably be better to address these cases in a follow-up. I filed HDDS-14753 for this task, although it is not a blocker to proceeding with implementing the new version managers. |
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/ClientVersion.java
Show resolved
Hide resolved
sodonnel
left a comment
There was a problem hiding this comment.
LGTM - I just had one question about why the latest entry is the array length minus 2, rather than 1.
|
@sodonnel I added a comment explaining the behavior, and filed HDDS-14753 to address this comment. PR should be ready for another review. |
sodonnel
left a comment
There was a problem hiding this comment.
LGTM - thanks for adding that comment. CI is green now, so go ahead and commit.
|
Thanks @sodonnel for the review. Turns out the upgrade acceptance failure was just another network issue:
|
What changes were proposed in this pull request?
The int representation of component version should only be used for serialization and should not be checked directly by callers. Direct checking is error prone for various reasons, including FUTURE_VERSION serializing to -1 and mixing up comparison operators like
<vs<=. It is also bad for readability. This PR provides utilities to make the serialized value opaque and provides a more robust comparison utility method.ComponentVersionimplementations now contain the following methods:serialize(from HDDS-14723. Create one common interface for LayoutFeature and ComponentVersion #9832): Should only be called when sending a version over the network or to diskdeserialize: Should only be called when reading a version from the network or diskisSupportedBy: Should be used to check version compatibility between client and server. This also wraps the deserialization.VersionManager#isAllowedto check against apparent version inHDDS-14732
All existing client/server version checks have been migrated to these new methods.
Additionally,
CURRENT_VERSIONhas been renamed toSOFTWARE_VERSIONinHDDSVersionandOzoneManagerVersionto reflect the terminology used in the new versioning system. For nowClientVersioncontinues to useCURRENT_VERSIONto refer to the latest version because clients are stateless and will not have apparent versions. TBD if we standardize this terminology so clients also refer to their latest version asSOFTWARE_VERSIONin the future.Some changes were generated by Cursor under my guidance and review.
What is the link to the Apache JIRA
HDDS-14735
How was this patch tested?
isSupportedByandserialize/deserializemethods added toTestComponentVersionInvariants.