DatabaseManager
Manages per-device Room database instances for node data, with LRU eviction.
Properties
Functions
Establishes an orderly shutdown boundary: rejects new work, bounds manager-job cancellation, admitted manager-operation draining, and admitted-writer draining, waits for the last serialized switch/association to finalize, then closes every manager-owned Room instance. If a cancelled child, admitted operation, writer, or pool close cannot finish successfully, ownership is retained and physical cleanup is skipped so a later close call can retry without losing track of live resources. Retried attempts may call Room's idempotent close() again for pools that completed during an earlier partial attempt.
Returns true if a database exists for the given device address. Android Room stores DB files without an extension; JVM/iOS append .db. We check both to stay platform-agnostic.
Re-latches long-lived DAO flows on database switches and recovers the active Room pool after a reader/writer acquisition timeout. A failed query is never replayed on the same pool; publishing the replacement causes flatMapLatest to start a fresh DAO flow. Concurrent failing collectors converge on the same replacement.
Switch active database to the one associated with address. Serialized via mutex.
Executes block once against the admitted current DB instance, bounding the caller's wait at withDbTimeoutMillis.
Executes one bounded read without writer admission or the serialized write-containment lane. Active database publication is synchronous and the captured pool is registered against eviction until the callback completes. The read is also admitted into the shutdown drain, is never replayed automatically, and new reads are rejected once shutdown begins.