CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
nfs_maps_sqlite.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_NFS_MAPS_SQLITE_H_
6 #define CVMFS_NFS_MAPS_SQLITE_H_
7 
8 #include <pthread.h>
9 
10 #include <string>
11 
12 #include "atomic.h"
13 #include "duplex_sqlite3.h"
14 #include "hash.h"
15 #include "nfs_maps.h"
16 #include "prng.h"
17 #include "shortstring.h"
18 
19 namespace perf {
20 class Counter;
21 class Statistics;
22 }
23 
24 class NfsMapsSqlite : public NfsMaps {
25  public:
26  virtual ~NfsMapsSqlite();
27  virtual uint64_t GetInode(const PathString &path);
28  virtual bool GetPath(const uint64_t inode, PathString *path);
29 
30  static NfsMapsSqlite *Create(
31  const std::string &db_dir,
32  const uint64_t root_inode,
33  const bool rebuild,
35 
36  private:
40  static const unsigned kMaxDBSqlLen = 128;
41  static const char *kSqlCreateTable;
42  static const char *kSqlAddRoot;
43  static const char *kSqlAddInode;
44  static const char *kSqlGetInode;
45  static const char *kSqlGetPath;
46 
47  struct BusyHandlerInfo {
50  }
51 
52  static const unsigned kMaxWaitMs = 60000;
53  static const unsigned kMaxBackoffMs = 100;
54  unsigned accumulated_ms;
56  };
57 
58  static int BusyHandler(void *data, int attempt);
59 
60  NfsMapsSqlite();
61  uint64_t FindInode(const PathString &path);
62  uint64_t IssueInode(const PathString &path);
63  uint64_t RetryGetInode(const PathString &path, int attempt);
64 
65  sqlite3 *db_;
66  sqlite3_stmt *stmt_get_path_;
67  sqlite3_stmt *stmt_get_inode_;
68  sqlite3_stmt *stmt_add_;
69  pthread_mutex_t *lock_;
70 
72 
77 };
78 
79 #endif // CVMFS_NFS_MAPS_SQLITE_H_
virtual ~NfsMapsSqlite()
Definition: prng.h:25
perf::Counter * n_db_added_
sqlite3_stmt * stmt_add_
static const char * kSqlGetPath
static NfsMapsSqlite * Create(const std::string &db_dir, const uint64_t root_inode, const bool rebuild, perf::Statistics *statistics_)
perf::Counter * n_db_seq_
uint64_t FindInode(const PathString &path)
void InitLocaltime()
Definition: prng.h:35
perf::Statistics * statistics_
Definition: repository.h:138
BusyHandlerInfo busy_handler_info_
static const char * kSqlGetInode
pthread_mutex_t * lock_
static const unsigned kMaxWaitMs
virtual uint64_t GetInode(const PathString &path)
static int BusyHandler(void *data, int attempt)
static const char * kSqlCreateTable
static const unsigned kMaxBackoffMs
virtual bool GetPath(const uint64_t inode, PathString *path)
perf::Counter * n_db_inode_found_
sqlite3_stmt * stmt_get_inode_
uint64_t RetryGetInode(const PathString &path, int attempt)
uint64_t IssueInode(const PathString &path)
perf::Counter * n_db_path_found_
static const unsigned kMaxDBSqlLen
sqlite3_stmt * stmt_get_path_
static const char * kSqlAddRoot
static const char * kSqlAddInode