cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jasobr...@apache.org
Subject cassandra git commit: Avoid unneeded memory allocations / cpu for disabled log levels
Date Sat, 02 Jun 2018 13:40:58 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 069e383f5 -> 4d8fc5b05


Avoid unneeded memory allocations / cpu for disabled log levels

patch by Benoit Wiart; reviewed by jasobrown for CASSANDRA-14488


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

Branch: refs/heads/trunk
Commit: 4d8fc5b050efaef3da818605c31e62b508425972
Parents: 069e383
Author: benoit <b.wiart@ubik-ingenierie.com>
Authored: Sat Jun 2 11:55:28 2018 +0200
Committer: Jason Brown <jasedbrown@gmail.com>
Committed: Sat Jun 2 05:58:32 2018 -0700

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../apache/cassandra/db/ColumnFamilyStore.java  |  3 +-
 .../apache/cassandra/db/ConsistencyLevel.java   |  3 +-
 src/java/org/apache/cassandra/db/Keyspace.java  |  3 +-
 src/java/org/apache/cassandra/db/Memtable.java  | 12 +++---
 .../cassandra/db/SizeEstimatesRecorder.java     |  9 +++--
 .../cassandra/db/TruncateVerbHandler.java       |  2 +-
 .../db/compaction/CompactionManager.java        |  6 ++-
 .../cassandra/db/compaction/CompactionTask.java | 39 +++++++++++---------
 .../apache/cassandra/gms/TokenSerializer.java   |  3 +-
 ...mitedLocalNodeFirstLocalBalancingPolicy.java |  3 +-
 .../io/sstable/IndexSummaryRedistribution.java  | 16 ++++----
 .../io/sstable/format/SSTableReader.java        |  6 ++-
 .../io/sstable/metadata/MetadataSerializer.java |  8 ++--
 .../net/async/InboundHandshakeHandler.java      |  3 +-
 .../apache/cassandra/repair/RepairSession.java  |  3 +-
 .../cassandra/streaming/StreamCoordinator.java  |  3 +-
 .../async/NettyStreamingMessageSender.java      | 28 +++++++++-----
 .../async/StreamingInboundHandler.java          |  7 +++-
 .../apache/cassandra/utils/JMXServerUtils.java  | 17 +++++----
 20 files changed, 106 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b94fc62..179e7bb 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.0
+ * Avoid unneeded memory allocations / cpu for disabled log levels (CASSANDRA-14488)
  * Implement virtual keyspace interface (CASSANDRA-7622)
  * nodetool import cleanup and improvements (CASSANDRA-14417)
  * Bump jackson version to >= 2.9.5 (CASSANDRA-14427)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/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 122b783..4be65c6 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -2002,7 +2002,8 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
                 ephemeralSnapshotMarker.getParentFile().mkdirs();
 
             Files.createFile(ephemeralSnapshotMarker.toPath());
-            logger.trace("Created ephemeral snapshot marker file on {}.", ephemeralSnapshotMarker.getAbsolutePath());
+            if (logger.isTraceEnabled())
+                logger.trace("Created ephemeral snapshot marker file on {}.", ephemeralSnapshotMarker.getAbsolutePath());
         }
         catch (IOException e)
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/src/java/org/apache/cassandra/db/ConsistencyLevel.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ConsistencyLevel.java b/src/java/org/apache/cassandra/db/ConsistencyLevel.java
index 840c174..8f3a51c 100644
--- a/src/java/org/apache/cassandra/db/ConsistencyLevel.java
+++ b/src/java/org/apache/cassandra/db/ConsistencyLevel.java
@@ -293,7 +293,8 @@ public enum ConsistencyLevel
                 int live = Iterables.size(liveEndpoints);
                 if (live < blockFor)
                 {
-                    logger.trace("Live nodes {} do not satisfy ConsistencyLevel ({} required)",
Iterables.toString(liveEndpoints), blockFor);
+                    if (logger.isTraceEnabled())
+                        logger.trace("Live nodes {} do not satisfy ConsistencyLevel ({} required)",
Iterables.toString(liveEndpoints), blockFor);
                     throw new UnavailableException(this, blockFor, live);
                 }
                 break;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/src/java/org/apache/cassandra/db/Keyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Keyspace.java b/src/java/org/apache/cassandra/db/Keyspace.java
