28 #ifndef _LOGGEDBOOKMARKSTORE_H_ 29 #define _LOGGEDBOOKMARKSTORE_H_ 40 #include <sys/types.h> 47 typedef char* amps_iovec_base_ptr;
49 typedef void* amps_iovec_base_ptr;
65 static void _clearBookmark(std::pair<const Message::Field, size_t>& pair)
71 typedef HANDLE FileType;
85 , _file(INVALID_HANDLE_VALUE)
89 , _fileName(fileName_)
101 , _file(INVALID_HANDLE_VALUE)
105 , _fileName(fileName_)
136 Subscription* sub = (Subscription*)(message_.getSubscriptionHandle());
137 Lock<Mutex> guard(_lock);
144 message_.setSubscriptionHandle(static_cast<amps_subscription_handle>(sub));
146 write(_file, sub->id(), ENTRY_BOOKMARK, bookmark);
147 return MemoryBookmarkStore::_log(message_);
160 Lock<Mutex> guard(_lock);
161 write(_file, subId, ENTRY_DISCARD, bookmark);
162 MemoryBookmarkStore::_discard(message_);
174 Lock<Mutex> l(_lock);
175 Subscription::Entry* entry = find(subId_)->getEntryByIndex(bookmarkSeqNo_);
176 if (!entry || entry->_val.empty())
return;
177 write(_file, subId_, ENTRY_DISCARD, entry->_val);
178 MemoryBookmarkStore::_discard(subId_, bookmarkSeqNo_);
188 Lock<Mutex> l(_lock);
202 Lock<Mutex> l(_lock);
203 bool retVal = MemoryBookmarkStore::_isDiscarded(message_);
209 write(_file, subId, ENTRY_BOOKMARK, message_.
getBookmark());
210 write(_file, subId, ENTRY_DISCARD, message_.
getBookmark());
222 Lock<Mutex> guard(_lock);
224 if(_file != INVALID_HANDLE_VALUE)
226 DeleteFileA(_fileName.c_str());
227 _file = CreateFileA(_fileName.c_str(), GENERIC_READ | GENERIC_WRITE, 0,
228 NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
229 if( _file == INVALID_HANDLE_VALUE )
231 DWORD err = getErrorNo();
232 std::ostringstream os;
233 os <<
"Failed to create file " << _fileName <<
" for LoggedBookmarkStore";
234 error(os.str(), err);
239 ::unlink(_fileName.c_str());
240 _file = open(_fileName.c_str(), O_RDWR | O_CREAT, (mode_t)0644);
243 error(
"Failed to open log file for LoggedBookmarkStore", getErrorNo());
247 MemoryBookmarkStore::_purge();
257 Lock<Mutex> guard(_lock);
258 MemoryBookmarkStore::_purge(subId_);
259 std::string tmpFileName = _fileName +
".tmp";
260 __prune(tmpFileName);
279 void _prune(std::string tmpFileName_)
281 if (tmpFileName_.empty())
283 tmpFileName_ = _fileName +
".tmp";
285 Lock<Mutex> guard(_lock);
291 __prune(tmpFileName_);
292 _recentChanged =
false;
295 void __prune(std::string tmpFileName_)
299 tmpFile = CreateFileA(tmpFileName_.c_str(), GENERIC_READ | GENERIC_WRITE, 0,
300 NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
301 if(tmpFile == INVALID_HANDLE_VALUE )
303 DWORD err = getErrorNo();
304 std::ostringstream os;
305 os <<
"Failed to open log file " << tmpFileName_ <<
306 " for LoggedBookmarkStore";
307 error(os.str(), err);
312 tmpFile = open(tmpFileName_.c_str(), O_RDWR | O_CREAT, (mode_t)0644);
315 int err = getErrorNo();
316 std::ostringstream os;
317 os <<
"Failed to open log file " << tmpFileName_ <<
318 " for LoggedBookmarkStore";
319 error(os.str(), err);
325 for (SubscriptionMap::iterator i = _subs.begin();
326 i != _subs.end(); ++i)
329 assert(!subId.
empty());
331 amps_uint64_t recentPub, recentSeq;
332 Subscription::parseBookmark(recent, recentPub, recentSeq);
333 Subscription::PublisherMap publishersDiscarded =
334 i->second->_publishers;
335 MemoryBookmarkStore::EntryPtrList recovered;
336 i->second->getRecoveryEntries(recovered);
337 i->second->setPublishersToDiscarded(&recovered,
338 &publishersDiscarded);
339 char tmpBookmarkBuffer[128];
340 for (Subscription::PublisherIterator pub =
341 publishersDiscarded.begin(),
342 e = publishersDiscarded.end();
346 if (pub->first == 0 || pub->second == 0)
continue;
348 if (pub->first == recentPub)
continue;
349 int written = AMPS_snprintf_amps_uint64_t(
351 sizeof(tmpBookmarkBuffer),
353 *(tmpBookmarkBuffer+written++) =
'|';
354 written += AMPS_snprintf_amps_uint64_t(
355 tmpBookmarkBuffer+written,
356 sizeof(tmpBookmarkBuffer)
359 *(tmpBookmarkBuffer+written++) =
'|';
361 write(tmpFile, subId, ENTRY_BOOKMARK, tmpBookmark);
362 write(tmpFile, subId, ENTRY_DISCARD, tmpBookmark);
364 if (isWritableBookmark(recent.len()))
366 write(tmpFile, subId, ENTRY_BOOKMARK, recent);
367 write(tmpFile, subId, ENTRY_DISCARD, recent);
371 i->second->getMostRecentList();
373 if (isWritableBookmark(i->second->getLastPersisted().len()))
375 write(tmpFile, subId, ENTRY_PERSISTED,
376 i->second->getLastPersisted());
378 i->second->getActiveEntries(recovered);
379 for (MemoryBookmarkStore::EntryPtrList::iterator entry =
381 entry != recovered.end(); ++entry)
383 if ((*entry)->_val.empty() ||
384 !isWritableBookmark((*entry)->_val.len()))
386 write(tmpFile, subId, ENTRY_BOOKMARK, (*entry)->_val);
387 if (!(*entry)->_active)
388 write(tmpFile, subId, ENTRY_DISCARD, (*entry)->_val);
392 catch (StoreException& ex)
395 CloseHandle(tmpFile);
396 DeleteFileA(tmpFileName_.c_str());
399 unlink(tmpFileName_.c_str());
401 std::ostringstream os;
402 os <<
"Exception during prune: " << ex.what();
403 throw StoreException(os.str());
407 CloseHandle(tmpFile);
408 _file = INVALID_HANDLE_VALUE;
409 tmpFile = INVALID_HANDLE_VALUE;
412 while (!MoveFileExA(tmpFileName_.c_str(), _fileName.c_str(),
413 MOVEFILE_COPY_ALLOWED|MOVEFILE_REPLACE_EXISTING|MOVEFILE_WRITE_THROUGH))
415 DWORD err = getErrorNo();
416 if (--retryCount > 0)
continue;
418 std::string desiredFileName = _fileName;
419 _fileName = tmpFileName_;
421 std::ostringstream os;
422 os <<
"Failed to move completed temp file " << tmpFileName_
423 <<
" to " << desiredFileName
424 <<
" in prune in LoggedBookmarkStore. Continuing by using " 425 << tmpFileName_ <<
" as the LoggedBookmarkStore file.";
426 error(os.str(), err);
430 SetFilePointer(_file, 0, NULL, FILE_END);
434 if (-1 == ::unlink(_fileName.c_str()))
436 int err = getErrorNo();
438 std::string desiredFileName = _fileName;
439 _fileName = tmpFileName_;
441 std::ostringstream os;
442 os <<
"Failed to delete file " << desiredFileName
443 <<
" after creating temporary file " << tmpFileName_
444 <<
" in prune in LoggedBookmarkStore. Continuing by using " 445 << tmpFileName_ <<
" as the LoggedBookmarkStore file.";
446 error(os.str(), err);
449 if (-1 == ::rename(tmpFileName_.c_str(), _fileName.c_str()))
451 int err = getErrorNo();
453 std::string desiredFileName = _fileName;
454 _fileName = tmpFileName_;
456 std::ostringstream os;
457 os <<
"Failed to move completed temp file " << tmpFileName_
458 <<
" to " << desiredFileName
459 <<
" in prune in LoggedBookmarkStore. Continuing by using " 460 << tmpFileName_ <<
" as the LoggedBookmarkStore file.";
461 error(os.str(), err);
466 if (-1 == ::fstat(_file, &fst))
468 int err = getErrorNo();
469 std::ostringstream os;
470 os <<
"Failed to get size of pruned file " << _fileName
471 <<
" in prune in LoggedBookmarkStore. ";
472 error(os.str(), err);
475 ::lseek(_file, (off_t)fst.st_size, SEEK_SET);
480 virtual void _persisted(Subscription* subP_,
483 Lock<Mutex> guard(_lock);
484 write(_file, subP_->id(), ENTRY_PERSISTED, bookmark_);
485 MemoryBookmarkStore::_persisted(subP_, bookmark_);
488 virtual Message::Field _persisted(Subscription* subP_,
size_t bookmark_)
490 Lock<Mutex> l(_lock);
491 Subscription::Entry* entryPtr = subP_->getEntryByIndex(bookmark_);
492 if (!entryPtr || entryPtr->_val.empty())
495 write(_file, subP_->id(), ENTRY_PERSISTED, bookmarkField);
496 MemoryBookmarkStore::_persisted(subP_, bookmarkField);
497 return bookmarkField;
501 typedef DWORD ERRTYPE ;
502 ERRTYPE getErrorNo()
const 504 return GetLastError();
507 void error(
const std::string& message_, ERRTYPE err)
509 std::ostringstream os;
510 static const DWORD msgSize = 2048;
512 DWORD sz = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM|
513 FORMAT_MESSAGE_ARGUMENT_ARRAY,
514 NULL, err, LANG_NEUTRAL,
515 pMsg, msgSize, NULL);
516 os <<
"File: " << _fileName <<
". " << message_;
519 os <<
" with error " << pMsg;
521 throw StoreException(os.str());
525 ERRTYPE getErrorNo()
const 530 void error(
const std::string& message_, ERRTYPE err)
532 std::ostringstream os;
533 os <<
"File: " << _fileName <<
". " << message_;
536 os <<
" with error " << strerror(err);
539 throw StoreException(os.str());
546 _file = CreateFileA(_fileName.c_str(), GENERIC_READ | GENERIC_WRITE, 0,
547 NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
548 if( _file == INVALID_HANDLE_VALUE )
550 DWORD err = getErrorNo();
551 std::ostringstream os;
552 os <<
"Failed to open log file " << _fileName <<
" for LoggedBookmarkStore";
553 error(os.str(), err);
557 _file = open(_fileName.c_str(), O_RDWR | O_CREAT, (mode_t)0644);
560 int err = getErrorNo();
561 std::ostringstream os;
562 os <<
"Failed to open log file " << _fileName <<
" for LoggedBookmarkStore";
563 error(os.str(), err);
572 void write(FileType file_,
const Message::Field& subId_,
char type_,
575 Lock<Mutex> guard(_fileLock);
576 if(!_recovering && isWritableBookmark(bookmark_.
len()))
580 size_t len = subId_.
len();
581 BOOL ok =WriteFile(file_, (LPVOID)&len,
sizeof(
size_t), &written, NULL);
582 ok |= WriteFile(file_, (LPVOID)subId_.
data(), (DWORD)len, &written, NULL);
583 ok |= WriteFile(file_, (LPVOID)&type_, 1, &written, NULL);
584 len = bookmark_.
len();
585 ok |= WriteFile(file_, (LPVOID)&len,
sizeof(
size_t), &written, NULL);
586 ok |= WriteFile(file_, (LPVOID)bookmark_.
data(), (DWORD)len,
590 error(
"Failed to write bookmark to file", getErrorNo());
597 file_ = open(_fileName.c_str(), O_RDWR | O_CREAT, (mode_t)0644);
600 int err = getErrorNo();
601 std::ostringstream os;
602 os <<
"Failed to open file " << _fileName
603 <<
" for use in LoggedBookmarkStore. ";
604 error(os.str(), err);
608 struct iovec data[5];
609 size_t len = subId_.
len();
610 data[0].iov_base = (amps_iovec_base_ptr)(
void*)&len;
611 data[0].iov_len =
sizeof(size_t);
612 data[1].iov_base = (amps_iovec_base_ptr)(
void*)subId_.
data();
613 data[1].iov_len = len;
614 data[2].iov_base = (amps_iovec_base_ptr)(
void*)&type_;
616 size_t bookmarkLen = bookmark_.
len();
617 data[3].iov_base = (amps_iovec_base_ptr)(
void*)&bookmarkLen;
618 data[3].iov_len =
sizeof(size_t);
619 data[4].iov_base = (amps_iovec_base_ptr)(
void*)bookmark_.
data();
620 data[4].iov_len = bookmarkLen;
621 ssize_t written = ::writev(file_, data, 5);
624 error(
"Failed to write to bookmark log.", getErrorNo());
635 char type_,
size_t bookmark_)
637 Lock<Mutex> guard(_fileLock);
642 size_t len = subId_.
len();
643 BOOL ok =WriteFile(file_, (LPVOID)&len,
sizeof(
size_t), &written, NULL);
644 ok |= WriteFile(file_, (LPVOID)subId_.
data(), (DWORD)len, &written, NULL);
645 ok |= WriteFile(file_, (LPVOID)&type_, 1, &written, NULL);
646 ok |= WriteFile(file_, (LPVOID)&bookmark_,
sizeof(
size_t),
650 error(
"Failed to write bookmark to file", getErrorNo());
657 file_ = open(_fileName.c_str(), O_RDWR | O_CREAT, (mode_t)0644);
660 int err = getErrorNo();
661 std::ostringstream os;
662 os <<
"Failed to open file " << _fileName
663 <<
" for use in LoggedBookmarkStore. ";
664 error(os.str(), err);
668 struct iovec data[4];
669 size_t len = subId_.
len();
670 data[0].iov_base = (amps_iovec_base_ptr)(
void*)&len;
671 data[0].iov_len =
sizeof(size_t);
672 data[1].iov_base = (amps_iovec_base_ptr)(
void*)subId_.
data();
673 data[1].iov_len = len;
674 data[2].iov_base = (amps_iovec_base_ptr)(
void*)&type_;
676 data[3].iov_base = (amps_iovec_base_ptr)(
void*)&bookmark_;
677 data[3].iov_len =
sizeof(size_t);
678 ssize_t written = ::writev(file_, data, 4);
681 error(
"Failed to write to bookmark log.", getErrorNo());
689 #define VOID_P(buf) (LPVOID)buf 690 bool readFileBytes(LPVOID buffer,
size_t numBytes, DWORD *bytesRead)
692 return (ReadFile(_file, buffer, (DWORD)numBytes, bytesRead, NULL) == TRUE);
695 #define VOID_P(buf) (void*)buf 696 bool readFileBytes(
void* buffer,
size_t numBytes, ssize_t *bytesRead)
698 *bytesRead = ::read(_file, buffer, numBytes);
699 return (*bytesRead >= 0);
705 size_t resizeLen = 128;
706 size_t bufferLen = 128;
707 char* buffer =
new char[bufferLen];
708 size_t subIdBufferLen = 128;
709 char* subIdBuffer =
new char[bufferLen];
713 size_t bookmarkLen = 0;
714 Lock<Mutex> l(_lock);
715 Lock<Mutex> guard(_fileLock);
719 SetFilePointer(_file, 0, NULL, FILE_BEGIN);
720 LARGE_INTEGER lifileSize;
721 if(GetFileSizeEx(_file, &lifileSize) == 0)
723 DWORD err = getErrorNo();
725 delete[] subIdBuffer;
727 error(
"Failure getting file size while trying to recover.", err);
732 size_t fileSize = lifileSize.QuadPart;
734 size_t fileSize = lifileSize.LowPart;
738 ::lseek(_file, loc, SEEK_SET);
740 ::fstat(_file, &fst);
741 ssize_t fileSize = fst.st_size;
742 ssize_t readBytes = 0;
744 if (!readFileBytes(VOID_P(&subLen),
sizeof(
size_t), &readBytes)
748 delete[] subIdBuffer;
750 error(
"Failure reading file while trying to recover.", getErrorNo());
754 size_t totalBytes = readBytes;
756 ssize_t totalBytes = readBytes;
759 size_t tooManyBytes = 0;
761 Message::Field::FieldHash> BookmarkMap;
762 typedef std::map<Message::Field, size_t,
763 Message::Field::FieldHash>::iterator BookmarkMapIter;
765 typedef std::map<Message::Field, BookmarkMap*,
766 Message::Field::FieldHash> ReadMap;
767 typedef std::map<Message::Field, BookmarkMap*,
768 Message::Field::FieldHash>::iterator ReadMapIter;
770 while(subLen > 0 && (
size_t)readBytes ==
sizeof(
size_t) &&
771 (
size_t)totalBytes <= (
size_t)fileSize)
773 if (subLen >= ((
size_t)fileSize - (
size_t)totalBytes)
776 tooManyBytes = subLen + 1;
782 while(subIdBufferLen < subLen)
784 char* old = subIdBuffer;
785 subIdBufferLen += resizeLen;
786 subIdBuffer =
new char[subIdBufferLen];
789 if (!readFileBytes(VOID_P(subIdBuffer), subLen, &readBytes))
792 tooManyBytes = subLen;
795 totalBytes += readBytes;
796 sub.assign(subIdBuffer, subLen);
797 if (!readFileBytes(VOID_P(buffer), 1, &readBytes))
803 totalBytes += readBytes;
808 if ((
size_t)totalBytes +
sizeof(
size_t) >= (
size_t)fileSize)
812 tooManyBytes =
sizeof(size_t);
815 if (!readFileBytes(VOID_P(&bookmarkLen),
sizeof(size_t), &readBytes))
818 tooManyBytes =
sizeof(size_t);
821 totalBytes += readBytes;
822 if (bookmarkLen > AMPS_MAX_BOOKMARK_LEN
823 || bookmarkLen > (
size_t)fileSize - (size_t)totalBytes)
827 tooManyBytes = bookmarkLen;
830 while(bufferLen < bookmarkLen)
834 buffer =
new char[bufferLen];
837 if (!readFileBytes(VOID_P(buffer), bookmarkLen, &readBytes))
840 tooManyBytes = bookmarkLen;
843 totalBytes += readBytes;
844 bookmarkField.assign(buffer, bookmarkLen);
845 Subscription* subP = find(sub);
846 BookmarkMap* bookmarks = NULL;
847 ReadMapIter iter = recovered.find(sub);
848 if (iter == recovered.end())
850 Message::Field subKey;
852 bookmarks =
new BookmarkMap();
853 recovered[subKey] = bookmarks;
857 bookmarks = iter->second;
859 if (bookmarks->find(bookmarkField) != bookmarks->end())
861 std::for_each(bookmarks->begin(), bookmarks->end(),
864 subP->getMostRecent();
866 if (!subP->isDiscarded(bookmarkField))
868 size_t sequence = subP->log(bookmarkField);
871 bookmarks->insert(std::make_pair(copy, sequence));
879 bookmarks->insert(std::make_pair(copy,0));
886 if ((
size_t)totalBytes +
sizeof(
size_t) >= (
size_t)fileSize)
890 tooManyBytes =
sizeof(size_t);
893 if (!readFileBytes(VOID_P(&bookmarkLen),
sizeof(size_t), &readBytes))
896 tooManyBytes =
sizeof(size_t);
899 totalBytes += readBytes;
900 if (bookmarkLen > AMPS_MAX_BOOKMARK_LEN
901 || bookmarkLen > (
size_t)fileSize - (size_t)totalBytes)
905 tooManyBytes = bookmarkLen;
908 while(bufferLen < bookmarkLen)
912 buffer =
new char[bufferLen];
915 if (!readFileBytes(VOID_P(buffer), bookmarkLen, &readBytes))
918 tooManyBytes = bookmarkLen;
921 totalBytes += readBytes;
922 bookmarkField.assign(buffer, bookmarkLen);
923 size_t sequence = AMPS_UNSET_INDEX;
924 ReadMapIter iter = recovered.find(sub);
925 if (iter != recovered.end())
927 BookmarkMap* bookmarks = iter->second;
928 BookmarkMapIter bookmarkIter = bookmarks->find(bookmarkField);
929 if (bookmarkIter != bookmarks->end())
931 sequence = bookmarkIter->second;
932 Message::Field bookmarkToClear(bookmarkIter->first);
933 bookmarkToClear.
clear();
934 bookmarks->erase(bookmarkIter);
937 Subscription* subP = find(sub);
938 if (sequence != AMPS_UNSET_INDEX)
941 if (sequence) subP->discard(sequence);
945 subP->discard(bookmarkField);
949 case ENTRY_PERSISTED:
951 if ((
size_t)totalBytes +
sizeof(
size_t) >= (
size_t)fileSize)
955 tooManyBytes =
sizeof(size_t);
958 if (!readFileBytes(VOID_P(&bookmarkLen),
sizeof(size_t), &readBytes))
961 tooManyBytes =
sizeof(size_t);
964 totalBytes += readBytes;
965 if (bookmarkLen > AMPS_MAX_BOOKMARK_LEN
966 || bookmarkLen > (
size_t)fileSize - (size_t)totalBytes)
970 tooManyBytes = bookmarkLen;
973 while(bufferLen < bookmarkLen)
977 buffer =
new char[bufferLen];
980 if (!readFileBytes(VOID_P(buffer), bookmarkLen, &readBytes))
983 tooManyBytes = bookmarkLen;
986 totalBytes += readBytes;
987 bookmarkField.assign(buffer, bookmarkLen);
988 Subscription* subP = find(sub);
989 MemoryBookmarkStore::_persisted(subP, bookmarkField);
995 tooManyBytes = (size_t)fileSize - (
size_t)totalBytes;
1002 if (!readFileBytes(VOID_P(&subLen),
sizeof(size_t), &readBytes))
1005 tooManyBytes =
sizeof(size_t);
1008 totalBytes += readBytes;
1011 delete[] subIdBuffer;
1014 for (SubscriptionMap::iterator i=_subs.begin(); i != _subs.end(); ++i)
1016 if (recovered.count(i->first) && !recovered[i->first]->empty())
1018 if (i->second->getMostRecent(
false).len() > 1)
1020 i->second->justRecovered();
1027 _subs[i->first] =
new Subscription(
this, i->first);
1032 for (ReadMapIter i = recovered.begin(), e = recovered.end(); i!=e; ++i)
1034 std::for_each(i->second->begin(), i->second->end(), _clearBookmark);
1036 Message::Field f = i->first;
1039 _recovering =
false;
1045 if (err != (ERRTYPE)-1 || loc == 0 || fileSize - loc > 128)
1047 std::ostringstream os;
1048 os <<
"Error while recovering LoggedBookmarkStore from " 1050 <<
". Record starting at " << loc
1051 <<
" reading at " << totalBytes
1052 <<
" requested " << tooManyBytes
1053 <<
" and file size is " << fileSize;
1054 error(os.str(), (err != (ERRTYPE)-1 ? err : 0));
1060 LONG low = (LONG)loc;
1061 LONG high = (LONG)((loc >> 32)&0xffffffff);
1062 SetFilePointer(_file, low, &high, FILE_BEGIN);
1064 SetFilePointer(_file, loc, NULL, FILE_BEGIN);
1067 ::lseek(_file, loc, SEEK_SET);
1076 std::string _fileName;
1083 #endif // _LOGGEDBOOKMARKSTORE_H_ virtual bool isDiscarded(Message &message_)
Called for each arriving message to determine if the application has already seen this bookmark and s...
Definition: LoggedBookmarkStore.hpp:200
Field getSubscriptionId() const
Retrieves the value of the SubscriptionId header of the Message as a new Field.
Definition: Message.hpp:1051
virtual Message::Field getMostRecent(const Message::Field &subId_)
Returns the most recent bookmark from the log that ought to be used for (re-)subscriptions.
Definition: MemoryBookmarkStore.hpp:984
LoggedBookmarkStore(const char *fileName_)
Creates a LoggedBookmarkStore using fileName_ as its file storage.
Definition: LoggedBookmarkStore.hpp:82
Message encapsulates a single message sent to or received from an AMPS server, and provides methods f...
Definition: Message.hpp:393
void setServerVersion(const VersionInfo &version_)
Internally used to set the server version so the store knows how to deal with persisted acks and call...
Definition: LoggedBookmarkStore.hpp:268
Provides AMPS::MemoryBookmarkStore, a bookmark store that holds bookmarks in memory.
void clear()
Deletes the data associated with this Field, should only be used on Fields that were created as deepC...
Definition: Field.hpp:196
virtual void discard(const Message::Field &subId_, size_t bookmarkSeqNo_)
Definition: LoggedBookmarkStore.hpp:172
const char * data() const
Returns the (non-null-terminated) data underlying this field.
Definition: Field.hpp:206
void setServerVersion(size_t version_)
Internally used to set the server version so the store knows how to deal with persisted acks and call...
Definition: LoggedBookmarkStore.hpp:273
Field getSubscriptionIds() const
Retrieves the value of the SubscriptionIds header of the Message as a new Field.
Definition: Message.hpp:1074
bool empty() const
Returns 'true' if empty, 'false' otherwise.
Definition: Field.hpp:93
LoggedBookmarkStore(const std::string &fileName_)
Creates a LoggedBookmarkStore using a file name fileName_.
Definition: LoggedBookmarkStore.hpp:98
Core type, function, and class declarations for the AMPS C++ client.
A BookmarkStoreImpl implementation that logs all messages to a file.
Definition: LoggedBookmarkStore.hpp:62
size_t len() const
Returns the length of the data underlying this field.
Definition: Field.hpp:213
void setServerVersion(const VersionInfo &version_)
Internally used to set the server version so the store knows how to deal with persisted acks and call...
Definition: MemoryBookmarkStore.hpp:1076
virtual void purge(const Message::Field &subId_)
Called to purge the contents of this store for particular subId.
Definition: LoggedBookmarkStore.hpp:255
virtual void noPersistedAcks(const Message::Field &subId_)
Flag the subscription as not requesting persisted acks No persisted acks will be sent for any bookmar...
Definition: LoggedBookmarkStore.hpp:263
virtual void noPersistedAcks(const Message::Field &subId_)
Flag the subscription as not requesting persisted acks No persisted acks will be sent for any bookmar...
Definition: MemoryBookmarkStore.hpp:1065
virtual void purge()
Called to purge the contents of this store.
Definition: LoggedBookmarkStore.hpp:220
virtual Message::Field getMostRecent(const Message::Field &subId_)
Returns the most recent bookmark from the log that ought to be used for (re-)subscriptions.
Definition: LoggedBookmarkStore.hpp:186
A BookmarkStoreImpl implmentation that stores bookmarks in memory.
Definition: MemoryBookmarkStore.hpp:50
Field represents the value of a single field in a Message.
Definition: Field.hpp:52
size_t getMaxSubIdLength() const
Gets the maximum allowed length for a sub id when recovering a bookmark store from persistent storage...
Definition: ampsplusplus.hpp:811
virtual size_t log(Message &message_)
Log a bookmark to the persistent log and return the corresponding sequence number for this bookmark...
Definition: LoggedBookmarkStore.hpp:133
void deepCopy(const Field &orig_)
Makes self a deep copy of the original field.
Definition: Field.hpp:167
Definition: ampsplusplus.hpp:136
Field getBookmark() const
Retrieves the value of the Bookmark header of the Message as a new Field.
Definition: Message.hpp:1064
virtual void discard(const Message &message_)
Log a Message as discarded from the store.
Definition: LoggedBookmarkStore.hpp:154