zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tumativ <...@git.apache.org>
Subject [GitHub] zookeeper pull request #673: [ZOOKEEPER-3177] Refactor request throttle logi...
Date Sun, 04 Nov 2018 13:17:04 GMT
Github user tumativ commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/673#discussion_r230588336
  
    --- Diff: zookeeper-server/src/main/java/org/apache/zookeeper/server/ServerCnxn.java ---
    @@ -68,8 +68,39 @@
     
         private volatile boolean stale = false;
     
    +    AtomicLong outstandingCount = new AtomicLong();
    +
    +    /** The ZooKeeperServer for this connection. May be null if the server
    +     * is not currently serving requests (for example if the server is not
    +     * an active quorum participant.
    +     */
    +    final ZooKeeperServer zkServer;
    +
    +    public ServerCnxn(final ZooKeeperServer zkServer) {
    +        this.zkServer = zkServer;
    +    }
    +
         abstract int getSessionTimeout();
     
    +    public void incrOutstandingAndCheckThrottle(RequestHeader h) {
    +        if (h.getXid() <= 0) {
    +            return;
    +        }
    +        if (zkServer.shouldThrottle(outstandingCount.incrementAndGet())) {
    +            disableRecv(false);
    +        }
    +    }
    +
    +    // will be called from zkServer.processPacket
    +    public void decrOutstandingAndCheckThrottle(ReplyHeader h) {
    --- End diff --
    
    Sure Thanks. I will send PR


---

Mime
View raw message