AMPS C/C++ Client Class Reference
AMPS C/C++ Client Version 5.3.5.17
MemoryPublishStore.hpp
Go to the documentation of this file.
1 //
3 // Copyright (c) 2010-2026 60East Technologies Inc., All Rights Reserved.
4 //
5 // This computer software is owned by 60East Technologies Inc. and is
6 // protected by U.S. copyright laws and other laws and by international
7 // treaties. This computer software is furnished by 60East Technologies
8 // Inc. pursuant to a written license agreement and may be used, copied,
9 // transmitted, and stored only in accordance with the terms of such
10 // license agreement and with the inclusion of the above copyright notice.
11 // This computer software or any other copies thereof may not be provided
12 // or otherwise made available to any other person.
13 //
14 // U.S. Government Restricted Rights. This computer software: (a) was
15 // developed at private expense and is in all respects the proprietary
16 // information of 60East Technologies Inc.; (b) was not developed with
17 // government funds; (c) is a trade secret of 60East Technologies Inc.
18 // for all purposes of the Freedom of Information Act; and (d) is a
19 // commercial item and thus, pursuant to Section 12.212 of the Federal
20 // Acquisition Regulations (FAR) and DFAR Supplement Section 227.7202,
21 // Government's use, duplication or disclosure of the computer software
22 // is subject to the restrictions set forth by 60East Technologies Inc..
23 //
25 
26 #ifndef _MEMORYPUBLISHSTORE_H_
27 #define _MEMORYPUBLISHSTORE_H_
28 
29 #include <amps/ampsplusplus.hpp>
32 
36 
37 namespace AMPS
38 {
45  {
46  public:
54  MemoryPublishStore(size_t blockPerRealloc_, bool errorOnPublishGap_ = false)
56  normalizeBlocksPerRealloc(
57  blockPerRealloc_, DEFAULT_BLOCK_SIZE),
58  false, errorOnPublishGap_,
59  normalizeBlockSize(
60  blockPerRealloc_, DEFAULT_BLOCK_SIZE))
61  , _firstGapCheckDone(false)
62  {
63  // We always want to restart sequencing to avoid possible duplicate in
64  // in the case where:
65  // Client is up and publishing to A with sync replication to B
66  // B goes down having persisted up to x in txn log where x < y
67  // Client goes down after publishing y
68  // Client comes back up and connects to A
69  // Logon ack from A is for x because B is still down
70  // If client started from x+1, all messages up to y would be duplicate
71  // We cannot error on publish gap in this case, since a new
72  // MemoryPublishStore has no history.
73  getLastPersisted(); // -V1053 we want the super class behavior and don't override
74  }
75 
87  MemoryPublishStore(size_t blocksPerRealloc_, amps_uint32_t blockSize_,
88  bool errorOnPublishGap_ = false)
90  normalizeBlocksPerRealloc(
91  blocksPerRealloc_, blockSize_),
92  false, errorOnPublishGap_,
93  normalizeBlockSize(blocksPerRealloc_, blockSize_))
94  , _firstGapCheckDone(false)
95  {
96  // We always want to restart sequencing to avoid possible duplicate in
97  // in the case where:
98  // Client is up and publishing to A with sync replication to B
99  // B goes down having persisted up to x in txn log where x < y
100  // Client goes down after publishing y
101  // Client comes back up and connects to A
102  // Logon ack from A is for x because B is still down
103  // If client started from x+1, all messages up to y would be duplicate
104  // We cannot error on publish gap in this case, since a new
105  // MemoryPublishStore has no history.
106  getLastPersisted(); // -V1053 we want the super class behavior and don't override
107  }
108 
109  virtual void discardUpTo(amps_uint64_t index_)
110  {
112  if (!_firstGapCheckDone)
113  {
114  _firstGapCheckDone = true;
115  }
116  }
117 
118  virtual bool getErrorOnPublishGap() const
119  {
120  return _firstGapCheckDone ? StoreImpl::getErrorOnPublishGap() : false;
121  }
122 
123  private:
124  bool _firstGapCheckDone;
125 
126  };//end MemoryPublishStore
127 
128 }//end namespace AMPS
129 
130 #endif //_MEMORYPUBLISHSTORE_H_
131 
MemoryPublishStore(size_t blocksPerRealloc_, amps_uint32_t blockSize_, bool errorOnPublishGap_=false)
Create a MemoryPublishStore with a specified initial capacity in bytes.
Definition: MemoryPublishStore.hpp:87
Provides AMPS::BlockPublishStore, a concrete implementation of a store that breaks the allocated stor...
A Buffer implementation that uses memory for storage.
Definition: MemoryStoreBuffer.hpp:50
amps_uint64_t getLastPersisted(void)
Get the last persisted sequence number.
Definition: BlockPublishStore.hpp:711
Core type, function, and class declarations for the AMPS C++ client.
virtual void discardUpTo(amps_uint64_t index_)
Remove all messages with an index up to and including index_.
Definition: MemoryPublishStore.hpp:109
Used as a base class for other stores in the AMPS C++ client, this is an implementation of StoreImpl ...
Definition: BlockPublishStore.hpp:60
Provides AMPS::MemoryStoreBuffer, used by an AMPS::HAClient to store messages in memory.
MemoryPublishStore(size_t blockPerRealloc_, bool errorOnPublishGap_=false)
Create a MemoryPublishStore with a specified initial capacity in bytes.
Definition: MemoryPublishStore.hpp:54
Definition: AMPSException.hpp:32
A StoreImpl implementation that uses MemoryStoreBuffer as its buffer to hold published messages in me...
Definition: MemoryPublishStore.hpp:44
virtual void discardUpTo(amps_uint64_t index_)
Remove all messages with an index up to and including index_.
Definition: BlockPublishStore.hpp:498