fleetd #498: awaitHerdr distinguishes deadline-passed from interrupted, with measured elapsed time #502
Reference in New Issue
Block a user
Delete Branch "worker/498-451d1c-5"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes fleetd #498.
awaitHerdrused to return a bareboolean, collapsing two different facts onto the samefalse: the configured wait budget genuinely running out, and the waiting thread being interrupted possibly milliseconds in. The caller's log line also printed only the configured budget, never the measured elapsed time.awaitHerdrnow returnsHerdrAwaitOutcome(HerdrWaitResult, elapsedNanos)with three named states:ANSWERED,DEADLINE_PASSED,INTERRUPTED.awaitHerdrtakes the clock (LongSupplier) and the per-poll sleep (Runnable) as required parameters, no defaulted overload (fleetd #415's shape), so it is testable. The one production call site passesSystem::nanoTimeand a real sleep helper.logHerdrWaitOutcomeAndShouldReap(main() itself cannot be driven from a unit test), which logs a distinct message per outcome, always printingconfigured=Ns elapsed=Xmstogether, never the configured budget alone.FleetdAwaitHerdrTest: covers the seam (all three outcomes with an injected clock/stub HerdrClient, including asserting the interrupt flag is preserved) and the call site (the three distinct log messages viaListAppender, same pattern asAmqpConnectionFailureLoggerTest/LeadRolloverTest).Tests:
mvn clean install—Tests run: 1683, Failures: 0, Errors: 0, Skipped: 0—BUILD SUCCESS.Mutation testing (see PR discussion / worker report for the full table): 3 mutations run, one per outcome/branch, each caught by a distinct failing test; control run afterward matched the baseline (6/6 green); harness-proof (broken string) also caught by the suite before any mutation was applied.
Out of scope, noted per the ticket, not fixed:
selectLeadMailbox(~Fleetd.java:1330-1358) returnsnullfor three distinct causes (not configured, blankcoordinator.selfId, broker unreachable) — a weaker instance of the same shape, though each cause is already logged distinctly at its own return site. No otherboolean-collapsing or configured-constant-only log line found elsewhere inFleetd.java.