AMPS C# Client  5.3.5.0
AMPS C# Client for .NET
AMPS.Client.HybridPublishStore Class Reference

A Store implementation that uses memory to hold the newest messages and rolls older messages over to a file. More...

+ Inheritance diagram for AMPS.Client.HybridPublishStore:

Public Member Functions

 HybridPublishStore (String path, int cap, bool errorOnPublishGap=false)
 Create a new HybridPublishStore using a <file named path, a max capacity of cap for its < MemoryPublishStore>. More...
 
void Dispose ()
 Performs application-defined tasks associated with freeing, releasing, or resetting resources. This method has no effect for the BlockPublishStore class. 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...
 
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...
 
void setLowWatermark (int lowWatermark_)
 Sets the low watermark; once we start swapping out to disk, we keep going until the number of entries in memory is lower than this. More...
 
ulong getLowestUnpersisted ()
 Gets the lowest unpersisted sequence number More...
 
void discardUpTo (ulong index)
 This method is repsonsible for managing the discarding of blocks in a store based on the specified index. It handles locking, updating metadata, and organizng the blocks for efficient reuse. More...
 
virtual void replay (StoreReplayer replayer)
 Replays the stored blocks onto the provided StoreReplayer. More...
 
bool replaySingle (StoreReplayer replayer, ulong index)
 Replays a single stored block with the specified index onto the provided StoreReplayer. Checks if the specified index 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 store (Message message)
 Stores a message in the BlockPublishStore. More...
 
void setMessage (Message m)
 Used internally by the Client to give the store a Message implementing the correct protocol for the connection. More...
 
ulong getLastPersisted ()
 Gets the last persisted sequence number 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 close ()
 Close the file access, making this store unusable. More...
 

Protected Attributes

PublishStore _fileStore
 
MemoryPublishStore _memoryStore
 
int _cap
 
string _path
 
int _lowWatermark = 0
 

Detailed Description

A Store implementation that uses memory to hold the newest messages and rolls older messages over to a file.

Constructor & Destructor Documentation

◆ HybridPublishStore()

AMPS.Client.HybridPublishStore.HybridPublishStore ( String  path,
int  cap,
bool  errorOnPublishGap = false 
)
inline

Create a new HybridPublishStore using a <file named path, a max capacity of cap for its < MemoryPublishStore>.

Parameters
pathThe file location for the file-based portion of the store.
capThe capacity on in-memory messages before offloading to file.
errorOnPublishGap_Indicates if an excpetion should be thrown if discardUpTo is called with an idex below the last persisted.

Member Function Documentation

◆ close()

void AMPS.Client.HybridPublishStore.close ( )
inline

Close the file access, making this store unusable.

◆ discardUpTo()

void AMPS.Client.HybridPublishStore.discardUpTo ( ulong  index)
inline

This method is repsonsible for managing the discarding of blocks in a store based on the specified index. It handles locking, updating metadata, and organizng the blocks for efficient reuse.

Parameters
index
Exceptions
StoreException

Implements AMPS.Client.Store.

◆ Dispose()

void AMPS.Client.HybridPublishStore.Dispose ( )
inline

Performs application-defined tasks associated with freeing, releasing, or resetting resources. This method has no effect for the BlockPublishStore class.

◆ flush() [1/2]

void AMPS.Client.HybridPublishStore.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.HybridPublishStore.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
timeoutThe number of milliseconds to wait for the flush.
Exceptions
TimedOutException

Implements AMPS.Client.Store.

◆ getErrorOnPublishGap()

bool AMPS.Client.HybridPublishStore.getErrorOnPublishGap ( )
inline

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.

◆ getLastPersisted()

ulong AMPS.Client.HybridPublishStore.getLastPersisted ( )
inline

Gets the last persisted sequence number

Returns
The last persisted sequence number.

Implements AMPS.Client.Store.

◆ getLowestUnpersisted()

ulong AMPS.Client.HybridPublishStore.getLowestUnpersisted ( )
inline

Gets the lowest unpersisted sequence number

Returns
The lowest unpersisted sequence number or -1 if no sequence numbers are unpersisted.

◆ replay()

virtual void AMPS.Client.HybridPublishStore.replay ( StoreReplayer  replayer)
inlinevirtual

Replays the stored blocks onto the provided StoreReplayer.

Parameters
replayerThe StoreReplayer onto which the blocks will be replayed.

Implements AMPS.Client.Store.

◆ replaySingle()

bool AMPS.Client.HybridPublishStore.replaySingle ( StoreReplayer  replayer,
ulong  index 
)
inline

Replays a single stored block with the specified index onto the provided StoreReplayer. Checks if the specified index is less than or equal to the stored metadata block's sequence number.

Parameters
replayerThe StoreReplayer onto which the block will be replayed.
indexThe 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.HybridPublishStore.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.

◆ setLowWatermark()

void AMPS.Client.HybridPublishStore.setLowWatermark ( int  lowWatermark_)
inline

Sets the low watermark; once we start swapping out to disk, we keep going until the number of entries in memory is lower than this.

Parameters
lowWatermark_The number of entries to serve as a low watermark.

◆ setMessage()

void AMPS.Client.HybridPublishStore.setMessage ( Message  m)
inline

Used internally by the Client to give the store a Message implementing the correct protocol for the connection.

Parameters
mA Message of the correct protocol type.

Implements AMPS.Client.Store.

◆ setResizeHandler()

void AMPS.Client.HybridPublishStore.setResizeHandler ( PublishStoreResizeHandler  handler)
inline

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
handlerThe resize handler to set

Implements AMPS.Client.Store.

◆ store()

void AMPS.Client.HybridPublishStore.store ( Message  message)
inline

Stores a message in the BlockPublishStore.

Parameters
mThe message to be stored.
Exceptions
StoreExceptionIf an error occurs during message storage.

Implements AMPS.Client.Store.

◆ unpersistedCount()

long AMPS.Client.HybridPublishStore.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: