zookeeper-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "tom.long (JIRA)" <j...@apache.org>
Subject [jira] [Created] (ZOOKEEPER-3457) Code optimization in QuorumCnxManager
Date Mon, 08 Jul 2019 06:29:00 GMT
tom.long created ZOOKEEPER-3457:

             Summary: Code optimization in QuorumCnxManager
                 Key: ZOOKEEPER-3457
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3457
             Project: ZooKeeper
          Issue Type: Improvement
          Components: quorum
    Affects Versions: 3.5.5
            Reporter: tom.long
             Fix For: 3.5.5

Dear developer:
I think the following code in line 623 of the QuorumCnxManager class can be optimized:

ArrayBlockingQueue<ByteBuffer> bq = new ArrayBlockingQueue<ByteBuffer>(
ArrayBlockingQueue<ByteBuffer> oldq = queueSendMap.putIfAbsent(sid, bq);
if (oldq != null) {
addToSendQueue(oldq, b);
} else {
addToSendQueue(bq, b);
The optimization is as follows:
ArrayBlockingQueue<ByteBuffer> bq = queueSendMap.computeIfAbsent(sid, serverId 
 -> new ArrayBlockingQueue<>(SEND_CAPACITY));
addToSendQueue(bq, b);

This message was sent by Atlassian JIRA

View raw message