index 50720f4..cb62c14 100644
--- a/src/java/org/apache/cassandra/db/Keyspace.java
+++ b/src/java/org/apache/cassandra/db/Keyspace.java
@@ -554,7 +554,8 @@ public class Keyspace
                             for (int j = 0; j < i; j++)
                                 locks[j].unlock();
 
-                            logger.trace("Could not acquire lock for {} and table {}", ByteBufferUtil.bytesToHex(mutation.key().getKey()),
columnFamilyStores.get(tableId).name);
+                            if (logger.isTraceEnabled())
+                                logger.trace("Could not acquire lock for {} and table {}",
ByteBufferUtil.bytesToHex(mutation.key().getKey()), columnFamilyStores.get(tableId).name);
                             Tracing.trace("Could not acquire MV lock");
                             if (future != null)
                             {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/src/java/org/apache/cassandra/db/Memtable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Memtable.java b/src/java/org/apache/cassandra/db/Memtable.java
index 08a6104..c6158b5 100644
--- a/src/java/org/apache/cassandra/db/Memtable.java
+++ b/src/java/org/apache/cassandra/db/Memtable.java
@@ -453,7 +453,8 @@ public class Memtable implements Comparable<Memtable>
 
         private void writeSortedContents()
         {
-            logger.debug("Writing {}, flushed range = ({}, {}]", Memtable.this.toString(),
from, to);
+            if (logger.isDebugEnabled())
+                logger.debug("Writing {}, flushed range = ({}, {}]", Memtable.this.toString(),
from, to);
 
             boolean trackContention = logger.isTraceEnabled();
             int heavilyContendedRowCount = 0;
@@ -482,10 +483,11 @@ public class Memtable implements Comparable<Memtable>
             }
 
             long bytesFlushed = writer.getFilePointer();
-            logger.debug("Completed flushing {} ({}) for commitlog position {}",
-                                                                              writer.getFilename(),
-                                                                              FBUtilities.prettyPrintMemory(bytesFlushed),
-                                                                              commitLogUpperBound);
+            if (logger.isDebugEnabled())
+                logger.debug("Completed flushing {} ({}) for commitlog position {}",
+                             writer.getFilename(),
+                             FBUtilities.prettyPrintMemory(bytesFlushed),
+                             commitLogUpperBound);
             // Update the metrics
             cfs.metric.bytesFlushed.inc(bytesFlushed);
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/src/java/org/apache/cassandra/db/SizeEstimatesRecorder.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SizeEstimatesRecorder.java b/src/java/org/apache/cassandra/db/SizeEstimatesRecorder.java
index 151e7d3..d61c297 100644
--- a/src/java/org/apache/cassandra/db/SizeEstimatesRecorder.java
+++ b/src/java/org/apache/cassandra/db/SizeEstimatesRecorder.java
@@ -77,10 +77,11 @@ public class SizeEstimatesRecorder extends SchemaChangeListener implements
Runna
                 long start = System.nanoTime();
                 recordSizeEstimates(table, localRanges);
                 long passed = System.nanoTime() - start;
-                logger.trace("Spent {} milliseconds on estimating {}.{} size",
-                             TimeUnit.NANOSECONDS.toMillis(passed),
-                             table.metadata.keyspace,
-                             table.metadata.name);
+                if (logger.isTraceEnabled())
+                    logger.trace("Spent {} milliseconds on estimating {}.{} size",
+                                 TimeUnit.NANOSECONDS.toMillis(passed),
+                                 table.metadata.keyspace,
+                                 table.metadata.name);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/src/java/org/apache/cassandra/db/TruncateVerbHandler.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/TruncateVerbHandler.java b/src/java/org/apache/cassandra/db/TruncateVerbHandler.java
index 226262c..c2fac65 100644
--- a/src/java/org/apache/cassandra/db/TruncateVerbHandler.java
+++ b/src/java/org/apache/cassandra/db/TruncateVerbHandler.java
@@ -50,7 +50,7 @@ public class TruncateVerbHandler implements IVerbHandler<Truncation>
         Tracing.trace("Enqueuing response to truncate operation to {}", message.from);
 
         TruncateResponse response = new TruncateResponse(t.keyspace, t.columnFamily, true);
-        logger.trace("{} applied.  Enqueuing response to {}@{} ", new Object[]{ t, id, message.from
});
+        logger.trace("{} applied.  Enqueuing response to {}@{} ", t, id, message.from );
         MessagingService.instance().sendReply(response.createMessage(), id, message.from);
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
index 5602aab..05891d2 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -697,8 +697,10 @@ public class CompactionManager implements CompactionManagerMBean
             ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(parentRepairSession);
             Preconditions.checkArgument(!prs.isPreview(), "Cannot anticompact for previews");
 
-            logger.info("{} Starting anticompaction for {}.{} on {}/{} sstables", PreviewKind.NONE.logPrefix(parentRepairSession),
cfs.keyspace.getName(), cfs.getTableName(), validatedForRepair.size(), cfs.getLiveSSTables().size());
-            logger.trace("{} Starting anticompaction for ranges {}", PreviewKind.NONE.logPrefix(parentRepairSession),
ranges);
+            if (logger.isInfoEnabled())
+                logger.info("{} Starting anticompaction for {}.{} on {}/{} sstables", PreviewKind.NONE.logPrefix(parentRepairSession),
cfs.keyspace.getName(), cfs.getTableName(), validatedForRepair.size(), cfs.getLiveSSTables().size());
+            if (logger.isTraceEnabled())
+                logger.trace("{} Starting anticompaction for ranges {}", PreviewKind.NONE.logPrefix(parentRepairSession),
ranges);
             Set<SSTableReader> sstables = new HashSet<>(validatedForRepair);
 
             Iterator<SSTableReader> sstableIterator = sstables.iterator();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/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 3d3cd3d..5697df2 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionTask.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionTask.java
@@ -254,23 +254,28 @@ public class CompactionTask extends AbstractCompactionTask
                     totalSourceRows += mergedRowCounts[i] * (i + 1);
 
                 String mergeSummary = updateCompactionHistory(cfs.keyspace.getName(), cfs.getTableName(),
mergedRowCounts, startsize, endsize);
-                logger.debug(String.format("Compacted (%s) %d sstables to [%s] to level=%d.
 %s to %s (~%d%% of original) in %,dms.  Read Throughput = %s, Write Throughput = %s, Row
Throughput = ~%,d/s.  %,d total partitions merged to %,d.  Partition merge counts were {%s}",
-                                           taskId,
-                                           transaction.originals().size(),
-                                           newSSTableNames.toString(),
-                                           getLevel(),
-                                           FBUtilities.prettyPrintMemory(startsize),
-                                           FBUtilities.prettyPrintMemory(endsize),
-                                           (int) (ratio * 100),
-                                           dTime,
-                                           FBUtilities.prettyPrintMemoryPerSecond(startsize,
durationInNano),
-                                           FBUtilities.prettyPrintMemoryPerSecond(endsize,
durationInNano),
-                                           (int) totalSourceCQLRows / (TimeUnit.NANOSECONDS.toSeconds(durationInNano)
+ 1),
-                                           totalSourceRows,
-                                           totalKeysWritten,
-                                           mergeSummary));
-                logger.trace("CF Total Bytes Compacted: {}", FBUtilities.prettyPrintMemory(CompactionTask.addToTotalBytesCompacted(endsize)));
-                logger.trace("Actual #keys: {}, Estimated #keys:{}, Err%: {}", totalKeysWritten,
estimatedKeys, ((double)(totalKeysWritten - estimatedKeys)/totalKeysWritten));
+
+                if (logger.isDebugEnabled())
+                    logger.debug(String.format("Compacted (%s) %d sstables to [%s] to level=%d.
 %s to %s (~%d%% of original) in %,dms.  Read Throughput = %s, Write Throughput = %s, Row
Throughput = ~%,d/s.  %,d total partitions merged to %,d.  Partition merge counts were {%s}",
+                                               taskId,
+                                               transaction.originals().size(),
+                                               newSSTableNames.toString(),
+                                               getLevel(),
+                                               FBUtilities.prettyPrintMemory(startsize),
+                                               FBUtilities.prettyPrintMemory(endsize),
+                                               (int) (ratio * 100),
+                                               dTime,
+                                               FBUtilities.prettyPrintMemoryPerSecond(startsize,
durationInNano),
+                                               FBUtilities.prettyPrintMemoryPerSecond(endsize,
durationInNano),
+                                               (int) totalSourceCQLRows / (TimeUnit.NANOSECONDS.toSeconds(durationInNano)
+ 1),
+                                               totalSourceRows,
+                                               totalKeysWritten,
+                                               mergeSummary));
+                if (logger.isTraceEnabled())
+                {
+                    logger.trace("CF Total Bytes Compacted: {}", FBUtilities.prettyPrintMemory(CompactionTask.addToTotalBytesCompacted(endsize)));
+                    logger.trace("Actual #keys: {}, Estimated #keys:{}, Err%: {}", totalKeysWritten,
estimatedKeys, ((double)(totalKeysWritten - estimatedKeys)/totalKeysWritten));
+                }
                 cfs.getCompactionStrategyManager().compactionLogger.compaction(startTime,
transaction.originals(), System.currentTimeMillis(), newSStables);
 
                 // update the metrics

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/src/java/org/apache/cassandra/gms/TokenSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/gms/TokenSerializer.java b/src/java/org/apache/cassandra/gms/TokenSerializer.java
index 41bd821..c371d64 100644
--- a/src/java/org/apache/cassandra/gms/TokenSerializer.java
+++ b/src/java/org/apache/cassandra/gms/TokenSerializer.java
@@ -54,7 +54,8 @@ public class TokenSerializer
             int size = in.readInt();
             if (size < 1)
                 break;
-            logger.trace("Reading token of {}", FBUtilities.prettyPrintMemory(size));
+            if (logger.isTraceEnabled())
+                logger.trace("Reading token of {}", FBUtilities.prettyPrintMemory(size));
             byte[] bintoken = new byte[size];
             in.readFully(bintoken);
             tokens.add(partitioner.getTokenFactory().fromByteArray(ByteBuffer.wrap(bintoken)));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/src/java/org/apache/cassandra/hadoop/cql3/LimitedLocalNodeFirstLocalBalancingPolicy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hadoop/cql3/LimitedLocalNodeFirstLocalBalancingPolicy.java
b/src/java/org/apache/cassandra/hadoop/cql3/LimitedLocalNodeFirstLocalBalancingPolicy.java
index 5c8d3c5..256da2d 100644
--- a/src/java/org/apache/cassandra/hadoop/cql3/LimitedLocalNodeFirstLocalBalancingPolicy.java
+++ b/src/java/org/apache/cassandra/hadoop/cql3/LimitedLocalNodeFirstLocalBalancingPolicy.java
@@ -71,7 +71,8 @@ class LimitedLocalNodeFirstLocalBalancingPolicy implements LoadBalancingPolicy
                 logger.warn("Invalid replica host name: {}, skipping it", replica);
             }
         }
