]> git.proxmox.com Git - ceph.git/blame - ceph/src/tools/cephfs_mirror/ServiceDaemon.h
import ceph 16.2.7
[ceph.git] / ceph / src / tools / cephfs_mirror / ServiceDaemon.h
CommitLineData
f67539c2
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3
4#ifndef CEPHFS_MIRROR_SERVICE_DAEMON_H
5#define CEPHFS_MIRROR_SERVICE_DAEMON_H
6
7#include "common/ceph_mutex.h"
a4b75251 8#include "common/Timer.h"
f67539c2
TL
9#include "mds/FSMap.h"
10#include "Types.h"
11
f67539c2
TL
12namespace cephfs {
13namespace mirror {
14
15class ServiceDaemon {
16public:
17 ServiceDaemon(CephContext *cct, RadosRef rados);
18 ~ServiceDaemon();
19
20 int init();
21
22 void add_filesystem(fs_cluster_id_t fscid, std::string_view fs_name);
23 void remove_filesystem(fs_cluster_id_t fscid);
24
25 void add_peer(fs_cluster_id_t fscid, const Peer &peer);
26 void remove_peer(fs_cluster_id_t fscid, const Peer &peer);
27
28 void add_or_update_fs_attribute(fs_cluster_id_t fscid, std::string_view key,
29 AttributeValue value);
30 void add_or_update_peer_attribute(fs_cluster_id_t fscid, const Peer &peer,
31 std::string_view key, AttributeValue value);
32
33private:
34 struct Filesystem {
35 std::string fs_name;
36 Attributes fs_attributes;
37 std::map<Peer, Attributes> peer_attributes;
38
39 Filesystem(std::string_view fs_name)
40 : fs_name(fs_name) {
41 }
42 };
43
44 const std::string CEPHFS_MIRROR_AUTH_ID_PREFIX = "cephfs-mirror.";
45
46 CephContext *m_cct;
47 RadosRef m_rados;
48 SafeTimer *m_timer;
49 ceph::mutex m_timer_lock = ceph::make_mutex("cephfs::mirror::ServiceDaemon");
50
51 ceph::mutex m_lock = ceph::make_mutex("cephfs::mirror::service_daemon");
52 Context *m_timer_ctx = nullptr;
53 std::map<fs_cluster_id_t, Filesystem> m_filesystems;
54
55 void schedule_update_status();
56 void update_status();
57};
58
59} // namespace mirror
60} // namespace cephfs
61
62#endif // CEPHFS_MIRROR_SERVICE_DAEMON_H