Class SessionDedupeLedger
- All Implemented Interfaces:
DedupeLedger
DedupeLedger every inbound handler of the framework shares (plan 22-21, D-17 as narrowed by S-52, S-59):
the command-id set and the receipts live in the current session's CommandDedupeSet, and
persistNow() writes them, with the outbox, to cloud-outbox.json through the session's
CloudStateStore.
Lifetime. One instance lives as long as the plugin is enabled, so the monitor stays the same across
reconnects and across the session replacements of a login or logout. Each call asks the SessionDedupeLedger.Target supplier for
the state of the session that is current at that moment; with no adopted credential (no target, or one without a
store) firstSeen(java.lang.String) reports every id as new, no receipt exists and persistNow() fails, which the
callers already treat as "continue with what is in memory".
Locks. Callers hold this ledger's monitor around a mutation and its persistence. persistNow() then
takes the store's JVM-wide write lock and, inside it, the dedupe set's leaf monitor; it never takes a session
monitor, so it cannot invert the lock order of CloudSession (S-32, S-37). It is synchronous and runs on the
thread that handles the request -- the agent thread or the player-link handler thread, never the server thread. A
module may complete its player-link result on any thread, the server thread included; PlayerLinkChannel
moves the persistence of that result onto the player-link handler thread first.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classThe state of one session: its id set, its state file and the server id the file is written for. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanRecords a previously unseen id in memory, subject to retention bounds.(package private) static SessionDedupeLedgerfixed(CommandDedupeSet dedupe, CloudStateStore store, String serverId) voidWrites the ids, their receipts and the outbox now, under the store's write lock.com.google.gson.JsonObjectreceiptFor(String id) Looks up a completion result for replay, without invoking its handler again.voidrecordReceipt(String id, com.google.gson.JsonObject receipt) Records the receipt with its id.
-
Field Details
-
target
-
-
Constructor Details
-
SessionDedupeLedger
SessionDedupeLedger(Supplier<SessionDedupeLedger.Target> target) - Parameters:
target- supplies the current session's state, ornullwhile no credential is adopted
-
-
Method Details
-
fixed
- Parameters:
dedupe- the id setstore- the state file writer, ornullfor an in-memory ledgerserverId- the linked server's id- Returns:
- a ledger bound to exactly that state
-
firstSeen
Description copied from interface:DedupeLedgerRecords a previously unseen id in memory, subject to retention bounds.- Specified by:
firstSeenin interfaceDedupeLedger- Parameters:
id- the request envelope ULID- Returns:
- true for a newly recorded id, false for an unexpired duplicate
-
persistNow
Writes the ids, their receipts and the outbox now, under the store's write lock.- Specified by:
persistNowin interfaceDedupeLedger- Throws:
IOException- when no store is adopted or the write fails; the dirty flags then stay set, so the next periodic flush retries
-
receiptFor
Description copied from interface:DedupeLedgerLooks up a completion result for replay, without invoking its handler again.- Specified by:
receiptForin interfaceDedupeLedger- Parameters:
id- the completed-message envelope ULID- Returns:
- the recorded result payload, or null when absent; callers must not mutate it
-
recordReceipt
Records the receipt with its id. A receipt larger thanCommandDedupeSet.MAX_RECEIPT_BYTESis not recorded and logs one WARNING: the reply is still sent, and a redelivery of that id asks the module again.- Specified by:
recordReceiptin interfaceDedupeLedger- Parameters:
id- the completed-message envelope ULIDreceipt- the result payload; callers must not mutate it after recording
-