AMPS C/C++ Client Class Reference
AMPS C/C++ Client Version 5.3.4.3
AMPS::StoreImpl Class Referenceabstract

Abstract base class for storing published messages for an HA publisher client. More...

#include <ampsplusplus.hpp>

+ Inheritance diagram for AMPS::StoreImpl:

Public Member Functions

 StoreImpl (bool errorOnPublishGap_=false)
 Default constructor. More...
 
virtual amps_uint64_t store (const Message &message_)=0
 Called by Client to store a message being published. More...
 
virtual void discardUpTo (amps_uint64_t index_)=0
 Called by Client to indicate that all messages up to and including. More...
 
virtual void replay (StoreReplayer &replayer_)=0
 Called by Client to get all stored and non-discarded messages replayed by the store onto the StoreReplayer. More...
 
virtual bool replaySingle (StoreReplayer &replayer_, amps_uint64_t index_)=0
 Called by Client to get a single message replayed by the store onto the StoreReplayer. More...
 
virtual size_t unpersistedCount () const =0
 Method to return how many messages are in the store that have not been discarded, indicating that they are not yet persisted by the AMPS server. More...
 
virtual void flush (long timeout_)=0
 Method to wait for the Store to discard everything that has been stored up to the point in time when flush is called. More...
 
virtual amps_uint64_t getLowestUnpersisted () const =0
 Get the oldest unpersisted message sequence in the store. More...
 
virtual amps_uint64_t getLastPersisted ()=0
 Get the last persisted sequence number. More...
 
virtual void setResizeHandler (PublishStoreResizeHandler handler_, void *userData_)
 Set a handler to be called if the Store needs to resize in order to keep storing messages. More...
 

Static Public Member Functions

static size_t getUnsetPosition ()
 Method to return the value used to represent not found or unset.
 
static amps_uint64_t getUnsetSequence ()
 Method to return the value used to represent no such sequence.
 

Detailed Description

Abstract base class for storing published messages for an HA publisher client.

Constructor & Destructor Documentation

AMPS::StoreImpl::StoreImpl ( bool  errorOnPublishGap_ = false)
inline

Default constructor.

Parameters
errorOnPublishGap_If true, PublishStoreGapException can be thrown by the store if the client logs onto a server that appears to be missing messages no longer held in the store.

Member Function Documentation

virtual void AMPS::StoreImpl::discardUpTo ( amps_uint64_t  index_)
pure virtual

Called by Client to indicate that all messages up to and including.

Parameters
index_have been successfully published to the server and are no longer required to be in the store.
Exceptions
PublishStoreGapExceptionIf index_ < getLastPersisted() which could leave a gap on the server of missing messages from this Client.

Implemented in AMPS::BlockPublishStore, and AMPS::HybridPublishStore.

virtual void AMPS::StoreImpl::flush ( long  timeout_)
pure virtual

Method to wait for the Store to discard everything that has been stored up to the point in time when flush is called.

It will get the current max and wait up to timeout for that message to be discarded

Parameters
timeout_The number of milliseconds to wait for the messages to be acknowledged by AMPS and discarded by the Store. 0 indicates no timeout.
Exceptions
DisconnectedExceptionThe Client is no longer connected to a server.
ConnectionExceptionAn error occurred while sending the message.
TimedOutExceptionThe publish command was not acked in the allowed time.

Implemented in AMPS::BlockPublishStore, and AMPS::HybridPublishStore.

virtual amps_uint64_t AMPS::StoreImpl::getLastPersisted ( )
pure virtual

Get the last persisted sequence number.

Returns
The sequence of the last persisted message.

Implemented in AMPS::BlockPublishStore, and AMPS::HybridPublishStore.

virtual amps_uint64_t AMPS::StoreImpl::getLowestUnpersisted ( ) const
pure virtual

Get the oldest unpersisted message sequence in the store.

Returns
The sequence of the oldest message.

Implemented in AMPS::BlockPublishStore, and AMPS::HybridPublishStore.

virtual void AMPS::StoreImpl::replay ( StoreReplayer replayer_)
pure virtual

Called by Client to get all stored and non-discarded messages replayed by the store onto the StoreReplayer.

Parameters
replayer_The StoreReplayer to be used to replay the messages.

Implemented in AMPS::BlockPublishStore, and AMPS::HybridPublishStore.

virtual bool AMPS::StoreImpl::replaySingle ( StoreReplayer replayer_,
amps_uint64_t  index_ 
)
pure virtual

Called by Client to get a single message replayed by the store onto the StoreReplayer.

Parameters
replayer_The StoreReplayer to be used to replay the messages.
index_The index of the message to replay.
Returns
Returns true for success, false for failure such as an invalid index.

Implemented in AMPS::BlockPublishStore, and AMPS::HybridPublishStore.

virtual void AMPS::StoreImpl::setResizeHandler ( PublishStoreResizeHandler  handler_,
void *  userData_ 
)
inlinevirtual

Set a handler to be called if the Store needs to resize in order to keep storing messages.

Resize could be caused by not being connected to the server, publishing messages faster than the network or AMPS can keep up, not properly discarding messages when receiving persisted acks, or AMPS being unable to complete persistence such as when its connection to a sync replication destination is unavailable.

Parameters
handler_The handler to be called when a resize event is required.
userData_The data to pass to the handler each time it is called.

Reimplemented in AMPS::HybridPublishStore.

virtual amps_uint64_t AMPS::StoreImpl::store ( const Message message_)
pure virtual

Called by Client to store a message being published.

Parameters
message_The message to store.
Returns
The sequence number for the message.

Implemented in AMPS::HybridPublishStore, and AMPS::BlockPublishStore.

virtual size_t AMPS::StoreImpl::unpersistedCount ( ) const
pure virtual

Method to return how many messages are in the store that have not been discarded, indicating that they are not yet persisted by the AMPS server.

Returns
The number of messages not yet persisted by the AMPS server.

Implemented in AMPS::BlockPublishStore, and AMPS::HybridPublishStore.


The documentation for this class was generated from the following file: