Any reason we shouldn't make SLEEP_AFTER_FAILURE_TO_BECOME_ACTIVE configurable?
Currently, ActiveStandbyElector doesn't take a Configuration object. I think many of the parameters should be changed to be configured via Configuration, but I didn't want to make this into a bigger scoped change.
There's some inconsistency in capitalization between "reJoinElection" and "rejoinElectionAfterFailureToBecomeActive"
Changed to consistently use "reJoin" to match the previously existing code.
Might want to do a s/System.currentTimeMillis/Util.now/g
The Util class is in HDFS, but this code is in common. We don't seem to have an equivalent in common.
Any reason we shouldn't make LOG_INTERVAL_MS configurable?
It's just test code, so seemed unnecessary.
Add @VisibleForTesting to sleepFor, since it would be private (and probably static) otherwise. Maybe even add a comment saying why it's not static.
Considering the comment says "after sleeping for a short period" in TestActiveStandbyElector#testFailToBecomeActive, maybe also verify that sleepFor was called? Likewise in testFailToBecomeActiveAfterZKDisconnect.
Done. I made the overridden method keep a tally of number of slept millis, and added asserts to the tests to make sure it slept for some time when rejoining.