Fledge
An open source edge computing platform for industrial users
purge_system.h
1 #ifndef _PURGE_SYSTEM_H
2 #define _PURGE_SYSTEM_H
3 
4 /*
5  * Fledge Statistics History
6  *
7  * Copyright (c) 2021 Dianomic Systems
8  *
9  * Released under the Apache 2.0 Licence
10  *
11  * Author: Stefano Simonelli
12  */
13 
14 #include <process.h>
15 
16 #define TO_STRING(...) DEFER(TO_STRING_)(__VA_ARGS__)
17 #define DEFER(x) x
18 #define TO_STRING_(...) #__VA_ARGS__
19 #define QUOTE(...) TO_STRING(__VA_ARGS__)
20 
21 #define LOG_NAME "purge_system"
22 #define CONFIG_CATEGORY_DESCRIPTION "Configuration of the Purge System"
23 #define CONFIG_CATEGORY_DISPLAY_NAME "Purge System"
24 
25 
26 #define UTILITIES_CATEGORY "Utilities"
27 
28 
29 class PurgeSystem : public FledgeProcess
30 {
31  public:
32  PurgeSystem(int argc, char** argv);
33  ~PurgeSystem();
34 
35  void run();
36 
37  private:
38  Logger *m_logger;
39  StorageClient *m_storage;
40  unsigned long m_retainStatsHistory;
41  unsigned long m_retainAuditLog;
42  unsigned long m_retainTaskHistory;
43 
44  private:
45  void raiseError(const char *reason, ...);
46  void purgeExecution();
47  void purgeTable(const std::string& tableName, const std::string& fieldName, unsigned long retentionDays);
48  void historicizeData(unsigned long retentionDays);
49  ResultSet *extractData(const std::string& tableName, const std::string& fieldName, unsigned long retentionDays);
50  void storeData(const std::string& tableDest, ResultSet *data);
51  void processEnd() const;
52  ConfigCategory configurationHandling(const std::string& config);
53 };
54 
55 #endif
Fledge Logger class used to log to syslog.
Definition: logger.h:26
PurgeSystem(int argc, char **argv)
Constructor for Purge system.
Definition: purge_system.cpp:75
Definition: config_category.h:56
Fledge process base class.
Definition: process.h:21
Result set.
Definition: resultset.h:32
void run()
PurgeSystem run method, called by the base class to start the process and do the actual work...
Definition: purge_system.cpp:102
Client for accessing the storage service.
Definition: storage_client.h:43
Definition: purge_system.h:29