guihecheng commented on a change in pull request #477:
URL: https://github.com/apache/ratis/pull/477#discussion_r629275270



##########
File path: 
ratis-server/src/main/java/org/apache/ratis/server/impl/ServerState.java
##########
@@ -104,17 +104,24 @@
     configurationManager = new ConfigurationManager(initialConf);
     LOG.info("{}: {}", getMemberId(), configurationManager);
 
+    boolean storageFound = false;
     List<File> directories = RaftServerConfigKeys.storageDir(prop);
     while (!directories.isEmpty()) {
       // use full uuid string to create a subdirectory
       File dir = chooseStorageDir(directories, 
group.getGroupId().getUuid().toString());
       try {
         storage = new RaftStorageImpl(dir, 
RaftServerConfigKeys.Log.corruptionPolicy(prop));
+        storageFound = true;
         break;
-      } catch (AccessDeniedException e) {
-        directories.remove(dir);
+      } catch (IOException e) {
+        directories.removeIf(d -> d.getAbsolutePath().equals(dir.getParent()));

Review comment:
       @szetszwo because the original `remove(dir)` is a BUG I think.
   Here dir points to '/data1/hdds-ratis/groupID', but I believe we want to 
iterator through all the storageDirs(/data1/hdds-ratis,/data2/hdds-ratis,...), 
and remove some 'dir' that is "BAD" which should points to '/dataX/hdds-ratis', 
not '/data1/hdds-ratis/groupID'.
   Then I use removeIf() to filter through the storageDirs and remove the exact 
storageDir that is BAD, so `dir.getParent()` 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.

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


Reply via email to