cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [4/15] git commit: add time remaining estimate to nodetool compactionstats patch by Fabien Rousseau; reviewed by jbellis for CASSANDRA-4167
Date Wed, 18 Apr 2012 18:26:51 GMT
add time remaining estimate to nodetool compactionstats
patch by Fabien Rousseau; reviewed by jbellis for CASSANDRA-4167


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

Branch: refs/heads/trunk
Commit: 726f6827dfd2059a793ec433653b2fe2ddc74266
Parents: 8246493
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Wed Apr 18 13:23:17 2012 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Wed Apr 18 13:23:17 2012 -0500

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 src/java/org/apache/cassandra/tools/NodeCmd.java   |   13 +++++++++++++
 src/java/org/apache/cassandra/tools/NodeProbe.java |    5 +++++
 3 files changed, 19 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/726f6827/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 3644c33..b8de41f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -5,6 +5,7 @@ Merged from 1.0:
  * avoid streaming empty files with bulk loader if sstablewriter errors out
    (CASSANDRA-3946)
  * fix stress build (CASSANDRA-4140)
+ * add time remaining estimate to nodetool compactionstats (CASSANDRA-4167)
 
 
 1.1-rc1

http://git-wip-us.apache.org/repos/asf/cassandra/blob/726f6827/src/java/org/apache/cassandra/tools/NodeCmd.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeCmd.java b/src/java/org/apache/cassandra/tools/NodeCmd.java
index 8540deb..afebfcd 100644
--- a/src/java/org/apache/cassandra/tools/NodeCmd.java
+++ b/src/java/org/apache/cassandra/tools/NodeCmd.java
@@ -38,6 +38,7 @@ import org.apache.cassandra.concurrent.JMXEnabledThreadPoolExecutorMBean;
 import org.apache.cassandra.config.ConfigurationException;
 import org.apache.cassandra.db.ColumnFamilyStoreMBean;
 import org.apache.cassandra.db.compaction.CompactionManagerMBean;
+import org.apache.cassandra.db.compaction.OperationType;
 import org.apache.cassandra.net.MessagingServiceMBean;
 import org.apache.cassandra.thrift.InvalidRequestException;
 import org.apache.cassandra.utils.EstimatedHistogram;
@@ -446,17 +447,29 @@ public class NodeCmd
 
     public void printCompactionStats(PrintStream outs)
     {
+	int compactionThroughput = probe.getCompactionThroughput();
         CompactionManagerMBean cm = probe.getCompactionManagerProxy();
         outs.println("pending tasks: " + cm.getPendingTasks());
         if (cm.getCompactions().size() > 0)
             outs.printf("%25s%16s%16s%16s%16s%10s%n", "compaction type", "keyspace", "column
family", "bytes compacted", "bytes total", "progress");
+        long remainingBytes = 0;
         for (Map<String, String> c : cm.getCompactions())
         {
             String percentComplete = new Long(c.get("totalBytes")) == 0
                                    ? "n/a"
                                    : new DecimalFormat("0.00").format((double) new Long(c.get("bytesComplete"))
/ new Long(c.get("totalBytes")) * 100) + "%";
             outs.printf("%25s%16s%16s%16s%16s%10s%n", c.get("taskType"), c.get("keyspace"),
c.get("columnfamily"), c.get("bytesComplete"), c.get("totalBytes"), percentComplete);
+            if (c.get("taskType").equals(OperationType.COMPACTION.toString()))
+                remainingBytes += (new Long(c.get("totalBytes")) - new Long(c.get("bytesComplete")));
         }
+        long remainingTimeInSecs = compactionThroughput == 0 || remainingBytes == 0
+                        ? -1 
+                        : (remainingBytes) / (long) (1024L * 1024L * compactionThroughput);
+        String remainingTime = remainingTimeInSecs < 0 
+                        ? "n/a"
+                        : String.format("%dh%02dm%02ds", remainingTimeInSecs / 3600, (remainingTimeInSecs
% 3600) / 60, (remainingTimeInSecs % 60)); 
+
+        outs.printf("%25s%10s%n", "Active compaction remaining time : ", remainingTime);
     }
 
     public void printColumnFamilyStats(PrintStream outs)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/726f6827/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 cea2fc6..2ae6050 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -613,6 +613,11 @@ public class NodeProbe
         ssProxy.setCompactionThroughputMbPerSec(value);
     }
 
+    public int getCompactionThroughput()
+    {
+        return ssProxy.getCompactionThroughputMbPerSec();
+    }
+
     public int getExceptionCount()
     {
         return ssProxy.getExceptionCount();


Mime
View raw message