errose28 commented on code in PR #10098:
URL: https://github.com/apache/ozone/pull/10098#discussion_r3148564907
##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/upgrade/HDDSVersionManager.java:
##########
@@ -20,29 +20,45 @@
import java.io.IOException;
import org.apache.hadoop.hdds.ComponentVersion;
import org.apache.hadoop.hdds.HDDSVersion;
+import org.apache.hadoop.ozone.common.Storage;
import org.apache.hadoop.ozone.upgrade.ComponentVersionManager;
+import org.apache.hadoop.ozone.upgrade.UpgradeException;
/**
* Component version manager for HDDS (Datanodes and SCM).
*/
public class HDDSVersionManager extends ComponentVersionManager {
- public HDDSVersionManager(int serializedApparentVersion) throws IOException {
- super(computeApparentVersion(serializedApparentVersion),
HDDSVersion.SOFTWARE_VERSION);
+ public HDDSVersionManager(Storage storage) throws IOException {
+ super(storage, computeApparentVersion(storage.getApparentVersion()),
HDDSVersion.SOFTWARE_VERSION);
}
/**
- * If the apparent version stored on the disk is >= 100, it indicates the
component has been finalized for the
- * ZDU feature, and the apparent version corresponds to a version in {@link
HDDSVersion}.
- * If the apparent version stored on the disk is < 100, it indicates the
component is not yet finalized for the
- * ZDU feature, and the apparent version corresponds to a version in {@link
HDDSLayoutFeature}.
+ * If the apparent version stored on the disk is >= {@link
HDDSVersion#ZDU} serialized, the apparent version is
+ * resolved via {@link HDDSVersion#deserialize(int)}. Values with no
matching {@link HDDSVersion} fail startup with
+ * the persisted integer in the exception message.
+ * If the value is below that threshold, the apparent version is resolved as
a {@link HDDSLayoutFeature}. Integers in
+ * the gap between the largest {@link HDDSLayoutFeature} and ZDU are not
valid legacy layout values; startup fails
+ * with the persisted integer in the exception message.
*/
- private static ComponentVersion computeApparentVersion(int
serializedApparentVersion) {
- if (serializedApparentVersion < HDDSVersion.ZDU.serialize()) {
- return HDDSLayoutFeature.deserialize(serializedApparentVersion);
+ private static ComponentVersion computeApparentVersion(int
serializedApparentVersion) throws IOException {
+ if (serializedApparentVersion >= HDDSVersion.ZDU.serialize()) {
+ HDDSVersion fromHdds =
HDDSVersion.deserialize(serializedApparentVersion);
+ if (fromHdds != HDDSVersion.FUTURE_VERSION) {
+ return fromHdds;
+ }
} else {
- return HDDSVersion.deserialize(serializedApparentVersion);
+ ComponentVersion fromLayout =
HDDSLayoutFeature.deserialize(serializedApparentVersion);
+ if (fromLayout != null) {
+ return fromLayout;
+ }
}
+ throw new IOException("Initialization failed. Disk contains unknown
apparent version " + serializedApparentVersion +
+ " for software version " + HDDSVersion.SOFTWARE_VERSION + ". Make sure
this component was not downgraded" +
+ " after finalization");
}
- // TODO HDDS-14826: Register upgrade actions based on annotations
+ @Override
+ protected void runUpgradeAction(ComponentVersion componentVersion) throws
UpgradeException {
+ // TODO HDDS-14826: Register upgrade actions based on annotations
Review Comment:
Thanks, will update this in the next PR. I actually haven't made the Jiras
for the HDDS updates yet.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]