ChenSammi commented on code in PR #5163:
URL: https://github.com/apache/ozone/pull/5163#discussion_r1309700872
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SequenceIdGenerator.java:
##########
@@ -393,20 +398,35 @@ public static void upgradeToSequenceId(SCMMetadataStore
scmMetadataStore)
CONTAINER_ID, sequenceIdTable.get(CONTAINER_ID));
}
- // upgrade root certificate ID
- if (sequenceIdTable.get(ROOT_CERTIFICATE_ID) == null) {
- long largestRootCertId = BigInteger.ONE.longValueExact();
+ upgradeToCertificateSequenceId(scmMetadataStore, false);
+ }
+
+ public static void upgradeToCertificateSequenceId(
+ SCMMetadataStore scmMetadataStore, boolean force) throws IOException {
+ Table<String, Long> sequenceIdTable =
scmMetadataStore.getSequenceIdTable();
+
+ // upgrade certificate ID table
+ if (sequenceIdTable.get(CERTIFICATE_ID) == null || force) {
+ // Start from ID 2.
+ // ID 1 - root certificate, ID 2 - first SCM certificate.
+ long largestCertId = BigInteger.ONE.add(BigInteger.ONE).longValueExact();
Review Comment:
Directly using 2L is not a recommended style. It's better to define a
constant variable for 2L. And I don't want to introduce a new constant variable
for that, that's why BigInteger.ONE is leveraged here.
--
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]