cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcken...@apache.org
Subject cassandra git commit: CASSANDRA-11880 Display number of tables in cfstats
Date Thu, 30 Jun 2016 17:12:32 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk c7f4600be -> 54cbdd73c


CASSANDRA-11880 Display number of tables in cfstats

Patch by gyu; reviewed by jmckenzie for CASSANDRA-11880


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

Branch: refs/heads/trunk
Commit: 54cbdd73c46f85113d947e702bec33ef43d59b8d
Parents: c7f4600
Author: Geoffrey Yu <geoffrey_yu@apple.com>
Authored: Mon May 23 15:21:38 2016 -0700
Committer: Josh McKenzie <jmckenzie@apache.org>
Committed: Thu Jun 30 13:11:39 2016 -0400

----------------------------------------------------------------------
 src/java/org/apache/cassandra/config/Schema.java            | 5 +++++
 src/java/org/apache/cassandra/service/StorageProxy.java     | 5 +++++
 .../org/apache/cassandra/service/StorageProxyMBean.java     | 2 ++
 src/java/org/apache/cassandra/tools/NodeProbe.java          | 5 +++++
 .../org/apache/cassandra/tools/nodetool/TableStats.java     | 2 +-
 .../apache/cassandra/tools/nodetool/stats/StatsHolder.java  | 9 ++++++---
 .../cassandra/tools/nodetool/stats/TableStatsPrinter.java   | 3 +++
 7 files changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/54cbdd73/src/java/org/apache/cassandra/config/Schema.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/Schema.java b/src/java/org/apache/cassandra/config/Schema.java
index ee1f137..47d8198 100644
--- a/src/java/org/apache/cassandra/config/Schema.java
+++ b/src/java/org/apache/cassandra/config/Schema.java
@@ -314,6 +314,11 @@ public class Schema
         return getCFMetaData(descriptor.ksname, descriptor.cfname);
     }
 
+    public int getNumberOfTables()
+    {
+        return cfIdMap.size();
+    }
+
     public ViewDefinition getView(String keyspaceName, String viewName)
     {
         assert keyspaceName != null;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/54cbdd73/src/java/org/apache/cassandra/service/StorageProxy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageProxy.java b/src/java/org/apache/cassandra/service/StorageProxy.java
index c88c449..6bef5fb 100644
--- a/src/java/org/apache/cassandra/service/StorageProxy.java
+++ b/src/java/org/apache/cassandra/service/StorageProxy.java
@@ -2694,4 +2694,9 @@ public class StorageProxy implements StorageProxyMBean
     public long getReadRepairRepairedBackground() {
         return ReadRepairMetrics.repairedBackground.getCount();
     }
+
+    public int getNumberOfTables()
+    {
+        return Schema.instance.getNumberOfTables();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/54cbdd73/src/java/org/apache/cassandra/service/StorageProxyMBean.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageProxyMBean.java b/src/java/org/apache/cassandra/service/StorageProxyMBean.java
index 0db0ca6..0a4ba19 100644
--- a/src/java/org/apache/cassandra/service/StorageProxyMBean.java
+++ b/src/java/org/apache/cassandra/service/StorageProxyMBean.java
@@ -61,4 +61,6 @@ public interface StorageProxyMBean
 
     /** Returns each live node's schema version */
     public Map<String, List<String>> getSchemaVersions();
+
+    public int getNumberOfTables();
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/54cbdd73/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 3bf99ef..84eeb04 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -1203,6 +1203,11 @@ public class NodeProbe implements AutoCloseable
         return ThreadPoolMetrics.getJmxThreadPools(mbeanServerConn);
     }
 
+    public int getNumberOfTables()
+    {
+        return spProxy.getNumberOfTables();
+    }
+
     /**
      * Retrieve ColumnFamily metrics
      * @param ks Keyspace for which stats are to be displayed or null for the global value

http://git-wip-us.apache.org/repos/asf/cassandra/blob/54cbdd73/src/java/org/apache/cassandra/tools/nodetool/TableStats.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/nodetool/TableStats.java b/src/java/org/apache/cassandra/tools/nodetool/TableStats.java
index ec729a5..d948be3 100644
--- a/src/java/org/apache/cassandra/tools/nodetool/TableStats.java
+++ b/src/java/org/apache/cassandra/tools/nodetool/TableStats.java
@@ -95,7 +95,7 @@ public class TableStats extends NodeToolCmd
         filter.verifyTables();
 
         // get metrics of keyspace
-        StatsHolder holder = new StatsHolder();
+        StatsHolder holder = new StatsHolder(probe.getNumberOfTables());
         for (Map.Entry<String, Collection<ColumnFamilyStoreMBean>> entry : selectedTableMbeans.asMap().entrySet())
         {
             String keyspaceName = entry.getKey();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/54cbdd73/src/java/org/apache/cassandra/tools/nodetool/stats/StatsHolder.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/nodetool/stats/StatsHolder.java b/src/java/org/apache/cassandra/tools/nodetool/stats/StatsHolder.java
index e26f3f7..28768e6 100644
--- a/src/java/org/apache/cassandra/tools/nodetool/stats/StatsHolder.java
+++ b/src/java/org/apache/cassandra/tools/nodetool/stats/StatsHolder.java
@@ -26,15 +26,18 @@ import java.util.Map;
 public class StatsHolder
 {
     public List<StatsKeyspace> keyspaces;
+    public final int numberOfTables;
 
-    public StatsHolder()
+    public StatsHolder(int numberOfTables)
     {
         keyspaces = new ArrayList<>();
+        this.numberOfTables = numberOfTables;
     }
 
-    public Map<String, HashMap<String, Object>> convert2Map()
+    public Map<String, Object> convert2Map()
     {
-        HashMap<String, HashMap<String, Object>> mpRet = new HashMap<>();
+        HashMap<String, Object> mpRet = new HashMap<>();
+        mpRet.put("total_number_of_tables", numberOfTables);
         for (StatsKeyspace keyspace : keyspaces)
         {
             // store each keyspace's metrics to map

http://git-wip-us.apache.org/repos/asf/cassandra/blob/54cbdd73/src/java/org/apache/cassandra/tools/nodetool/stats/TableStatsPrinter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/nodetool/stats/TableStatsPrinter.java b/src/java/org/apache/cassandra/tools/nodetool/stats/TableStatsPrinter.java
index a6da189..c901da7 100644
--- a/src/java/org/apache/cassandra/tools/nodetool/stats/TableStatsPrinter.java
+++ b/src/java/org/apache/cassandra/tools/nodetool/stats/TableStatsPrinter.java
@@ -59,6 +59,9 @@ public enum TableStatsPrinter
         @Override
         public void printFormat(StatsHolder data, PrintStream out)
         {
+            out.println("Total number of tables: " + data.numberOfTables);
+            out.println("----------------");
+
             List<StatsKeyspace> keyspaces = data.keyspaces;
             for (StatsKeyspace keyspace : keyspaces)
             {


Mime
View raw message