-        logger.trace("Created instance with the following replicas: {}", Arrays.asList(replicas));
+        if (logger.isTraceEnabled())
+            logger.trace("Created instance with the following replicas: {}", Arrays.asList(replicas));
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/src/java/org/apache/cassandra/io/sstable/IndexSummaryRedistribution.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/IndexSummaryRedistribution.java b/src/java/org/apache/cassandra/io/sstable/IndexSummaryRedistribution.java
index 1aaeb8b..0e1d0f0 100644
--- a/src/java/org/apache/cassandra/io/sstable/IndexSummaryRedistribution.java
+++ b/src/java/org/apache/cassandra/io/sstable/IndexSummaryRedistribution.java
@@ -125,7 +125,8 @@ public class IndexSummaryRedistribution extends CompactionInfo.Holder
         total = 0;
         for (SSTableReader sstable : Iterables.concat(compacting, newSSTables))
             total += sstable.getIndexSummaryOffHeapSize();
-        logger.trace("Completed resizing of index summaries; current approximate memory used:
{}",
+        if (logger.isTraceEnabled())
+            logger.trace("Completed resizing of index summaries; current approximate memory
used: {}",
                      FBUtilities.prettyPrintMemory(total));
 
         return newSSTables;
@@ -177,12 +178,13 @@ public class IndexSummaryRedistribution extends CompactionInfo.Holder
             int numEntriesAtNewSamplingLevel = IndexSummaryBuilder.entriesAtSamplingLevel(newSamplingLevel,
maxSummarySize);
             double effectiveIndexInterval = sstable.getEffectiveIndexInterval();
 
-            logger.trace("{} has {} reads/sec; ideal space for index summary: {} ({} entries);
considering moving " +
-                    "from level {} ({} entries, {}) " +
-                    "to level {} ({} entries, {})",
-                    sstable.getFilename(), readsPerSec, FBUtilities.prettyPrintMemory(idealSpace),
targetNumEntries,
-                    currentSamplingLevel, currentNumEntries, FBUtilities.prettyPrintMemory((long)
(currentNumEntries * avgEntrySize)),
-                    newSamplingLevel, numEntriesAtNewSamplingLevel, FBUtilities.prettyPrintMemory((long)
(numEntriesAtNewSamplingLevel * avgEntrySize)));
+            if (logger.isTraceEnabled())
+                logger.trace("{} has {} reads/sec; ideal space for index summary: {} ({}
entries); considering moving " +
+                             "from level {} ({} entries, {}) " +
+                             "to level {} ({} entries, {})",
+                             sstable.getFilename(), readsPerSec, FBUtilities.prettyPrintMemory(idealSpace),
targetNumEntries,
+                             currentSamplingLevel, currentNumEntries, FBUtilities.prettyPrintMemory((long)
(currentNumEntries * avgEntrySize)),
+                             newSamplingLevel, numEntriesAtNewSamplingLevel, FBUtilities.prettyPrintMemory((long)
(numEntriesAtNewSamplingLevel * avgEntrySize)));
 
             if (effectiveIndexInterval < minIndexInterval)
             {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java b/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
index dd93e5f..63f3596 100644
--- a/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
+++ b/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
@@ -428,7 +428,8 @@ public abstract class SSTableReader extends SSTable implements SelfRefCounted<SS
         }
 
         long fileLength = new File(descriptor.filenameFor(Component.DATA)).length();
