Used as a base class for other stores in the AMPS C++ client, this is an implementation of StoreImpl that breaks a provided Buffer into uniform blocks for storing messages and tracks used and unused blocks.
More...
#include <BlockPublishStore.hpp>
|
static amps_uint32_t | getBlockHeaderSize () |
| Block header is number of blocks, total length, sequence number, crc, next in chain offset. More...
|
|
static amps_uint32_t | getBlockChainHeaderSize () |
| Block chain header is operation, command id length, correlation id length, expiration length, sow key length, topic length, sow delete flag, ack types. More...
|
|
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.
|
|
Used as a base class for other stores in the AMPS C++ client, this is an implementation of StoreImpl that breaks a provided Buffer into uniform blocks for storing messages and tracks used and unused blocks.
AMPS::BlockPublishStore::BlockPublishStore |
( |
Buffer * |
buffer_, |
|
|
amps_uint32_t |
blocksPerRealloc_ = 1000 , |
|
|
bool |
isFile_ = false , |
|
|
bool |
errorOnPublishGap_ = false , |
|
|
amps_uint32_t |
blockSize_ = DEFAULT_BLOCK_SIZE |
|
) |
| |
|
inline |
Create a BlockPublishStore using buffer_, that grows by blocksPerRealloc_ blocks when it must grow.
If isFile_ is true, it will use CRCs for all storage and retrieval.
- Parameters
-
buffer_ | Pointer to an allocated Buffer implementation that will be used for storage. The store will delete buffer_ when it is destructed. |
blocksPerRealloc_ | Number of blocks to add to when growing the size of the Buffer. |
isFile_ | Whether or not the buffer is a recoverable file. If false, the buffer is intialized as if empty, otherwise recovery remains possible and a CRC will be used for all stored items. |
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. |
blockSize_ | Size in bytes for each Block |
virtual void AMPS::BlockPublishStore::discardUpTo |
( |
amps_uint64_t |
index_ | ) |
|
|
inlinevirtual |
Remove all messages with an index up to and including index_.
This method is used internally by the Client to remove messages once they have been acknowledged by AMPS as stored on the server side.
- Parameters
-
index_ | The highest index to remove. |
- Exceptions
-
PublishStoreGapException | If index_ < getLastPersisted() which could leave a gap on the server of missing messages from this Client. |
Implements AMPS::StoreImpl.
virtual void AMPS::BlockPublishStore::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
-
DisconnectedException | The Client is no longer connected to a server. |
ConnectionException | An error occurred while sending the message. |
TimedOutException | The publish command was not acked in the allowed time. |
Implements AMPS::StoreImpl.
static amps_uint32_t AMPS::BlockPublishStore::getBlockChainHeaderSize |
( |
| ) |
|
|
inlinestatic |
Block chain header is operation, command id length, correlation id length, expiration length, sow key length, topic length, sow delete flag, ack types.
- Returns
- The size of Block chain header
amps_uint32_t AMPS::BlockPublishStore::getBlockDataSize |
( |
| ) |
|
|
inline |
Return the size left in a block for data when it has a header in it.
- Returns
- The amount of room left in a block for data
static amps_uint32_t AMPS::BlockPublishStore::getBlockHeaderSize |
( |
| ) |
|
|
inlinestatic |
Block header is number of blocks, total length, sequence number, crc, next in chain offset.
- Returns
- The size of Block header
amps_uint32_t AMPS::BlockPublishStore::getBlockSize |
( |
| ) |
|
|
inline |
Return the size left in a block for data when it has a header in it.
- Returns
- The amount of room left in a block for data
amps_uint64_t AMPS::BlockPublishStore::getLastPersisted |
( |
void |
| ) |
|
|
inlinevirtual |
Get the last persisted sequence number.
- Returns
- The sequence of the last persisted message.
Implements AMPS::StoreImpl.
amps_uint64_t AMPS::BlockPublishStore::getLowestUnpersisted |
( |
| ) |
const |
|
inlinevirtual |
Get the oldest unpersisted message sequence in the store.
- Returns
- The sequence of the oldest message.
Implements AMPS::StoreImpl.
void AMPS::BlockPublishStore::replay |
( |
StoreReplayer & |
replayer_ | ) |
|
|
inlinevirtual |
Replay all messages in the Store onto the given StoreReplayer.
This is used internally by the Client to replay any messages to the server after a successful connection or reconnection to AMPS.
- Parameters
-
Implements AMPS::StoreImpl.
bool AMPS::BlockPublishStore::replaySingle |
( |
StoreReplayer & |
replayer_, |
|
|
amps_uint64_t |
index_ |
|
) |
| |
|
inlinevirtual |
Replay one message in the Store onto the given StoreReplayer.
This is used internally by replay to replay each message.
- Parameters
-
replayer_ | The StoreReplayer that will transmit the message. |
index_ | The index of the message to replay. |
- Returns
- Returns true for success, false for failure such as an invalid index.
Implements AMPS::StoreImpl.
virtual amps_uint64_t AMPS::BlockPublishStore::store |
( |
const Message & |
message_ | ) |
|
|
inlinevirtual |
Store a given message that will be delivered to AMPS.
This method will also assign a sequence number to the Message. This method is primarily used internally by the Client to store outgoing messages.
- Parameters
-
message_ | The Message to put into the store. |
Implements AMPS::StoreImpl.
amps_uint64_t AMPS::BlockPublishStore::store |
( |
const Message & |
message_, |
|
|
bool |
assignSequence_ |
|
) |
| |
|
inline |
Store a given message that will be delivered to AMPS.
This method will also assign a sequence number to the Message if assignSequence_ is true. HybridPublishStore uses this method with false when moving messages from memory to file.
- Parameters
-
message_ | The Message to put into the store. |
assignSequence_ | If true, message_ will be updated with the next sequence number from the store. |
- Returns
- The sequence number of the message_.
size_t AMPS::BlockPublishStore::unpersistedCount |
( |
| ) |
const |
|
inlinevirtual |
Method to return the count of messages that currently in the Store because they have not been discarded, presumably because AMPS has not yet acknowledged them.
This assumes that there are no gaps in sequence numbers for better performance.
- Returns
- The count of messages in the store.
Implements AMPS::StoreImpl.
The documentation for this class was generated from the following file: