Github user eribeiro commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/205#discussion_r107824547
  
    --- Diff: 
src/java/main/org/apache/zookeeper/server/NIOServerCnxnFactory.java ---
    @@ -607,9 +618,28 @@ public static ByteBuffer getDirectBuffer() {
         // sessionMap is used by closeSession()
         private final ConcurrentHashMap<Long, NIOServerCnxn> sessionMap =
             new ConcurrentHashMap<Long, NIOServerCnxn>();
    -    // ipMap is used to limit connections per IP
    -    private final ConcurrentHashMap<InetAddress, Set<NIOServerCnxn>> ipMap 
=
    -        new ConcurrentHashMap<InetAddress, Set<NIOServerCnxn>>( );
    +    // ipMap is used to limit connections and connection rate per IP
    +    private final ConcurrentHashMap<InetAddress, IpCnxns> ipMap
    +        = new ConcurrentHashMap<InetAddress, IpCnxns>();
    +
    +    // for each IP, we keep a RateLimiter to limit connection rate,
    +    // as well as a set of connections to limit total number of connections
    +    private static class IpCnxns {
    --- End diff --
    
    Eventually, we need to implement same logic for NettyServerCnxnFactory so 
better to up this class to ServerCnxnFactory or make it a top level class. The 
former is fine, imho.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to