AMPS C/C++ Client Class Reference
AMPS C/C++ Client Version 5.3.3.2
AMPS::HybridPublishStore Class Reference

An implementation of StoreImpl for publication. More...

#include <HybridPublishStore.hpp>

+ Inheritance diagram for AMPS::HybridPublishStore:

Public Member Functions

 HybridPublishStore (const char *fileName_, size_t maxMemoryCapacity_)
 Create a HybridPublishStore that will use fileName_ as its file storage and stores at most maxMemoryCapacity_ messages in memory before offloading some messages to the file. More...
 
 HybridPublishStore (const std::string &fileName_, size_t maxMemoryCapacity_)
 Create a HybridPublishStore that will use fileName_ as its file storage and stores at most maxMemoryCapacity_ messages in memory before offloading some messages to the file. More...
 
void setLowWatermark (size_t lowWatermark_)
 Set how many messags remain in memory after messages get offlined. More...
 
size_t getLowWatermark ()
 Get how many messags remain in memory after messages get offlined. More...
 
void discardUpTo (amps_uint64_t index_)
 Discard all messages in the store up to and including index_. More...
 
void replay (StoreReplayer &replayer_)
 Used internally by Client to replay messages in the store to AMPS after a successful connection. More...
 
size_t unpersistedCount () const
 The number of messages in the Store that have not been discarded. More...
 
virtual void flush (long timeout_)
 Method to wait for the Store to discard everything that has been stored up to the point in time when flush is called. More...
 
bool replaySingle (StoreReplayer &replayer_, amps_uint64_t index_)
 Called by Client to get a single message replayed by the store onto the StoreReplayer. More...
 
amps_uint64_t store (const Message &message_)
 Used internally by Client to put messages into the Store. More...
 
void setResizeHandler (PublishStoreResizeHandler handler_, void *data_)
 Set a handler to be called if the Store needs to resize in order to keep storing messages. More...
 
amps_uint64_t getLowestUnpersisted () const
 Get the oldest unpersisted message sequence in the store. More...
 
amps_uint64_t getLastPersisted (void)
 Get the last persisted sequence number. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from AMPS::StoreImpl
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

An implementation of StoreImpl for publication.

This store uses memory up to a specified capacity, then starts using a file if it will exceed the set maximum memory capacity. This store does not provide guaranteed durable publication if the application is restarted. However, this store does help to limit the amount of memory consumed by a publisher when the publisher cannot connect to AMPS.

Constructor & Destructor Documentation

AMPS::HybridPublishStore::HybridPublishStore ( const char *  fileName_,
size_t  maxMemoryCapacity_ 
)
inline

Create a HybridPublishStore that will use fileName_ as its file storage and stores at most maxMemoryCapacity_ messages in memory before offloading some messages to the file.

Parameters
fileName_The name to use for the file-based storage.
maxMemoryCapacity_The maximum number of messages to store in in memory before starting to use a file.
AMPS::HybridPublishStore::HybridPublishStore ( const std::string &  fileName_,
size_t  maxMemoryCapacity_ 
)
inline

Create a HybridPublishStore that will use fileName_ as its file storage and stores at most maxMemoryCapacity_ messages in memory before offloading some messages to the file.

Parameters
fileName_The name to use for the file-based storage.
maxMemoryCapacity_The maximum number of messages to store in in memory before starting to use a file.

Member Function Documentation

void AMPS::HybridPublishStore::discardUpTo ( amps_uint64_t  index_)
inlinevirtual

Discard all messages in the store up to and including index_.

Parameters
index_The maximum index to remove from storage.

Implements AMPS::StoreImpl.

virtual void AMPS::HybridPublishStore::flush ( long  timeout_)
inlinevirtual

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.
Exceptions
DisconnectedExceptionThe Client is no longer connected to a server.
ConnectionExceptionAn error occured while sending the message.
TimedOutExceptionThe publish command was not acked in the allowed time.

Implements AMPS::StoreImpl.

amps_uint64_t AMPS::HybridPublishStore::getLastPersisted ( void  )
inlinevirtual

Get the last persisted sequence number.

Returns
The sequence of the last persisted message.

Implements AMPS::StoreImpl.

amps_uint64_t AMPS::HybridPublishStore::getLowestUnpersisted ( ) const
inlinevirtual

Get the oldest unpersisted message sequence in the store.

Returns
The sequence of the oldest message.

Implements AMPS::StoreImpl.

size_t AMPS::HybridPublishStore::getLowWatermark ( )
inline

Get how many messags remain in memory after messages get offlined.

When memory storage reaches its cap, it will write its oldest messages to its file until it is holding only lowWatermark_ messages.

Returns
The number of messages that remain in memory after offlining completes.
void AMPS::HybridPublishStore::replay ( StoreReplayer replayer_)
inlinevirtual

Used internally by Client to replay messages in the store to AMPS after a successful connection.

Parameters
replayer_The StoreReplayer that replays the messages.

Implements AMPS::StoreImpl.

bool AMPS::HybridPublishStore::replaySingle ( StoreReplayer replayer_,
amps_uint64_t  index_ 
)
inlinevirtual

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.

Implements AMPS::StoreImpl.

void AMPS::HybridPublishStore::setLowWatermark ( size_t  lowWatermark_)
inline

Set how many messags remain in memory after messages get offlined.

When memory storage reaches its cap, it will write its oldest messages to its file until it is holding only lowWatermark_ messages.

Parameters
lowWatermark_The number of messages that remain in memory after offlining completes.
void AMPS::HybridPublishStore::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 from AMPS::StoreImpl.

amps_uint64_t AMPS::HybridPublishStore::store ( const Message message_)
inlinevirtual

Used internally by Client to put messages into the Store.

Parameters
message_The Message to be stored.

Implements AMPS::StoreImpl.

size_t AMPS::HybridPublishStore::unpersistedCount ( ) const
inlinevirtual

The number of messages in the Store that have not been discarded.

Returns
The number of messages still in the Store.

Implements AMPS::StoreImpl.


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