You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by an...@apache.org on 2019/07/27 18:04:49 UTC
[zookeeper] branch master updated: ZOOKEEPER-3457: Code
optimization in QuorumCnxManager
This is an automated email from the ASF dual-hosted git repository.
andor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zookeeper.git
The following commit(s) were added to refs/heads/master by this push:
new 83940b1 ZOOKEEPER-3457: Code optimization in QuorumCnxManager
83940b1 is described below
commit 83940b18ce70016de7400f6159ce2a2db5a0bbec
Author: longqiang <l>
AuthorDate: Sat Jul 27 20:04:26 2019 +0200
ZOOKEEPER-3457: Code optimization in QuorumCnxManager
more details in the [ZOOKEEPER-3457](https://issues.apache.org/jira/browse/ZOOKEEPER-3457)
Author: longqiang <l>
Reviewers: nkalmar@apache.org, andor@apache.org
Closes #1021 from finefuture/zookeeper-3457 and squashes the following commits:
312615089 [longqiang] refactor(optimize code):
541547de8 [longqiang] Merge branch 'master' of github.com:apache/zookeeper into zookeeper-3457
ea78fe88e [longqiang] refactor(optimize code):
---
.../apache/zookeeper/server/quorum/QuorumCnxManager.java | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumCnxManager.java b/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
index 7870bb3..d97da2a 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
@@ -619,15 +619,10 @@ public class QuorumCnxManager {
/*
* Start a new connection if doesn't have one already.
*/
- ArrayBlockingQueue<ByteBuffer> bq = new ArrayBlockingQueue<ByteBuffer>(
- SEND_CAPACITY);
- ArrayBlockingQueue<ByteBuffer> oldq = queueSendMap.putIfAbsent(sid, bq);
- if (oldq != null) {
- addToSendQueue(oldq, b);
- } else {
- addToSendQueue(bq, b);
- }
- connectOne(sid);
+ ArrayBlockingQueue<ByteBuffer> bq = queueSendMap.computeIfAbsent(sid,
+ serverId -> new ArrayBlockingQueue<>(SEND_CAPACITY));
+ addToSendQueue(bq, b);
+ connectOne(sid);
}
}