-        logger.debug("Opening {} ({})", descriptor, FBUtilities.prettyPrintMemory(fileLength));
+        if (logger.isDebugEnabled())
+            logger.debug("Opening {} ({})", descriptor, FBUtilities.prettyPrintMemory(fileLength));
         SSTableReader sstable = internalOpen(descriptor,
                                              components,
                                              metadata,
@@ -518,7 +519,8 @@ public abstract class SSTableReader extends SSTable implements SelfRefCounted<SS
         }
 
         long fileLength = new File(descriptor.filenameFor(Component.DATA)).length();
-        logger.debug("Opening {} ({})", descriptor, FBUtilities.prettyPrintMemory(fileLength));
+        if (logger.isDebugEnabled())
+            logger.debug("Opening {} ({})", descriptor, FBUtilities.prettyPrintMemory(fileLength));
         SSTableReader sstable = internalOpen(descriptor,
                                              components,
                                              metadata,

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/src/java/org/apache/cassandra/io/sstable/metadata/MetadataSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/metadata/MetadataSerializer.java b/src/java/org/apache/cassandra/io/sstable/metadata/MetadataSerializer.java
index c1bbeb0..74923a0 100644
--- a/src/java/org/apache/cassandra/io/sstable/metadata/MetadataSerializer.java
+++ b/src/java/org/apache/cassandra/io/sstable/metadata/MetadataSerializer.java
@@ -221,7 +221,8 @@ public class MetadataSerializer implements IMetadataSerializer
 
     public void mutateLevel(Descriptor descriptor, int newLevel) throws IOException
     {
-        logger.trace("Mutating {} to level {}", descriptor.filenameFor(Component.STATS),
newLevel);
+        if (logger.isTraceEnabled())
+            logger.trace("Mutating {} to level {}", descriptor.filenameFor(Component.STATS),
newLevel);
         Map<MetadataType, MetadataComponent> currentComponents = deserialize(descriptor,
EnumSet.allOf(MetadataType.class));
         StatsMetadata stats = (StatsMetadata) currentComponents.remove(MetadataType.STATS);
         // mutate level
@@ -231,8 +232,9 @@ public class MetadataSerializer implements IMetadataSerializer
 
     public void mutateRepaired(Descriptor descriptor, long newRepairedAt, UUID newPendingRepair)
throws IOException
     {
-        logger.trace("Mutating {} to repairedAt time {} and pendingRepair {}",
-                     descriptor.filenameFor(Component.STATS), newRepairedAt, newPendingRepair);
+        if (logger.isTraceEnabled())
+            logger.trace("Mutating {} to repairedAt time {} and pendingRepair {}",
+                         descriptor.filenameFor(Component.STATS), newRepairedAt, newPendingRepair);
         Map<MetadataType, MetadataComponent> currentComponents = deserialize(descriptor,
EnumSet.allOf(MetadataType.class));
         StatsMetadata stats = (StatsMetadata) currentComponents.remove(MetadataType.STATS);
         // mutate time & id

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/src/java/org/apache/cassandra/net/async/InboundHandshakeHandler.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/net/async/InboundHandshakeHandler.java b/src/java/org/apache/cassandra/net/async/InboundHandshakeHandler.java
index a84112e..656680f 100644
--- a/src/java/org/apache/cassandra/net/async/InboundHandshakeHandler.java
+++ b/src/java/org/apache/cassandra/net/async/InboundHandshakeHandler.java
@@ -247,7 +247,8 @@ class InboundHandshakeHandler extends ByteToMessageDecoder
         // record the (true) version of the endpoint
         InetAddressAndPort from = msg.address;
         MessagingService.instance().setVersion(from, maxVersion);
-        logger.trace("Set version for {} to {} (will use {})", from, maxVersion, MessagingService.instance().getVersion(from));
+        if (logger.isTraceEnabled())
+            logger.trace("Set version for {} to {} (will use {})", from, maxVersion, MessagingService.instance().getVersion(from));
 
         setupMessagingPipeline(ctx.pipeline(), from, compressed, version);
         return State.HANDSHAKE_COMPLETE;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/src/java/org/apache/cassandra/repair/RepairSession.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/repair/RepairSession.java b/src/java/org/apache/cassandra/repair/RepairSession.java
index 91d767d..ec06f37 100644
--- a/src/java/org/apache/cassandra/repair/RepairSession.java
+++ b/src/java/org/apache/cassandra/repair/RepairSession.java
@@ -238,7 +238,8 @@ public class RepairSession extends AbstractFuture<RepairSessionResult>
implement
             return;
         }
 
-        logger.debug("{} Repair completed between {} and {} on {}", previewKind.logPrefix(getId()),
nodes.endpoint1, nodes.endpoint2, desc.columnFamily);
+        if (logger.isDebugEnabled())
+            logger.debug("{} Repair completed between {} and {} on {}", previewKind.logPrefix(getId()),
nodes.endpoint1, nodes.endpoint2, desc.columnFamily);
         task.syncComplete(success, summaries);
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/src/java/org/apache/cassandra/streaming/StreamCoordinator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/streaming/StreamCoordinator.java b/src/java/org/apache/cassandra/streaming/StreamCoordinator.java
index 6ea8e00..34b0bbd 100644
--- a/src/java/org/apache/cassandra/streaming/StreamCoordinator.java
+++ b/src/java/org/apache/cassandra/streaming/StreamCoordinator.java
@@ -135,7 +135,8 @@ public class StreamCoordinator
         if (sessionsToConnect.hasNext())
         {
             StreamSession next = sessionsToConnect.next();
-            logger.debug("Connecting next session {} with {}.", next.planId(), next.peer.toString());
+            if (logger.isDebugEnabled())
+                logger.debug("Connecting next session {} with {}.", next.planId(), next.peer.toString());
             startSession(next);
         }
         else

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/src/java/org/apache/cassandra/streaming/async/NettyStreamingMessageSender.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/streaming/async/NettyStreamingMessageSender.java
b/src/java/org/apache/cassandra/streaming/async/NettyStreamingMessageSender.java
index 1bcb013..bff77cf 100644
--- a/src/java/org/apache/cassandra/streaming/async/NettyStreamingMessageSender.java
+++ b/src/java/org/apache/cassandra/streaming/async/NettyStreamingMessageSender.java
@@ -170,7 +170,8 @@ public class NettyStreamingMessageSender implements StreamingMessageSender
     private void scheduleKeepAliveTask(Channel channel)
     {
         int keepAlivePeriod = DatabaseDescriptor.getStreamingKeepAlivePeriod();
-        logger.debug("{} Scheduling keep-alive task with {}s period.", createLogTag(session,
channel), keepAlivePeriod);
+        if (logger.isDebugEnabled())
+            logger.debug("{} Scheduling keep-alive task with {}s period.", createLogTag(session,
channel), keepAlivePeriod);
 
         KeepAliveTask task = new KeepAliveTask(channel, session);
         ScheduledFuture<?> scheduledFuture = channel.eventLoop().scheduleAtFixedRate(task,
0, keepAlivePeriod, TimeUnit.SECONDS);
@@ -188,7 +189,7 @@ public class NettyStreamingMessageSender implements StreamingMessageSender
         return channel;
     }
 
-     static String createLogTag(StreamSession session, Channel channel)
+    static String createLogTag(StreamSession session, Channel channel)
     {
         StringBuilder sb = new StringBuilder(64);
         sb.append("[Stream");
@@ -213,7 +214,8 @@ public class NettyStreamingMessageSender implements StreamingMessageSender
         {
             if (isPreview)
                 throw new RuntimeException("Cannot send stream data messages for preview
streaming sessions");
-            logger.debug("{} Sending {}", createLogTag(session, null), message);
+            if (logger.isDebugEnabled())
+                logger.debug("{} Sending {}", createLogTag(session, null), message);
             fileTransferExecutor.submit(new FileStreamTask((OutgoingStreamMessage)message));
             return;
         }
@@ -232,7 +234,8 @@ public class NettyStreamingMessageSender implements StreamingMessageSender
 
     private void sendControlMessage(Channel channel, StreamMessage message, GenericFutureListener
listener) throws IOException
     {
-        logger.debug("{} Sending {}", createLogTag(session, channel), message);
+        if (logger.isDebugEnabled())
+            logger.debug("{} Sending {}", createLogTag(session, channel), message);
 
         // we anticipate that the control messages are rather small, so allocating a ByteBuf
shouldn't  blow out of memory.
         long messageSize = StreamMessage.serializedSize(message, protocolVersion);
@@ -358,8 +361,10 @@ public class NettyStreamingMessageSender implements StreamingMessageSender
                     {
                         timeOfLastLogging = now;
                         OutgoingStreamMessage ofm = (OutgoingStreamMessage)msg;
-                        logger.info("{} waiting to acquire a permit to begin streaming {}.
This message logs every {} minutes",
-                                    createLogTag(session, null), ofm.getName(), logInterval);
+
+                        if (logger.isInfoEnabled())
+                            logger.info("{} waiting to acquire a permit to begin streaming
{}. This message logs every {} minutes",
+                                        createLogTag(session, null), ofm.getName(), logInterval);
                     }
                 }
                 catch (InterruptedException ie)
@@ -448,7 +453,8 @@ public class NettyStreamingMessageSender implements StreamingMessageSender
 
             try
             {
-                logger.trace("{} Sending keep-alive to {}.", createLogTag(session, channel),
session.peer);
+                if (logger.isTraceEnabled())
+                    logger.trace("{} Sending keep-alive to {}.", createLogTag(session, channel),
session.peer);
                 sendControlMessage(channel, new KeepAliveMessage(), this::keepAliveListener);
             }
             catch (IOException ioe)
@@ -462,8 +468,9 @@ public class NettyStreamingMessageSender implements StreamingMessageSender
             if (future.isSuccess() || future.isCancelled())
                 return;
 
-            logger.debug("{} Could not send keep-alive message (perhaps stream session is
finished?).",
-                         createLogTag(session, channel), future.cause());
+            if (logger.isDebugEnabled())
+                logger.debug("{} Could not send keep-alive message (perhaps stream session
is finished?).",
+                             createLogTag(session, channel), future.cause());
         }
     }
 
