As reported: Rubrik system coding round (2026), multithreading / distributed systems: design and implement a thread-safe Lease Manager in Java.
A lease manager controls access to shared resources. Clients ask it for a lease on a resource; while a client holds the lease, it may use the resource. At any time only one client can hold a lease on a particular resource. Many clients call the manager concurrently.
Design the API and implement it so that it is correct under concurrency.
Clarifications (agree on these first)
- What a client gets back: a lease object or token identifying the holder, so that only the holder can release it.
- Whether leases expire after a duration (and can be renewed), so a crashed client does not hold a resource forever.
- What
acquiredoes when the resource is taken: fail immediately, block, or block with a timeout.