Leader Lease Manager
A marker interface for LeaseManager implementations that provide leader election functionality across service instances (e.g. first-come first-serve, quorum).
Leader lease managers ensure that only one instance in a cluster holds a particular lease at a time, making that instance the "leader" for coordinating work or making decisions. This is useful for scenarios where a single coordinator is needed to prevent conflicts or duplicate processing.
Implementations should ensure that:
Only one instance holds the leader lease at any given time
Leadership transfers gracefully when the current leader fails or releases the lease
The system can detect and handle split-brain scenarios
Functions
Attempts to acquire an AutoCloseableLease.
Registers interest in the lease with the given name. Service instances should register their interest in leases as soon as they know about them; this gives the process an opportunity to notify the underlying cluster system that it is interested in the lease, or to setup other background tasks to acquire the lease if necessary. Note that registering interest in a lease doesn't necessarily mean that this service instance will attempt to acquire the lease; many clustering systems will only try to acquire leases for resources that they think they should own based on some consistent hashing system