AMPS C/C++ Client Class Reference AMPS C/C++ Client Version 5.3.5.7

Public Types | Public Member Functions | Static Public Member Functions | List of all members
AMPS::BlockPublishStore Class Reference

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>`

Inheritance diagram for AMPS::BlockPublishStore:

## Public Types
enum | Constants : amps_uint32_t
| Default constant values for BlockPublishStore.

## Public Member Functions
amps_uint32_t | getBlockSize ()
| Return the size left in a block for data when it has a header in it. More...
amps_uint32_t | getBlockDataSize ()
| Return the size left in a block for data when it has a header in it. More...
| BlockPublishStore (Buffer *buffer_, amps_uint32_t blocksPerRealloc_=1000, bool isFile_=false, bool errorOnPublishGap_=false, amps_uint32_t blockSize_=DEFAULT_BLOCK_SIZE)
| Create a BlockPublishStore using buffer_, that grows by blocksPerRealloc_ blocks when it must grow. More...
virtual | ~BlockPublishStore ()
| Destructor that cleans up the buffer and other associated memory.
virtual amps_uint64_t | store (const Message &message_)
| Store a given message that will be delivered to AMPS. More...
amps_uint64_t | store (const Message &message_, bool assignSequence_)
| Store a given message that will be delivered to AMPS. More...
virtual void | discardUpTo (amps_uint64_t index_)
| Remove all messages with an index up to and including index_. More...
void | replay (StoreReplayer &replayer_)
| Replay all messages in the Store onto the given StoreReplayer. More...
bool | replaySingle (StoreReplayer &replayer_, amps_uint64_t index_)
| Replay one message in the Store onto the given StoreReplayer. More...
size_t | unpersistedCount () const
| 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. 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...
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...
Public Member Functions inherited from AMPS::StoreImpl
| StoreImpl (bool errorOnPublishGap_=false)
| Default constructor. 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 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 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

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.

## Constructor & Destructor Documentation

## ◆ BlockPublishStore()

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

## Member Function Documentation

## ◆ discardUpTo()

virtual void AMPS::BlockPublishStore::discardUpTo | ( | amps_uint64_t | index_ | ) |
| inline virtual

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.

Reimplemented in AMPS::MemoryPublishStore.

## ◆ flush()

virtual void AMPS::BlockPublishStore::flush | ( | long | timeout_ | ) |
| inline 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.

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.

## ◆ getBlockChainHeaderSize()

static amps_uint32_t AMPS::BlockPublishStore::getBlockChainHeaderSize | ( |  | ) |
| inline static

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

## ◆ getBlockDataSize()

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

## ◆ getBlockHeaderSize()

static amps_uint32_t AMPS::BlockPublishStore::getBlockHeaderSize | ( |  | ) |
| inline static

Block header is number of blocks, total length, sequence number, crc, next in chain offset.

Returns
  The size of Block header

## ◆ getBlockSize()

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

## ◆ getLastPersisted()

amps_uint64_t AMPS::BlockPublishStore::getLastPersisted | ( | void |  | ) |
| inline virtual

Get the last persisted sequence number.

Returns
  The sequence of the last persisted message.

Implements AMPS::StoreImpl.

## ◆ getLowestUnpersisted()

amps_uint64_t AMPS::BlockPublishStore::getLowestUnpersisted | ( |  | ) | const
| inline virtual

Get the oldest unpersisted message sequence in the store.

Returns
  The sequence of the oldest message.

Implements AMPS::StoreImpl.

## ◆ replay()

void AMPS::BlockPublishStore::replay | ( | StoreReplayer & | replayer_ | ) |
| inline virtual

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

  replayer_ | The StoreReplayer that will transmit the message.

Implements AMPS::StoreImpl.

## ◆ replaySingle()

bool AMPS::BlockPublishStore::replaySingle | ( | StoreReplayer & | replayer_,
|  | amps_uint64_t | index_
| ) |  |
| inline virtual

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.

## ◆ store() [1/2]

virtual amps_uint64_t AMPS::BlockPublishStore::store | ( | const Message & | message_ | ) |
| inline virtual

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.

## ◆ store() [2/2]

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_.

## ◆ unpersistedCount()

size_t AMPS::BlockPublishStore::unpersistedCount | ( |  | ) | const
| inline virtual

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:

- include/amps/BlockPublishStore.hpp