AMPS C/C++ Client Class Reference
AMPS C/C++ Client Version 5.3.5.0
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>
32 
36 
37 namespace AMPS
38 {
45  {
46  public:
54  MemoryPublishStore(size_t blockPerRealloc_, bool errorOnPublishGap_ = false)
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.
71  }
72 
73  virtual void discardUpTo(amps_uint64_t index_)
74  {
76  if (!_firstGapCheckDone)
77  {
78  _firstGapCheckDone = true;
79  }
80  }
81 
82  virtual bool getErrorOnPublishGap() const
83  {
84  return _firstGapCheckDone ? StoreImpl::getErrorOnPublishGap() : false;
85  }
86 
87  private:
88  bool _firstGapCheckDone;
89 
90  };//end MemoryPublishStore
91 
92 }//end namespace AMPS
93 
94 #endif //_MEMORYPUBLISHSTORE_H_
95 
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:73
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: ampsplusplus.hpp:103
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