smiklosovic commented on code in PR #3374:
URL: https://github.com/apache/cassandra/pull/3374#discussion_r1686182378


##########
src/java/org/apache/cassandra/service/StorageService.java:
##########
@@ -2969,77 +2958,49 @@ private Keyspace getValidKeyspace(String keyspaceName)
      * Remove the snapshot with the given name from the given keyspaces.
      * If no tag is specified we will remove all snapshots.
      */
-    public void clearSnapshot(String tag, String... keyspaceNames)
+    public void clearSnapshot(String tag, String... keyspaceNames) throws 
IOException
     {
         clearSnapshot(Collections.emptyMap(), tag, keyspaceNames);
     }
 
     public void clearSnapshot(Map<String, Object> options, String tag, 
String... keyspaceNames)
     {
-        if (tag == null)
-            tag = "";
-
         if (options == null)
             options = Collections.emptyMap();
 
-        Set<String> keyspaces = new HashSet<>();
-        for (String dataDir : DatabaseDescriptor.getAllDataFileLocations())
-        {
-            for (String keyspaceDir : new File(dataDir).tryListNames())
-            {
-                // Only add a ks if it has been specified as a param, assuming 
params were actually provided.
-                if (keyspaceNames.length > 0 && 
!Arrays.asList(keyspaceNames).contains(keyspaceDir))
-                    continue;
-                keyspaces.add(keyspaceDir);
-            }
-        }
+        Set<String> keyspaces = new HashSet<>(Arrays.asList(keyspaceNames));
+        long maxCreatedAt = getMaxSnapshotCreatedAt(options);
+
+        SnapshotManager.instance.clearSnapshots(tag, keyspaces, maxCreatedAt);
 
+        if (logger.isDebugEnabled())
+            logger.debug("Cleared out snapshot directories");
+    }
+
+    private static long getMaxSnapshotCreatedAt(Map<String, Object> options)
+    {
         Object olderThan = options.get("older_than");
         Object olderThanTimestamp = options.get("older_than_timestamp");
 
-        final long clearOlderThanTimestamp;
+        long maxCreatedAt = Clock.Global.currentTimeMillis();

Review Comment:
   To be honest I think this is what Paulo did and I just took his stuff he had 
in a branch and applied it here. I need to check this ... 



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