cchung100m commented on code in PR #11505:
URL: https://github.com/apache/ozone/pull/11505#discussion_r4552339550
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMRatisServerImpl.java:
##########
@@ -147,6 +150,40 @@ public static void initialize(String clusterId, String
scmId,
}
}
+ /**
+ * Fail if the SCM Ratis storage directory contains any Raft group directory.
+ * A new cluster has none, so any existing one is stale.
+ */
+ public static void verifyNoRaftGroup(ConfigurationSource conf) throws
IOException {
+ verifyNoOtherRaftGroup(conf, null);
+ }
+
+ /**
+ * Fail if the SCM Ratis storage directory contains a Raft group directory
other than the given one.
+ * SCM has a single Raft group derived from the cluster ID.
+ *
+ * @param groupId the only group allowed in the directory, or null to allow
none
+ */
+ private static void verifyNoOtherRaftGroup(ConfigurationSource conf,
RaftGroupId groupId) throws IOException {
+ final File ratisDir = new File(SCMHAUtils.getSCMRatisDirectory(conf));
+ final File[] children = ratisDir.listFiles(File::isDirectory);
+ if (children == null) {
+ return;
+ }
+ for (File child : children) {
+ final String name = child.getName();
+ try {
+ if (!RaftGroupId.valueOf(UUID.fromString(name)).equals(groupId)) {
+ throw new IOException("Found stal Raft group directory " + child + "
in the SCM Ratis storage directory "
Review Comment:
Thank you for the reminder. I have corrected the typo.
--
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]