linkedin / brooklin

An extensible distributed system for reliable nearline data streaming at scale
BSD 2-Clause "Simplified" License
922 stars 137 forks source link

Unblock waiting threads sooner #975

Closed hshukla closed 10 months ago

hshukla commented 10 months ago

currently, during the shutdown, we always wait 60seconds before we unblock other waiting threads(zk callback thread or main threads) on coordinator object, this was being added as part of https://github.com/linkedin/brooklin/pull/964, our expectation was the intrinsic CV will help us with notifying blocking threads sooner, but notifyAll was not mentioned at the right place, which was making other threads to be blocked on for 60 seconds always.

This PR uses explicit state variable for intrinsic CV, checks the new state variable _handleEventCompleted and wait only if false. From evenThread run method, we update the state variable and call notifyAll() outside the while loop; when shutdown is true. This will help blocking thread to unblock and have a chance to acquire the lock on the coordinator object and perform the clean shutdown.