Interface AllowlistStore
public interface AllowlistStore
Interface for persisting the allowlist across restarts.
This SPI allows implementations to store allowlist changes durably
to disk, a database, or other persistent storage. By default,
AllowlistManager works in-memory; calls to AllowlistManager.add(String)
and AllowlistManager.remove(String) can optionally invoke an AllowlistStore
to ensure durability.
Implementation requirements
- The store MUST be thread-safe for concurrent access.
- Writes MUST be durable and survive process restarts.
- Load operations MUST be idempotent.
Usage
AllowlistStore fileStore = new FileAllowlistStore(Paths.get("/data/allowlist.txt"));
AllowlistManager allowlist = new AllowlistManager();
allowlist.loadFromStore(fileStore); // Load previously persisted allowlist
allowlist.add("new-node");
allowlist.saveToStore(fileStore); // Durably save the update
- Since:
- 1.0.0
- See Also:
-
Method Summary
-
Method Details
-
load
Loads allowlisted node IDs from persistent storage.This method is typically called once at startup to restore the allowlist from a previous session.
- Returns:
- a set of allowlisted node IDs (maybe empty, but non-null)
-
save
Saves a set of node IDs to persistent storage, replacing any previously stored list.This method is called whenever the allowlist is modified (in
AllowlistManagerintegration scenarios) to ensure durability.- Parameters:
nodeIds- the set of node IDs to persist (non-null, may be empty)
-