cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yu...@apache.org
Subject cassandra git commit: Add --hex-format option to nodetool getsstables
Date Fri, 18 Mar 2016 18:24:15 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 77b27f33e -> e24da8f7f


Add --hex-format option to nodetool getsstables

patch by Paulo Motta; reviewed by yukim for CASSANDRA-11337


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

Branch: refs/heads/trunk
Commit: e24da8f7faea0e764ab4653343085adf6edcd75f
Parents: 77b27f3
Author: Paulo Motta <pauloricardomg@gmail.com>
Authored: Fri Mar 11 12:32:15 2016 -0300
Committer: Yuki Morishita <yukim@apache.org>
Committed: Fri Mar 18 13:12:04 2016 -0500

----------------------------------------------------------------------
 CHANGES.txt                                               |  1 +
 src/java/org/apache/cassandra/db/ColumnFamilyStore.java   |  8 +++++++-
 .../org/apache/cassandra/db/ColumnFamilyStoreMBean.java   |  8 ++++++++
 src/java/org/apache/cassandra/tools/NodeProbe.java        |  4 ++--
 .../org/apache/cassandra/tools/nodetool/GetSSTables.java  | 10 ++++++++--
 5 files changed, 26 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e24da8f7/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index be9115e..ba2f25a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.6
+ * Add --hex-format option to nodetool getsstables (CASSANDRA-11337)
  * sstablemetadata should print sstable min/max token (CASSANDRA-7159)
  * Do not wrap CassandraException in TriggerExecutor (CASSANDRA-9421)
  * COPY TO should have higher double precision (CASSANDRA-11255)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e24da8f7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index a2102f4..1c46331 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1554,7 +1554,13 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
     // WARNING: this returns the set of LIVE sstables only, which may be only partially written
     public List<String> getSSTablesForKey(String key)
     {
-        DecoratedKey dk = decorateKey(metadata.getKeyValidator().fromString(key));
+        return getSSTablesForKey(key, false);
+    }
+
+    public List<String> getSSTablesForKey(String key, boolean hexFormat)
+    {
+        ByteBuffer keyBuffer = hexFormat ? ByteBufferUtil.hexToBytes(key) : metadata.getKeyValidator().fromString(key);
+        DecoratedKey dk = decorateKey(keyBuffer);
         try (OpOrder.Group op = readOrdering.start())
         {
             List<String> files = new ArrayList<>();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e24da8f7/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java b/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
index c900442..63215b4 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
@@ -124,6 +124,14 @@ public interface ColumnFamilyStoreMBean
     public List<String> getSSTablesForKey(String key);
 
     /**
+     * Returns a list of filenames that contain the given key on this node
+     * @param key
+     * @param hexFormat if key is in hex string format
+     * @return list of filenames containing the key
+     */
+    public List<String> getSSTablesForKey(String key, boolean hexFormat);
+
+    /**
      * Scan through Keyspace/ColumnFamily's data directory
      * determine which SSTables should be loaded and load them
      */

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e24da8f7/src/java/org/apache/cassandra/tools/NodeProbe.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeProbe.java b/src/java/org/apache/cassandra/tools/NodeProbe.java
index 405f70c..51fa2c1 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -692,10 +692,10 @@ public class NodeProbe implements AutoCloseable
         return ssProxy.getNaturalEndpoints(keyspace, cf, key);
     }
 
-    public List<String> getSSTables(String keyspace, String cf, String key)
+    public List<String> getSSTables(String keyspace, String cf, String key, boolean
hexFormat)
     {
         ColumnFamilyStoreMBean cfsProxy = getCfsProxy(keyspace, cf);
-        return cfsProxy.getSSTablesForKey(key);
+        return cfsProxy.getSSTablesForKey(key, hexFormat);
     }
 
     public Set<StreamState> getStreamStatus()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e24da8f7/src/java/org/apache/cassandra/tools/nodetool/GetSSTables.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/nodetool/GetSSTables.java b/src/java/org/apache/cassandra/tools/nodetool/GetSSTables.java
index 2c5d46b..849ad94 100644
--- a/src/java/org/apache/cassandra/tools/nodetool/GetSSTables.java
+++ b/src/java/org/apache/cassandra/tools/nodetool/GetSSTables.java
@@ -24,13 +24,19 @@ import io.airlift.command.Command;
 import java.util.ArrayList;
 import java.util.List;
 
+import io.airlift.command.Option;
 import org.apache.cassandra.tools.NodeProbe;
 import org.apache.cassandra.tools.NodeTool.NodeToolCmd;
 
 @Command(name = "getsstables", description = "Print the sstable filenames that own the key")
 public class GetSSTables extends NodeToolCmd
 {
-    @Arguments(usage = "<keyspace> <table> <key>", description = "The keyspace,
the table, and the key")
+    @Option(title = "hex_format",
+           name = {"-hf", "--hex-format"},
+           description = "Specify the key in hexadecimal string format")
+    private boolean hexFormat = false;
+
+    @Arguments(usage = "<keyspace> <cfname> <key>", description = "The
keyspace, the column family, and the key")
     private List<String> args = new ArrayList<>();
 
     @Override
@@ -41,7 +47,7 @@ public class GetSSTables extends NodeToolCmd
         String cf = args.get(1);
         String key = args.get(2);
 
-        List<String> sstables = probe.getSSTables(ks, cf, key);
+        List<String> sstables = probe.getSSTables(ks, cf, key, hexFormat);
         for (String sstable : sstables)
         {
             System.out.println(sstable);


Mime
View raw message