maedhroz commented on code in PR #4428:
URL: https://github.com/apache/cassandra/pull/4428#discussion_r2535862347


##########
src/java/org/apache/cassandra/db/Directories.java:
##########
@@ -727,6 +729,39 @@ public static File getSnapshotSchemaFile(File snapshotDir)
         return new File(snapshotDir, "schema.cql");
     }
 
+    @VisibleForTesting
+    public Set<File> getPendingLocations()
+    {
+        Set<File> result = new HashSet<>();
+        for (DataDirectory dataDirectory : dataDirectories.getAllDirectories())
+        {
+            for (File dir : dataPaths)
+            {
+                // Note that we must compare absolute paths (not canonical) 
here since keyspace directories might be symlinks
+                Path dirPath = dir.toAbsolute().toPath();
+                Path locationPath = 
dataDirectory.location.toAbsolute().toPath();
+                if (!dirPath.startsWith(locationPath))
+                    continue;
+                 result.add(getOrCreate(dir, PENDING_SUBDIR));
+            }
+        }
+        return result;
+    }
+
+    public File getPendingLocationForDisk(DataDirectory dataDirectory, 
TimeUUID planId)
+    {
+        for (File dir : dataPaths)
+        {
+            // Note that we must compare absolute paths (not canonical) here 
since keyspace directories might be symlinks
+            Path dirPath = dir.toAbsolute().toPath();
+            Path locationPath = dataDirectory.location.toAbsolute().toPath();
+            if (!dirPath.startsWith(locationPath))
+                continue;

Review Comment:
   The 4 lines above are duplicated in so many places in `Directories`. What 
about just adding the following to `DataDirectory`?
   
   ```
   boolean contains(File dir)
   {
       // Note that we must compare absolute paths (not canonical) here since 
keyspace directories might be symlinks
       Path dirPath = dir.toAbsolute().toPath();
       Path locationPath = location.toAbsolute().toPath();
       return dirPath.startsWith(locationPath);
   }
   ```



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

Reply via email to