cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [1/3] git commit: allow sstable2json on 2i CFs patch by Michał Michalski; reviewed by jbellis for CASSANDRA-5694
Date Tue, 25 Jun 2013 01:00:48 GMT
Updated Branches:
  refs/heads/cassandra-1.2 57eb87b57 -> 07c627aae
  refs/heads/trunk ab6232aea -> a684ee095


allow sstable2json on 2i CFs
patch by Michał Michalski; reviewed by jbellis for CASSANDRA-5694


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

Branch: refs/heads/cassandra-1.2
Commit: 07c627aaed6d381aee79e2e7e388fd115e3cd410
Parents: 57eb87b
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Mon Jun 24 18:00:27 2013 -0700
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Mon Jun 24 18:00:27 2013 -0700

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../apache/cassandra/tools/SSTableExport.java   | 27 ++++++++++++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/07c627aa/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 78c630f..be0c1d0 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,6 @@
 1.2.7
  * Fix ReadResponseSerializer.serializedSize() for digest reads (CASSANDRA-5476)
+ * allow sstable2json on 2i CFs (CASSANDRA-5694)
 
 
 1.2.6

http://git-wip-us.apache.org/repos/asf/cassandra/blob/07c627aa/src/java/org/apache/cassandra/tools/SSTableExport.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/SSTableExport.java b/src/java/org/apache/cassandra/tools/SSTableExport.java
index 1d898ef..c407ca1 100644
--- a/src/java/org/apache/cassandra/tools/SSTableExport.java
+++ b/src/java/org/apache/cassandra/tools/SSTableExport.java
@@ -503,9 +503,32 @@ public class SSTableExport
 
         DatabaseDescriptor.loadSchemas();
         Descriptor descriptor = Descriptor.fromFilename(ssTableFileName);
-        if (Schema.instance.getCFMetaData(descriptor) == null)
+
+        // Start by validating keyspace name
+        if (Schema.instance.getKSMetaData(descriptor.ksname) == null)
+        {
+            System.err.println(String.format("Filename %s references to nonexistent keyspace:
%s!",
+                                             ssTableFileName, descriptor.ksname));
+            System.exit(1);
+        }
+        Table table = Table.open(descriptor.ksname);
+
+        // Make it work for indexes too - find parent cf if necessary
+        String baseName = descriptor.cfname;
+        if (descriptor.cfname.contains("."))
+        {
+            String[] parts = descriptor.cfname.split("\\.", 2);
+            baseName = parts[0];
+        }
+
+        // IllegalArgumentException will be thrown here if ks/cf pair does not exist
+        try
+        {
+            table.getColumnFamilyStore(baseName);
+        }
+        catch (IllegalArgumentException e)
         {
-            System.err.println(String.format("The provided column family is not part of this
cassandra database: keyspace = %s, column family = %s",
+            System.err.println(String.format("The provided column family is not part of this
cassandra keyspace: keyspace = %s, column family = %s",
                                              descriptor.ksname, descriptor.cfname));
             System.exit(1);
         }


Mime
View raw message