CernVM-FS  2.13.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
statistics_database.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_STATISTICS_DATABASE_H_
6 #define CVMFS_STATISTICS_DATABASE_H_
7 
8 #include <ctime>
9 #include <string>
10 
11 #include "options.h"
12 #include "sql.h"
13 #include "statistics.h"
14 #include "upload.h"
15 #include "util/posix.h"
16 #include "util/string.h"
17 
18 struct Stats;
19 
20 class StatisticsDatabase : public sqlite::Database<StatisticsDatabase> {
21  protected:
23  StatisticsDatabase(const std::string &filename, const OpenMode open_mode);
24 
25  std::string repo_name_;
26 
27  bool StoreEntry(const std::string &insert_statement);
28 
34  bool Prune(uint32_t days);
35 
36  public:
37  // not const - needs to be adaptable!
38  static float kLatestSchema;
39  // not const - needs to be adaptable!
40  static unsigned kLatestSchemaRevision;
41  static const float kLatestCompatibleSchema;
42  static bool compacting_fails;
43  static unsigned int instances;
44  unsigned int create_empty_db_calls;
46  unsigned int live_upgrade_calls;
47  mutable unsigned int compact_calls;
48 
49  bool CreateEmptyDatabase();
52  bool CompactDatabase() const;
54 
61  static StatisticsDatabase *OpenStandardDB(const std::string repo_name);
62 
68  bool StorePublishStatistics(const perf::Statistics *statistics,
69  const std::string &start_time,
70  const bool success);
71 
77  bool StoreGCStatistics(const perf::Statistics *statistics,
78  const std::string &start_time,
79  const bool success);
80 
89  bool UploadStatistics(upload::Spooler *spooler, std::string local_path = "");
90 
98  std::string local_path = "");
99 
115  static void GetDBParams(const std::string &repo_name,
116  std::string *path,
117  uint32_t *days_to_keep);
118 
125  static bool GcExtendedStats(const std::string &repo_name);
126 
127  private:
128  static const uint32_t kDefaultDaysToKeep;
129 };
130 
131 
132 #endif // CVMFS_STATISTICS_DATABASE_H_
StatisticsDatabase(const std::string &filename, const OpenMode open_mode)
const std::string & filename() const
Definition: sql.h:146
bool UploadStatistics(upload::Spooler *spooler, std::string local_path="")
bool StoreGCStatistics(const perf::Statistics *statistics, const std::string &start_time, const bool success)
static unsigned int instances
unsigned int live_upgrade_calls
bool Prune(uint32_t days)
static bool compacting_fails
static const float kLatestCompatibleSchema
unsigned int create_empty_db_calls
static float kLatestSchema
unsigned int check_compatibility_calls
static unsigned kLatestSchemaRevision
static StatisticsDatabase * OpenStandardDB(const std::string repo_name)
static bool GcExtendedStats(const std::string &repo_name)
bool StoreEntry(const std::string &insert_statement)
bool StorePublishStatistics(const perf::Statistics *statistics, const std::string &start_time, const bool success)
static const uint32_t kDefaultDaysToKeep
unsigned int compact_calls
static void GetDBParams(const std::string &repo_name, std::string *path, uint32_t *days_to_keep)
bool CompactDatabase() const