BlockPublishStore is a base class that implements the Store interface. It is designed for publish store implementations, allowing messages to be stored and managed efficiently. As messages are discarded, space in that buffer is marked "free" for future store operations. If messages are stored faster than they are published, the buffer is re-sized to create more capacity.
More...
|
virtual void | Dispose () |
| Performs implementation-defined tasks associated with freeing, releasing, or resetting resources. This method has no effect for the BlockPublishStore class. Publish store implementations that sub-class this class, should override it as needed. More...
|
|
void | store (Message m) |
| Stores a message in the BlockPublishStore. More...
|
|
void | store (Message m, Boolean assignSequence) |
| Internal utility method for storing messages in the BlockPublishStore. More...
|
|
virtual void | discardUpTo (ulong sequence) |
| Discard messages in the store, up to and including the message specified by the passed in sequnence number. This is called by the client when it's notified a message is persisted on the server. The space used by discarded messages is made available for reuse by later messages. More...
|
|
ulong | getLastPersisted () |
| Gets the last persisted sequence number More...
|
|
ulong | getLowestUnpersisted () |
| Gets the lowest unpersisted sequence number. More...
|
|
ulong | getHighestUnpersisted () |
| Gets the highest unpersisted sequence number. More...
|
|
void | setMessage (Message message) |
| Used internally by the Client to give the store a Message implementing the correct protocol for the connection. This Message instance is also used for replay operations. More...
|
|
virtual void | replay (StoreReplayer replayer) |
| Implemented to replay unpersisted messages from the stored blocks onto the provided StoreReplayer. More...
|
|
bool | replaySingle (StoreReplayer replayer, ulong sequence) |
| Implemented to find the unpersisted message with the specified sequence among the stored blocks, and replay it onto the provided StoreReplayer. Checks if the specified sequence is less than or equal to the stored metadata block's sequence number. More...
|
|
long | unpersistedCount () |
| Returns the count of unpersisted messages in the store. This count represents the number of messages that have been received but not yet persisted. More...
|
|
void | flush () |
| Wait for the store to discard everything that has been stored up to the point in time when flush is called, then return. More...
|
|
void | flush (int timeout) |
| Wait for the store to discard everything that has been stored up to the point in time when flush is called, then return. Throw an exception if this is not completed in the number of milliseconds specified by the timeout. More...
|
|
void | setResizeHandler (PublishStoreResizeHandler handler) |
| Set the resize handler for the publish store. An implementation can call the resize handler in the event that it needs to grow the size of the publish store. More...
|
|
void | setErrorOnPublishGap (bool errorOnPublishGap_) |
| Set if a PublishStoreGapException should be thrown by the Store if there is an attempt to call discardUpTo with a sequence number lower than the last persisted sequence number. This could occur during logon after a failover event if the new server was not current on messages due to being an async replication destination. More...
|
|
virtual bool | getErrorOnPublishGap () |
| Get if a PublishStoreGapException can be thrown by the Store if there is an attempt to call discardUpTo with a sequence number lower than the last persisted sequence number. This could occur during logon after a failover event if the new server was not current on messages due to being an async replication destination. More...
|
|
BlockPublishStore is a base class that implements the Store interface. It is designed for publish store implementations, allowing messages to be stored and managed efficiently. As messages are discarded, space in that buffer is marked "free" for future store operations. If messages are stored faster than they are published, the buffer is re-sized to create more capacity.
◆ BlockPublishStore() [1/2]
AMPS.Client.BlockPublishStore.BlockPublishStore |
( |
Buffer |
buffer, |
|
|
int |
blocksPerRealloc, |
|
|
bool |
errorOnPublishGap_ = false |
|
) |
| |
|
inlineprotected |
Initializes a new instance of the BlockPublishStore class with the specified buffer and block allocation configuration.
- Parameters
-
buffer | The buffer used for storing messages. |
blocksPerRealloc | The number of blocks per reallocation, determining the block allocation during buffer resizing. |
errorOnPublishGap_ | Indicates if an excpetion should be thrown if discardUpTo is called with an index below the last persisted. |
◆ BlockPublishStore() [2/2]
AMPS.Client.BlockPublishStore.BlockPublishStore |
( |
Buffer |
buffer, |
|
|
bool |
useCrc = false , |
|
|
int |
blocksPerRealloc = 10000 , |
|
|
bool |
errorOnPublishGap_ = false |
|
) |
| |
|
inlineprotected |
Initializes a new instance of the BlockPublishStore class with the specified buffer.
- Parameters
-
buffer | The buffer used for storing messages. |
useCrc | A boolean flag indicating whether to use CRC (Cyclic Redundancy Check). |
blocksPerRealloc | The number of blocks per reallocation, determining the block allocation during buffer resizing. |
errorOnPublishGap_ | Indicates if an excpetion should be thrown if discardUpTo is called with an index below the last persisted. |
◆ discardUpTo()
virtual void AMPS.Client.BlockPublishStore.discardUpTo |
( |
ulong |
sequence | ) |
|
|
inlinevirtual |
Discard messages in the store, up to and including the message specified by the passed in sequnence number. This is called by the client when it's notified a message is persisted on the server. The space used by discarded messages is made available for reuse by later messages.
- Parameters
-
sequence | The highest sequence number of the messages that can be safely discarded. The specified message and all prior messages are removed from the store. |
- Exceptions
-
StoreException | If an error occurred during discarding. |
Implements AMPS.Client.Store.
Reimplemented in AMPS.Client.MemoryPublishStore.
◆ Dispose()
virtual void AMPS.Client.BlockPublishStore.Dispose |
( |
| ) |
|
|
inlinevirtual |
◆ flush() [1/2]
void AMPS.Client.BlockPublishStore.flush |
( |
| ) |
|
|
inline |
Wait for the store to discard everything that has been stored up to the point in time when flush is called, then return.
Implements AMPS.Client.Store.
◆ flush() [2/2]
void AMPS.Client.BlockPublishStore.flush |
( |
int |
timeout | ) |
|
|
inline |
Wait for the store to discard everything that has been stored up to the point in time when flush is called, then return. Throw an exception if this is not completed in the number of milliseconds specified by the timeout.
- Parameters
-
timeout | The number of milliseconds to wait for the flush. |
- Exceptions
-
Implements AMPS.Client.Store.
◆ getErrorOnPublishGap()
virtual bool AMPS.Client.BlockPublishStore.getErrorOnPublishGap |
( |
| ) |
|
|
inlinevirtual |
Get if a PublishStoreGapException can be thrown by the Store if there is an attempt to call discardUpTo
with a sequence number lower than the last persisted sequence number. This could occur during logon after a failover event if the new server was not current on messages due to being an async replication destination.
- Returns
- True if the exception will be thrown
Implements AMPS.Client.Store.
Reimplemented in AMPS.Client.MemoryPublishStore.
◆ getHighestUnpersisted()
ulong AMPS.Client.BlockPublishStore.getHighestUnpersisted |
( |
| ) |
|
|
inline |
Gets the highest unpersisted sequence number.
- Returns
- The highest unpersisted sequence number.
◆ getLastPersisted()
ulong AMPS.Client.BlockPublishStore.getLastPersisted |
( |
| ) |
|
|
inline |
Gets the last persisted sequence number
- Returns
- The last persisted sequence number.
Implements AMPS.Client.Store.
◆ getLowestUnpersisted()
ulong AMPS.Client.BlockPublishStore.getLowestUnpersisted |
( |
| ) |
|
|
inline |
Gets the lowest unpersisted sequence number.
- Returns
- The lowest unpersisted sequence number or -1 if no sequence numbers are unpersisted.
◆ growFreeListIfEmpty()
void AMPS.Client.BlockPublishStore.growFreeListIfEmpty |
( |
| ) |
|
|
inlineprotected |
Ensures that the free list has at least one block available for use.
◆ recover()
void AMPS.Client.BlockPublishStore.recover |
( |
| ) |
|
|
inlineprotected |
Recovers the state of the BlockPublishStore by reconstructing the used and free lists from the stored blocks in the buffer.
◆ replay()
virtual void AMPS.Client.BlockPublishStore.replay |
( |
StoreReplayer |
replayer | ) |
|
|
inlinevirtual |
◆ replaySingle()
bool AMPS.Client.BlockPublishStore.replaySingle |
( |
StoreReplayer |
replayer, |
|
|
ulong |
sequence |
|
) |
| |
|
inline |
Implemented to find the unpersisted message with the specified sequence among the stored blocks, and replay it onto the provided StoreReplayer. Checks if the specified sequence is less than or equal to the stored metadata block's sequence number.
- Parameters
-
replayer | The StoreReplayer onto which the block will be replayed. |
sequence | The sequence number of the block to be replayed. |
- Returns
- True if the block is successfully replayed, false otherwise.
Implements AMPS.Client.Store.
◆ setErrorOnPublishGap()
void AMPS.Client.BlockPublishStore.setErrorOnPublishGap |
( |
bool |
errorOnPublishGap_ | ) |
|
|
inline |
Set if a PublishStoreGapException should be thrown by the Store if there is an attempt to call discardUpTo
with a sequence number lower than the last persisted sequence number. This could occur during logon after a failover event if the new server was not current on messages due to being an async replication destination.
- Parameters
-
errorOnPublishGap_ | Indicates if the exception should be thrown |
Implements AMPS.Client.Store.
◆ setMessage()
void AMPS.Client.BlockPublishStore.setMessage |
( |
Message |
message | ) |
|
|
inline |
Used internally by the Client to give the store a Message implementing the correct protocol for the connection. This Message instance is also used for replay operations.
- Parameters
-
message | A Message of the correct protocol type. |
Implements AMPS.Client.Store.
◆ setResizeHandler()
Set the resize handler for the publish store. An implementation can call the resize handler in the event that it needs to grow the size of the publish store.
- Parameters
-
handler | The resize handler to set |
Implements AMPS.Client.Store.
◆ store() [1/2]
void AMPS.Client.BlockPublishStore.store |
( |
Message |
m | ) |
|
|
inline |
Stores a message in the BlockPublishStore.
- Parameters
-
m | The message to be stored. |
- Exceptions
-
StoreException | If an error occurs during message storage. |
Implements AMPS.Client.Store.
◆ store() [2/2]
void AMPS.Client.BlockPublishStore.store |
( |
Message |
m, |
|
|
Boolean |
assignSequence |
|
) |
| |
|
inline |
Internal utility method for storing messages in the BlockPublishStore.
- Parameters
-
m | The messge to be stored. |
assignSequence | A boolean flag indicating whether to assign a sequence number to the message. |
- Exceptions
-
StoreException | If an error occurs during message storage. |
◆ unpersistedCount()
long AMPS.Client.BlockPublishStore.unpersistedCount |
( |
| ) |
|
|
inline |
Returns the count of unpersisted messages in the store. This count represents the number of messages that have been received but not yet persisted.
- Returns
- The count of unpersisted messages.
Implements AMPS.Client.Store.
The documentation for this class was generated from the following file:
- AMPS.Client/BlockPublishStore.cs