class StoreState extends Object
Tracks peer interaction status, timing information, and operation progress for store operations. Maintains separate sets for pending, attempted, and successful operations to coordinate concurrent store operations and prevent duplicate queries.
Thread-safe implementation using synchronized collections and atomic counters for safe concurrent access from multiple store jobs.
Provides comprehensive state management for reliable data persistence with validation, timeout handling, and operation completion tracking.
| Constructor and Description |
|---|
StoreState(RouterContext ctx,
Hash key,
DatabaseEntry data)StoreState. |
StoreState(RouterContext ctx,
Hash key,
DatabaseEntry data,
Set<Hash> toSkip)New store state tracking pending, attempted, and successful peers. |
| Modifier and Type | Method and Description |
|---|---|
void | addPending(Hash peer)Increments attempted count |
void | addPending(Hash peer,
MessageWrapper.WrappedMessage msg)Adds a pending message for tracking. |
void | addSkipped(Hash peer)We aren't even going to try to contact this peer. |
void | complete(boolean completed)Mark the store as completed at the current time, if not already. |
boolean | completed()Whether the store has completed. |
long | confirmed(Hash peer)Mark the peer as confirmed and return the response time. |
Set<Hash> | getAttempted()The peers attempted OR skipped. |
int | getAttemptedCount()The number of peers attempted. |
int | getCompleteCount()Number of peers that confirmed the store. |
DatabaseEntry | getData()The data being stored. |
int | getPendingCount()Number of pending peers. |
MessageWrapper.WrappedMessage | getPendingMessage(Hash peer)Returns the pending message for the specified peer. |
Hash | getSuccessful()Return a successful peer (a random one if more than one was successful)
or null. |
Hash | getTarget()The DatabaseEntry hash target. |
long | getWhenCompleted()Time the store completed, or -1 if not yet completed. |
long | getWhenStarted()Time the store started. |
void | replyTimeout(Hash peer)Remove the peer from pending on timeout. |
String | toString()Debug string for this store state. |
public StoreState(RouterContext ctx, Hash key, DatabaseEntry data)
public StoreState(RouterContext ctx, Hash key, DatabaseEntry data, Set<Hash> toSkip)
key - the DatabaseEntry hashtoSkip - may be null, if non-null, all attempted and skipped targets will be added as of 0.9.53public void addPending(Hash peer)
public void addPending(Hash peer, MessageWrapper.WrappedMessage msg)
public void addSkipped(Hash peer)
public void complete(boolean completed)
completed - whether to mark the store as completedpublic boolean completed()
public long confirmed(Hash peer)
peer - the peer that confirmedpublic Set<Hash> getAttempted()
public int getAttemptedCount()
public int getCompleteCount()
public DatabaseEntry getData()
public int getPendingCount()
public MessageWrapper.WrappedMessage getPendingMessage(Hash peer)
public Hash getSuccessful()
public Hash getTarget()
public long getWhenCompleted()
public long getWhenStarted()
public void replyTimeout(Hash peer)
peer - the peer that timed out