CernVM-FS  2.12.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,
24  const OpenMode open_mode);
25 
26  std::string repo_name_;
27 
28  bool StoreEntry(const std::string &insert_statement);
29 
35  bool Prune(uint32_t days);
36 
37  public:
38  // not const - needs to be adaptable!
39  static float kLatestSchema;
40  // not const - needs to be adaptable!
41  static unsigned kLatestSchemaRevision;
42  static const float kLatestCompatibleSchema;
43  static bool compacting_fails;
44  static unsigned int instances;
45  unsigned int create_empty_db_calls;
47  unsigned int live_upgrade_calls;
48  mutable unsigned int compact_calls;
49 
50  bool CreateEmptyDatabase();
53  bool CompactDatabase() const;
55 
62  static StatisticsDatabase *OpenStandardDB(const std::string repo_name);
63 
69  bool StorePublishStatistics(const perf::Statistics *statistics,
70  const std::string &start_time,
71  const bool success);
72 
78  bool StoreGCStatistics(const perf::Statistics *statistics,
79  const std::string &start_time,
80  const bool success);
81 
90  bool UploadStatistics(upload::Spooler *spooler,
91  std::string local_path = "");
92 
100  std::string local_path = "");
101 
117  static void GetDBParams(const std::string &repo_name,
118  std::string *path,
119  uint32_t *days_to_keep);
120 
127  static bool GcExtendedStats(const std::string &repo_name);
128 
129  private:
130  static const uint32_t kDefaultDaysToKeep;
131 };
132 
133 
134 #endif // CVMFS_STATISTICS_DATABASE_H_
StatisticsDatabase(const std::string &filename, const OpenMode open_mode)
const std::string & filename() const
Definition: sql.h:148
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