You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jj...@apache.org on 2019/06/21 16:22:15 UTC

[cassandra] branch trunk updated: CQL Native Transport: Apply noSpamLogger to ConnectionLimitHandler

This is an automated email from the ASF dual-hosted git repository.

jjirsa pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 58456fc  CQL Native Transport: Apply noSpamLogger to ConnectionLimitHandler
58456fc is described below

commit 58456fc15d047810f0010e64ca496fd3223376ab
Author: Jeff Jirsa <jj...@apple.com>
AuthorDate: Mon Jun 17 11:00:25 2019 -0700

    CQL Native Transport: Apply noSpamLogger to ConnectionLimitHandler
    
    Patch by Jeff Jirsa; Reviewed by Chris Lohfink for CASSANDRA-15167
---
 CHANGES.txt                                                      | 1 +
 .../org/apache/cassandra/transport/ConnectionLimitHandler.java   | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 7680b8d..6435d03 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.0
+ * Native Transport - Apply noSpamLogger to ConnectionLimitHandler (CASSANDRA-15167)
  * Reduce heap pressure during compactions (CASSANDRA-14654)
  * Support building Cassandra with JDK 11 (CASSANDRA-15108)
  * Use quilt to patch cassandra.in.sh in Debian packaging (CASSANDRA-14710)
diff --git a/src/java/org/apache/cassandra/transport/ConnectionLimitHandler.java b/src/java/org/apache/cassandra/transport/ConnectionLimitHandler.java
index 7bcf280..3b2765f 100644
--- a/src/java/org/apache/cassandra/transport/ConnectionLimitHandler.java
+++ b/src/java/org/apache/cassandra/transport/ConnectionLimitHandler.java
@@ -22,6 +22,8 @@ import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelInboundHandlerAdapter;
 import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.utils.NoSpamLogger;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -29,6 +31,7 @@ import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
 
@@ -40,6 +43,8 @@ import java.util.concurrent.atomic.AtomicLong;
 final class ConnectionLimitHandler extends ChannelInboundHandlerAdapter
 {
     private static final Logger logger = LoggerFactory.getLogger(ConnectionLimitHandler.class);
+    private static final NoSpamLogger noSpamLogger = NoSpamLogger.getLogger(logger, 1L, TimeUnit.MINUTES);
+
     private final ConcurrentMap<InetAddress, AtomicLong> connectionsPerClient = new ConcurrentHashMap<>();
     private final AtomicLong counter = new AtomicLong(0);
 
@@ -56,7 +61,7 @@ final class ConnectionLimitHandler extends ChannelInboundHandlerAdapter
         if (count > limit)
         {
             // The decrement will be done in channelClosed(...)
-            logger.warn("Exceeded maximum native connection limit of {} by using {} connections", limit, count);
+            noSpamLogger.warn("Exceeded maximum native connection limit of {} by using {} connections", limit, count);
             ctx.close();
         }
         else
@@ -80,7 +85,7 @@ final class ConnectionLimitHandler extends ChannelInboundHandlerAdapter
                 if (perIpCount.incrementAndGet() > perIpLimit)
                 {
                     // The decrement will be done in channelClosed(...)
-                    logger.warn("Exceeded maximum native connection limit per ip of {} by using {} connections", perIpLimit, perIpCount);
+                    noSpamLogger.warn("Exceeded maximum native connection limit per ip of {} by using {} connections", perIpLimit, perIpCount);
                     ctx.close();
                     return;
                 }


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