hanishakoneru commented on a change in pull request #1688:
URL: https://github.com/apache/ozone/pull/1688#discussion_r543736892



##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
##########
@@ -464,16 +465,33 @@ private OzoneManager(OzoneConfiguration conf) throws 
IOException,
             " must be defined.");
       }
       OmUtils.createOMDir(omRatisDirectory);
+
       // Create Ratis snapshot dir
       omRatisSnapshotDir = OmUtils.createOMDir(
           OzoneManagerRatisServer.getOMRatisSnapshotDirectory(configuration));
 
+      // Before starting ratis server check, if previous installation has
+      // snapshot directory in Ratis storage directory if so, move it to
+      // snapshot directory.
+      File[] dirs = new File(omRatisDirectory).listFiles();
+
+      if (dirs != null) {
+        for (File dir : dirs) {
+          if (dir.isDirectory() && dir.getName().equals("snapshot")) {
+            FileUtils.moveDirectory(dir.toPath(), omRatisSnapshotDir.toPath());
+            break;

Review comment:
       Instead of listing the files and trying to find if snapshot subdir 
exists, why don't we construct the snapshot subdir path and check it that 
exists and move it.

##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
##########
@@ -464,16 +465,33 @@ private OzoneManager(OzoneConfiguration conf) throws 
IOException,
             " must be defined.");
       }
       OmUtils.createOMDir(omRatisDirectory);
+
       // Create Ratis snapshot dir
       omRatisSnapshotDir = OmUtils.createOMDir(
           OzoneManagerRatisServer.getOMRatisSnapshotDirectory(configuration));
 
+      // Before starting ratis server check, if previous installation has
+      // snapshot directory in Ratis storage directory if so, move it to
+      // snapshot directory.
+      File[] dirs = new File(omRatisDirectory).listFiles();
+
+      if (dirs != null) {
+        for (File dir : dirs) {
+          if (dir.isDirectory() && dir.getName().equals("snapshot")) {

Review comment:
       Can we define "snapshot" as a constant in OzoneConsts and use that here 
and in getOMRatisSnapshotDirectory().




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to