Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-3457

Code optimization in QuorumCnxManager

    XMLWordPrintableJSON

    Details

      Description

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

      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);
      }
      

      The optimization is as follows:

      ArrayBlockingQueue<ByteBuffer> bq = queueSendMap.computeIfAbsent(sid, serverId 
       -> new ArrayBlockingQueue<>(SEND_CAPACITY));
      addToSendQueue(bq, b);
      

        Attachments

          Activity

            People

            • Assignee:
              18779116352 tom.long
              Reporter:
              18779116352 tom.long
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified