BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
RecoverableJournalQueuingStrategy.h
1 #pragma once
2 
3 #include "exporters/JournalQueuingStrategy.h"
4 
5 namespace BeeeOn {
6 
31 public:
33 
37  void setDisableTmpDataRecovery(bool disable);
38 
44  void setDisableBrokenRecovery(bool disable);
45 
50  void setDisableLostRecovery(bool disable);
51 
52  void setup() override;
53 
54 protected:
59  void collectRecoverable(std::list<Poco::File> &files) const;
60 
68  size_t recoverEntries(
69  Poco::File file,
70  std::vector<SensorData> &data) const;
71 
77  std::string recoverBrokenBuffer(Poco::File file) const;
78 
84  std::string recoverBuffer(Poco::File tmpFile) const;
85 
89  void recoverTmpData(Poco::Timestamp &newest);
90 
96  void recoverBroken(
97  const std::string &broken,
98  Poco::Timestamp &newest);
99 
106  void recoverLost(
107  std::list<Poco::File> &recoverable,
108  const Poco::Timestamp &indexModified,
109  const Poco::Timestamp &newest);
110 
111 private:
112  bool m_disableTmpDataRecovery;
113  bool m_disableBrokenRecovery;
114  bool m_disableLostRecovery;
115 };
116 
117 }
void setDisableTmpDataRecovery(bool disable)
Disable running recovery of the data.tmp file.
Definition: RecoverableJournalQueuingStrategy.cpp:41
RecoverableJournalQueuingStrategy works the same way as the JournalQueuingStrategy but it extends its...
Definition: RecoverableJournalQueuingStrategy.h:30
size_t recoverEntries(Poco::File file, std::vector< SensorData > &data) const
Read the given file and parse its contents like it is a buffer. In this way, we read as much of entri...
Definition: RecoverableJournalQueuingStrategy.cpp:109
void recoverLost(std::list< Poco::File > &recoverable, const Poco::Timestamp &indexModified, const Poco::Timestamp &newest)
From a list of potentially recoverable buffers, recover those that has newer timestamps than the newe...
Definition: RecoverableJournalQueuingStrategy.cpp:290
void recoverBroken(const std::string &broken, Poco::Timestamp &newest)
Definition: RecoverableJournalQueuingStrategy.cpp:257
void setDisableLostRecovery(bool disable)
Disable running recovery of lost buffers - ie. buffers that were not appended to index but contain re...
Definition: RecoverableJournalQueuingStrategy.cpp:51
void recoverTmpData(Poco::Timestamp &newest)
Recover the data.tmp file if present and append it to the index.
Definition: RecoverableJournalQueuingStrategy.cpp:223
std::string recoverBrokenBuffer(Poco::File file) const
Recover contents of the given file into a new file that has a valid digest. Empty files are deleted...
Definition: RecoverableJournalQueuingStrategy.cpp:146
JournalQueuingStrategy implements persistent temporary storing of SensorData into a filesystem struct...
Definition: JournalQueuingStrategy.h:40
std::string recoverBuffer(Poco::File tmpFile) const
Recover the given file as it should be a buffer. This method is useful to recover file that are not n...
Definition: RecoverableJournalQueuingStrategy.cpp:194
void setup() override
Setup the storage for the JournalQueuingStrategy. It creates new index or loads the existing one...
Definition: RecoverableJournalQueuingStrategy.cpp:56
void collectRecoverable(std::list< Poco::File > &files) const
Collect files looking like buffers that are not referenced and thus are potentially recoverable for s...
Definition: RecoverableJournalQueuingStrategy.cpp:90
void setDisableBrokenRecovery(bool disable)
Disable running recovery of broken buffers referenced from index. Such buffers are ignored (and poten...
Definition: RecoverableJournalQueuingStrategy.cpp:46