cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [3/6] git commit: Allow deleting snapshots from dropped keyspaces patch by Lyuben Todorov; reviewed by Nick Bailey for CASSANDRA-6281
Date Fri, 21 Mar 2014 18:18:37 GMT
Allow deleting snapshots from dropped keyspaces
patch by Lyuben Todorov; reviewed by Nick Bailey for CASSANDRA-6281


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/6b6139cc
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/6b6139cc
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/6b6139cc

Branch: refs/heads/trunk
Commit: 6b6139cc8bf903f76dfc422d1f45a800a84b9000
Parents: c843b6b
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Fri Mar 21 13:17:33 2014 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Fri Mar 21 13:17:33 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 src/java/org/apache/cassandra/db/Keyspace.java  |  4 ++--
 .../cassandra/service/SnapshotVerbHandler.java  |  4 +++-
 .../cassandra/service/StorageService.java       | 23 ++++++++++----------
 4 files changed, 17 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6b6139cc/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index c5f2666..c89ae51 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.7
+ * Allow deleting snapshots from dropped keyspaces (CASSANDRA-6821)
  * Add uuid() function (CASSANDRA-6473)
  * Omit tombstones from schema digests (CASSANDRA-6862)
  * Include correct consistencyLevel in LWT timeout (CASSANDRA-6884)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6b6139cc/src/java/org/apache/cassandra/db/Keyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Keyspace.java b/src/java/org/apache/cassandra/db/Keyspace.java
index f5369f9..714956a 100644
--- a/src/java/org/apache/cassandra/db/Keyspace.java
+++ b/src/java/org/apache/cassandra/db/Keyspace.java
@@ -237,9 +237,9 @@ public class Keyspace
      * @param snapshotName the user supplied snapshot name. It empty or null,
      *                     all the snapshots will be cleaned
      */
-    public void clearSnapshot(String snapshotName)
+    public static void clearSnapshot(String snapshotName, String keyspace)
     {
-        List<File> snapshotDirs = Directories.getKSChildDirectories(getName());
+        List<File> snapshotDirs = Directories.getKSChildDirectories(keyspace);
         Directories.clearSnapshot(snapshotName, snapshotDirs);
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6b6139cc/src/java/org/apache/cassandra/service/SnapshotVerbHandler.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/SnapshotVerbHandler.java b/src/java/org/apache/cassandra/service/SnapshotVerbHandler.java
index 2d393cf..a997533 100644
--- a/src/java/org/apache/cassandra/service/SnapshotVerbHandler.java
+++ b/src/java/org/apache/cassandra/service/SnapshotVerbHandler.java
@@ -35,7 +35,9 @@ public class SnapshotVerbHandler implements IVerbHandler<SnapshotCommand>
     {
         SnapshotCommand command = message.payload;
         if (command.clear_snapshot)
-            Keyspace.open(command.keyspace).clearSnapshot(command.snapshot_name);
+        {
+            Keyspace.clearSnapshot(command.snapshot_name, command.keyspace);
+        }
         else
             Keyspace.open(command.keyspace).getColumnFamilyStore(command.column_family).snapshot(command.snapshot_name);
         logger.debug("Enqueuing response to snapshot request {} to {}", command.snapshot_name,
message.from);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6b6139cc/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index b66873c..42a58b0 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -2294,21 +2294,20 @@ public class StorageService extends NotificationBroadcasterSupport
implements IE
         if(tag == null)
             tag = "";
 
-        Iterable<Keyspace> keyspaces;
-        if (keyspaceNames.length == 0)
-        {
-            keyspaces = Keyspace.all();
-        }
-        else
+        Set<String> keyspaces = new HashSet<>();
+        for (String dataDir : DatabaseDescriptor.getAllDataFileLocations())
         {
-            ArrayList<Keyspace> tempKeyspaces = new ArrayList<Keyspace>(keyspaceNames.length);
-            for(String keyspaceName : keyspaceNames)
-                tempKeyspaces.add(getValidKeyspace(keyspaceName));
-            keyspaces = tempKeyspaces;
+            for(String keyspaceDir : new File(dataDir).list())
+            {
+                // 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);
+            }
         }
 
-        for (Keyspace keyspace : keyspaces)
-            keyspace.clearSnapshot(tag);
+        for (String keyspace : keyspaces)
+            Keyspace.clearSnapshot(tag, keyspace);
 
         if (logger.isDebugEnabled())
             logger.debug("Cleared out snapshot directories");


Mime
View raw message