Open DomGarguilo opened 1 month ago
I think I missed the initial inclusion of the CountDownTimer class. I went looking to see if an implementation already existed that we could just use and not have to maintain ourselves. I didn't find one, but I found three implementations of a StopWatch. One StopWatch is in our codebase and it appears unused and a candidate for removal, Commons-Lang has one, and Guava does too. A timer is just checking to see if some amount of time has passed. I'm wondering if we should leverage an existing StopWatch implementation inside of the CountDownTimer to reduce the amount of code that we have to maintain and test.
I think it's worth looking into one of the existing libraries to use. But, we'd need to be careful it's fast and efficient, and not something that is going to be slow by creating unnecessary Duration objects to do simple arithmetic operations on nanoTime.
Yea I think its worth looking into as well. Maybe we can open a new ticket to remove the StopWatch class thats in our codebase and look into the existing timing utils.
This pull request introduces the
CountDownTimer
class to replace the existingTimer
class for better handling of timeout and retry logic in theTabletServerBatchReaderIterator
class. The most significant changes include the integration ofCountDownTimer
in various methods and the addition of new methods to theCountDownTimer
class to support the new functionality.Integration of
CountDownTimer
:TabletServerBatchReaderIterator.java
: ReplacedTimer
withCountDownTimer
to simplify handling of retry timeouts and activity tracking in methods such asdoLookups
,rebinToScanServers
, andTimeoutTracker
class.Enhancements to
CountDownTimer
class:CountDownTimer.java
: Addedrestart
method to reset the timer andtimeLeft
method to get the remaining time as aDuration
.