• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apache / bookkeeper / 39
72%

Build:
DEFAULT BRANCH: master
Ran 01 Apr 2018 02:31PM UTC
Jobs 1
Files 399
Run time 21s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
39

push

jenkins

Matteo Merli
Avoid acquiring closeLock.readLock() on every add/read operation

In the `BookieClient`, we are always acquiring a readlock when grabbing a connection to use for sending a write/read request.

The lock is the `closeLock` and it's only acquired in "write" mode when the `BookKeeper` instance is closed.

The problem with the read-lock is that it introduces contention between the threads that are acquiring it (even if all of them in read mode). Multiple threads can be be in read mode in the critical section, though they have contention when they're entering/exiting the section.

Additionally, the Java implementation of read/write lock is creating and destroying a lot of objects when that contention happens.

My understanding of the code is that we don't need to acquire the read lock in that point. The reason is that, we are already acquiring the lock in the `lookupClient()` method, although only if the pool is null. Additionally, when `Bookkeeper.close()` is invoked all PCBC will be set to closed as well, so it will not be possibile to create a new connection.

All the line changes in the patch are just removing the readLock acquire and try/finally, and reducing the indentation level.

Author: Matteo Merli <mmerli@apache.org>

Reviewers: Ivan Kelly <ivank@apache.org>, Enrico Olivelli <eolivelli@gmail.com>, Jia Zhai <None>, Sijie Guo <sijie@apache.org>

This closes #1292 from merlimat/bookie-client-rw-lock and squashes the following commits:

2104a3aa7 [Matteo Merli] Converted anonymous classes into lambdas
cabad14e5 [Matteo Merli] Avoid acquiring closeLock.readLock() on every add/read operation

22995 of 31802 relevant lines covered (72.31%)

0.72 hits per line

Jobs
ID Job ID Ran Files Coverage
1 39.1 01 Apr 2018 02:31PM UTC 0
72.31
Source Files on build 39
Detailed source file information is not available for this build.
  • Back to Repo
  • Jenkins Build #39
  • 9df8dac2 on github
  • Prev Build on master (#38)
  • Next Build on master (#40)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc