summaryrefslogtreecommitdiffstats
path: root/src/tools/rbd_mirror/PoolMetaCache.h
blob: f0440120fee06c31ff2b4b46374d56712a16b7ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#ifndef CEPH_RBD_MIRROR_POOL_META_CACHE_H
#define CEPH_RBD_MIRROR_POOL_META_CACHE_H

#include "include/int_types.h"
#include "common/ceph_mutex.h"
#include "tools/rbd_mirror/Types.h"
#include <map>

namespace rbd {
namespace mirror {

class PoolMetaCache {
public:
  PoolMetaCache(CephContext* cct)
    : m_cct(cct) {
  }
  PoolMetaCache(const PoolMetaCache&) = delete;
  PoolMetaCache& operator=(const PoolMetaCache&) = delete;

  int get_local_pool_meta(int64_t pool_id,
                          LocalPoolMeta* local_pool_meta) const;
  void set_local_pool_meta(int64_t pool_id,
                           const LocalPoolMeta& local_pool_meta);
  void remove_local_pool_meta(int64_t pool_id);

  int get_remote_pool_meta(int64_t pool_id,
                           RemotePoolMeta* remote_pool_meta) const;
  void set_remote_pool_meta(int64_t pool_id,
                            const RemotePoolMeta& remote_pool_meta);
  void remove_remote_pool_meta(int64_t pool_id);

private:
  CephContext* m_cct;

  mutable ceph::shared_mutex m_lock =
    ceph::make_shared_mutex("rbd::mirror::PoolMetaCache::m_lock");
  std::map<int64_t, LocalPoolMeta> m_local_pool_metas;
  std::map<int64_t, RemotePoolMeta> m_remote_pool_metas;
};

} // namespace mirror
} // namespace rbd

#endif // CEPH_RBD_MIRROR_POOL_META_CACHE_H