From a8b9849480d8318faad073091d15c491e6d419d8 Mon Sep 17 00:00:00 2001 From: Amnon Heiman Date: Mon, 29 Jul 2019 10:09:04 +0300 Subject: [PATCH] ColumnFamilyStore: Mbean API support the hex format param (#69) Cassandra 3.0 version of the JMX added a parameter that allows accepting the parameter as hex. This breaks the current implementation with a NoSuchMethodException. This patch adds the missing implementation. For a full support, a follow up patch in Scylla is needed, but for the current functionality it would work. After this patch usage example: nodetool getsstables keyspace1 standard1 39303138374b4d343830 Fixes #78 Signed-off-by: Amnon Heiman (cherry picked from commit ff0723abc6c2dd23313f93cd5ec396ffd731d743) --- .../apache/cassandra/db/ColumnFamilyStore.java | 17 +++++++++++++++++ .../cassandra/db/ColumnFamilyStoreMBean.java | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/src/main/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/main/java/org/apache/cassandra/db/ColumnFamilyStore.java index 72598c0..2157ade 100644 --- a/src/main/java/org/apache/cassandra/db/ColumnFamilyStore.java +++ b/src/main/java/org/apache/cassandra/db/ColumnFamilyStore.java @@ -368,6 +368,23 @@ public class ColumnFamilyStore extends MetricsMBean implements ColumnFamilyStore return client.getListStrValue("column_family/sstables/by_key/" + getCFName(), queryParams); } + /** + * 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 + */ + @Override + public List getSSTablesForKey(String key, boolean hexFormat) + { + log(" getSSTablesForKey(String key)"); + MultivaluedMap queryParams = new MultivaluedHashMap(); + queryParams.add("key", key); + if (hexFormat) { + queryParams.add("format", "hex"); + } + return client.getListStrValue("column_family/sstables/by_key/" + getCFName(), queryParams); + } /** * Scan through Keyspace/ColumnFamily's data directory determine which * SSTables should be loaded and load them diff --git a/src/main/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java b/src/main/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java index 3fd6051..eed31b7 100644 --- a/src/main/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java +++ b/src/main/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java @@ -141,6 +141,14 @@ public interface ColumnFamilyStoreMBean { */ public List 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 getSSTablesForKey(String key, boolean hexFormat); + /** * Scan through Keyspace/ColumnFamily's data directory determine which * SSTables should be loaded and load them