]> git.proxmox.com Git - ceph.git/blame - ceph/src/mgr/Mgr.h
update sources to v12.2.3
[ceph.git] / ceph / src / mgr / Mgr.h
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3/*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2014 John Spray <john.spray@inktank.com>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 */
13
14#ifndef CEPH_MGR_H_
15#define CEPH_MGR_H_
16
17// Python.h comes first because otherwise it clobbers ceph's assert
18#include "Python.h"
19// Python's pyconfig-64.h conflicts with ceph's acconfig.h
20#undef HAVE_SYS_WAIT_H
21#undef HAVE_UNISTD_H
22#undef HAVE_UTIME_H
23#undef _POSIX_C_SOURCE
24#undef _XOPEN_SOURCE
25
26#include "mds/FSMap.h"
27#include "messages/MFSMap.h"
28#include "msg/Messenger.h"
29#include "auth/Auth.h"
30#include "common/Finisher.h"
31#include "common/Timer.h"
224ce89b 32#include "mon/MgrMap.h"
7c673cae
FG
33
34#include "DaemonServer.h"
3efd9988 35#include "PyModuleRegistry.h"
7c673cae
FG
36
37#include "DaemonState.h"
38#include "ClusterState.h"
39
40class MCommand;
41class MMgrDigest;
42class MLog;
224ce89b 43class MServiceMap;
7c673cae
FG
44class Objecter;
45class Client;
46
7c673cae
FG
47class Mgr {
48protected:
49 MonClient *monc;
50 Objecter *objecter;
51 Client *client;
52 Messenger *client_messenger;
53
c07f9fc5 54 mutable Mutex lock;
7c673cae
FG
55 SafeTimer timer;
56 Finisher finisher;
57
224ce89b 58 // Track receipt of initial data during startup
7c673cae 59 Cond fs_map_cond;
224ce89b
WB
60 bool digest_received;
61 Cond digest_cond;
7c673cae 62
3efd9988 63 PyModuleRegistry *py_module_registry;
7c673cae
FG
64 DaemonStateIndex daemon_state;
65 ClusterState cluster_state;
66
67 DaemonServer server;
68
3efd9988
FG
69 LogChannelRef clog;
70 LogChannelRef audit_clog;
71
72 PyModuleConfig load_config();
7c673cae
FG
73 void load_all_metadata();
74 void init();
75
76 bool initialized;
77 bool initializing;
78
79public:
224ce89b 80 Mgr(MonClient *monc_, const MgrMap& mgrmap,
3efd9988 81 PyModuleRegistry *py_module_registry_,
224ce89b 82 Messenger *clientm_, Objecter *objecter_,
7c673cae
FG
83 Client *client_, LogChannelRef clog_, LogChannelRef audit_clog_);
84 ~Mgr();
85
86 bool is_initialized() const {return initialized;}
87 entity_addr_t get_server_addr() const { return server.get_myaddr(); }
88
89 void handle_mgr_digest(MMgrDigest* m);
90 void handle_fs_map(MFSMap* m);
91 void handle_osd_map();
92 void handle_log(MLog *m);
224ce89b
WB
93 void handle_service_map(MServiceMap *m);
94
95 bool got_mgr_map(const MgrMap& m);
7c673cae
FG
96
97 bool ms_dispatch(Message *m);
98
31f18b77
FG
99 void tick();
100
224ce89b 101 void background_init(Context *completion);
7c673cae 102 void shutdown();
c07f9fc5
FG
103
104 std::vector<MonCommand> get_command_set() const;
3efd9988 105 std::map<std::string, std::string> get_services() const;
7c673cae
FG
106};
107
b32b8144
FG
108/**
109 * Context for completion of metadata mon commands: take
110 * the result and stash it in DaemonStateIndex
111 */
112class MetadataUpdate : public Context
113{
114
115private:
116 DaemonStateIndex &daemon_state;
117 DaemonKey key;
118
119 std::map<std::string, std::string> defaults;
120
121public:
122 bufferlist outbl;
123 std::string outs;
124
125 MetadataUpdate(DaemonStateIndex &daemon_state_, const DaemonKey &key_)
126 : daemon_state(daemon_state_), key(key_) {}
127
128 void set_default(const std::string &k, const std::string &v)
129 {
130 defaults[k] = v;
131 }
132
133 void finish(int r) override;
134};
135
136
7c673cae 137#endif