@@ -495,7 +502,8 @@ public class NettyStreamingMessageSender implements StreamingMessageSender
     public void close()
     {
         closed = true;
-        logger.debug("{} Closing stream connection channels on {}", createLogTag(session,
null), connectionId);
+        if (logger.isDebugEnabled())
+            logger.debug("{} Closing stream connection channels on {}", createLogTag(session,
null), connectionId);
         for (ScheduledFuture<?> future : channelKeepAlives)
             future.cancel(false);
         channelKeepAlives.clear();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/src/java/org/apache/cassandra/streaming/async/StreamingInboundHandler.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/streaming/async/StreamingInboundHandler.java b/src/java/org/apache/cassandra/streaming/async/StreamingInboundHandler.java
index 03f0640..81fe8cd 100644
--- a/src/java/org/apache/cassandra/streaming/async/StreamingInboundHandler.java
+++ b/src/java/org/apache/cassandra/streaming/async/StreamingInboundHandler.java
@@ -180,13 +180,16 @@ public class StreamingInboundHandler extends ChannelInboundHandlerAdapter
                     // wrt session lifecycle, due to races), just log that we received the
message and carry on
                     if (message instanceof KeepAliveMessage)
                     {
-                        logger.debug("{} Received {}", createLogTag(session, channel), message);
+                        if (logger.isDebugEnabled())
+                            logger.debug("{} Received {}", createLogTag(session, channel),
message);
                         continue;
                     }
 
                     if (session == null)
                         session = deriveSession(message);
-                    logger.debug("{} Received {}", createLogTag(session, channel), message);
+
+                    if (logger.isDebugEnabled())
+                        logger.debug("{} Received {}", createLogTag(session, channel), message);
                     session.messageReceived(message);
                 }
             }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d8fc5b0/src/java/org/apache/cassandra/utils/JMXServerUtils.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/JMXServerUtils.java b/src/java/org/apache/cassandra/utils/JMXServerUtils.java
