cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbros...@apache.org
Subject [1/3] git commit: Don't generate compaction statistics if logging isn't enabled patch by dbrosius reviewed by jbellis for cassandra-5262
Date Fri, 15 Feb 2013 06:43:43 GMT
Don't generate compaction statistics if logging isn't enabled
patch by dbrosius reviewed by jbellis for cassandra-5262


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

Branch: refs/heads/trunk
Commit: 9828c63b49b98ef3530ef03a075208d4e40c906d
Parents: 6849942
Author: Dave Brosius <dbrosius@apache.org>
Authored: Fri Feb 15 01:25:47 2013 -0500
Committer: Dave Brosius <dbrosius@apache.org>
Committed: Fri Feb 15 01:25:47 2013 -0500

----------------------------------------------------------------------
 .../cassandra/db/compaction/CompactionTask.java    |   33 ++++++++-------
 1 files changed, 18 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/9828c63b/src/java/org/apache/cassandra/db/compaction/CompactionTask.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionTask.java b/src/java/org/apache/cassandra/db/compaction/CompactionTask.java
index 714e308..02d20cf 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionTask.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionTask.java
@@ -215,21 +215,24 @@ public class CompactionTask extends AbstractCompactionTask
                sstable.cacheKey(entry.getKey(), entry.getValue());
         }
 
-        long dTime = System.currentTimeMillis() - startTime;
-        long startsize = SSTable.getTotalBytes(toCompact);
-        long endsize = SSTable.getTotalBytes(sstables);
-        double ratio = (double)endsize / (double)startsize;
-
-        StringBuilder builder = new StringBuilder();
-        builder.append("[");
-        for (SSTableReader reader : sstables)
-            builder.append(reader.getFilename()).append(",");
-        builder.append("]");
-
-        double mbps = dTime > 0 ? (double)endsize/(1024*1024)/((double)dTime/1000) : 0;
-        logger.info(String.format("Compacted to %s.  %,d to %,d (~%d%% of original) bytes
for %,d keys at %fMB/s.  Time: %,dms.",
-                                  builder.toString(), startsize, endsize, (int) (ratio *
100), totalkeysWritten, mbps, dTime));
-        logger.debug(String.format("CF Total Bytes Compacted: %,d", CompactionTask.addToTotalBytesCompacted(endsize)));
+        if (logger.isInfoEnabled())
+        {
+            long dTime = System.currentTimeMillis() - startTime;
+            long startsize = SSTable.getTotalBytes(toCompact);
+            long endsize = SSTable.getTotalBytes(sstables);
+            double ratio = (double)endsize / (double)startsize;
+
+            StringBuilder builder = new StringBuilder();
+            builder.append("[");
+            for (SSTableReader reader : sstables)
+                builder.append(reader.getFilename()).append(",");
+            builder.append("]");
+
+            double mbps = dTime > 0 ? (double)endsize/(1024*1024)/((double)dTime/1000)
: 0;
+            logger.info(String.format("Compacted to %s.  %,d to %,d (~%d%% of original) bytes
for %,d keys at %fMB/s.  Time: %,dms.",
+                                      builder.toString(), startsize, endsize, (int) (ratio
* 100), totalkeysWritten, mbps, dTime));
+            logger.debug(String.format("CF Total Bytes Compacted: %,d", CompactionTask.addToTotalBytesCompacted(endsize)));
+        }
         return toCompact.size();
     }
 


Mime
View raw message