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

MemoryPublishStore.hpp
Go to the documentation of this file.
1 //
3 // Copyright (c) 2010-2025 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>
30 #include <amps/BlockPublishStore.hpp>
31 #include <amps/MemoryStoreBuffer.hpp>
32
36
37 namespace AMPS
38 {
44 class MemoryPublishStore : public BlockPublishStore
45 {
46 public:
54 MemoryPublishStore(size_t blockPerRealloc_, bool errorOnPublishGap_ = false)
55 : BlockPublishStore(new MemoryStoreBuffer(),
56 (amps_uint32_t)blockPerRealloc_,
57 false, errorOnPublishGap_)
58 , _firstGapCheckDone(false)
59 {
60 // We always want to restart sequencing to avoid possible duplicate in
61 // in the case where:
62 // Client is up and publishing to A with sync replication to B
63 // B goes down having persisted up to x in txn log where x < y
64 // Client goes down after publishing y
65 // Client comes back up and connects to A
66 // Logon ack from A is for x because B is still down
67 // If client started from x+1, all messages up to y would be duplicate
68 // We cannot error on publish gap in this case, since a new
69 // MemoryPublishStore has no history.
70 getLastPersisted();
71 }
72
84 MemoryPublishStore(size_t blocksPerRealloc_, amps_uint32_t blockSize_,
85 bool errorOnPublishGap_ = false)
86 : BlockPublishStore(new MemoryStoreBuffer(),
87 (amps_uint32_t)blocksPerRealloc_,
88 false, errorOnPublishGap_, blockSize_)
89 , _firstGapCheckDone(false)
90 {
91 // We always want to restart sequencing to avoid possible duplicate in
92 // in the case where:
93 // Client is up and publishing to A with sync replication to B
94 // B goes down having persisted up to x in txn log where x < y
95 // Client goes down after publishing y
96 // Client comes back up and connects to A
97 // Logon ack from A is for x because B is still down
98 // If client started from x+1, all messages up to y would be duplicate
99 // We cannot error on publish gap in this case, since a new
100 // MemoryPublishStore has no history.
101 getLastPersisted();
102 }
103
104 virtual void discardUpTo(amps_uint64_t index_)
105 {
106 BlockPublishStore::discardUpTo(index_);
107 if (!_firstGapCheckDone)
108 {
109 _firstGapCheckDone = true;
110 }
111 }
112
113 virtual bool getErrorOnPublishGap() const
114 {
115 return _firstGapCheckDone ? StoreImpl::getErrorOnPublishGap() : false;
116 }
117
118 private:
119 bool _firstGapCheckDone;
120
121 };//end MemoryPublishStore
122
123 }//end namespace AMPS
124
125 #endif //_MEMORYPUBLISHSTORE_H_
126
BlockPublishStore.hpp
Provides AMPS::BlockPublishStore, a concrete implementation of a store that breaks the allocated stor...
MemoryStoreBuffer.hpp
Provides AMPS::MemoryStoreBuffer, used by an AMPS::HAClient to store messages in memory.
ampsplusplus.hpp
Core type, function, and class declarations for the AMPS C++ client.
AMPS::BlockPublishStore
Used as a base class for other stores in the AMPS C++ client, this is an implementation of StoreImpl ...
Definition: BlockPublishStore.hpp:61
AMPS::BlockPublishStore::discardUpTo
virtual void discardUpTo(amps_uint64_t index_)
Remove all messages with an index up to and including index_.
Definition: BlockPublishStore.hpp:498
AMPS::BlockPublishStore::getLastPersisted
amps_uint64_t getLastPersisted(void)
Get the last persisted sequence number.
Definition: BlockPublishStore.hpp:711
AMPS::MemoryPublishStore
A StoreImpl implementation that uses MemoryStoreBuffer as its buffer to hold published messages in me...
Definition: MemoryPublishStore.hpp:45
AMPS::MemoryPublishStore::discardUpTo
virtual void discardUpTo(amps_uint64_t index_)
Remove all messages with an index up to and including index_.
Definition: MemoryPublishStore.hpp:104
AMPS::MemoryPublishStore::MemoryPublishStore
MemoryPublishStore(size_t blocksPerRealloc_, amps_uint32_t blockSize_, bool errorOnPublishGap_=false)
Create a MemoryPublishStore with a specified initial capacity in bytes.
Definition: MemoryPublishStore.hpp:84
AMPS::MemoryPublishStore::MemoryPublishStore
MemoryPublishStore(size_t blockPerRealloc_, bool errorOnPublishGap_=false)
Create a MemoryPublishStore with a specified initial capacity in bytes.
Definition: MemoryPublishStore.hpp:54
AMPS::MemoryStoreBuffer
A Buffer implementation that uses memory for storage.
Definition: MemoryStoreBuffer.hpp:51