index a5a07f4..f913baf 100644
--- a/src/java/org/apache/cassandra/utils/JMXServerUtils.java
+++ b/src/java/org/apache/cassandra/utils/JMXServerUtils.java
@@ -248,14 +248,15 @@ public class JMXServerUtils
 
     private static void logJmxSslConfig(SslRMIServerSocketFactory serverFactory)
     {
-        logger.debug("JMX SSL configuration. { protocols: [{}], cipher_suites: [{}], require_client_auth:
{} }",
-                     serverFactory.getEnabledProtocols() == null
-                     ? "'JVM defaults'"
-                     : Arrays.stream(serverFactory.getEnabledProtocols()).collect(Collectors.joining("','",
"'", "'")),
-                     serverFactory.getEnabledCipherSuites() == null
-                     ? "'JVM defaults'"
-                     : Arrays.stream(serverFactory.getEnabledCipherSuites()).collect(Collectors.joining("','",
"'", "'")),
-                     serverFactory.getNeedClientAuth());
+        if (logger.isDebugEnabled())
+            logger.debug("JMX SSL configuration. { protocols: [{}], cipher_suites: [{}],
require_client_auth: {} }",
+                         serverFactory.getEnabledProtocols() == null
+                         ? "'JVM defaults'"
+                         : Arrays.stream(serverFactory.getEnabledProtocols()).collect(Collectors.joining("','",
"'", "'")),
+                         serverFactory.getEnabledCipherSuites() == null
+                         ? "'JVM defaults'"
+                         : Arrays.stream(serverFactory.getEnabledCipherSuites()).collect(Collectors.joining("','",
"'", "'")),
+                         serverFactory.getNeedClientAuth());
     }
 
     private static class JMXPluggableAuthenticatorWrapper implements JMXAuthenticator


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


Mime
View raw message