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
---