]> git.proxmox.com Git - ceph.git/blame - ceph/src/mgr/Mgr.h
import ceph quincy 17.2.4
[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
9f95a23c 18#include <Python.h>
7c673cae
FG
19
20#include "mds/FSMap.h"
21#include "messages/MFSMap.h"
22#include "msg/Messenger.h"
23#include "auth/Auth.h"
24#include "common/Finisher.h"
224ce89b 25#include "mon/MgrMap.h"
7c673cae
FG
26
27#include "DaemonServer.h"
3efd9988 28#include "PyModuleRegistry.h"
7c673cae
FG
29
30#include "DaemonState.h"
31#include "ClusterState.h"
32
33class MCommand;
34class MMgrDigest;
35class MLog;
224ce89b 36class MServiceMap;
7c673cae
FG
37class Objecter;
38class Client;
39
9f95a23c 40class Mgr : public AdminSocketHook {
7c673cae
FG
41protected:
42 MonClient *monc;
43 Objecter *objecter;
44 Client *client;
45 Messenger *client_messenger;
46
9f95a23c 47 mutable ceph::mutex lock = ceph::make_mutex("Mgr::lock");
7c673cae
FG
48 Finisher finisher;
49
224ce89b 50 // Track receipt of initial data during startup
9f95a23c 51 ceph::condition_variable fs_map_cond;
224ce89b 52 bool digest_received;
9f95a23c 53 ceph::condition_variable digest_cond;
7c673cae 54
3efd9988 55 PyModuleRegistry *py_module_registry;
7c673cae
FG
56 DaemonStateIndex daemon_state;
57 ClusterState cluster_state;
58
59 DaemonServer server;
60
3efd9988
FG
61 LogChannelRef clog;
62 LogChannelRef audit_clog;
63
f67539c2
TL
64 std::map<std::string, std::string> pre_init_store;
65
7c673cae 66 void load_all_metadata();
11fdf7f2 67 std::map<std::string, std::string> load_store();
7c673cae
FG
68 void init();
69
70 bool initialized;
71 bool initializing;
72
73public:
224ce89b 74 Mgr(MonClient *monc_, const MgrMap& mgrmap,
3efd9988 75 PyModuleRegistry *py_module_registry_,
224ce89b 76 Messenger *clientm_, Objecter *objecter_,
7c673cae
FG
77 Client *client_, LogChannelRef clog_, LogChannelRef audit_clog_);
78 ~Mgr();
79
80 bool is_initialized() const {return initialized;}
11fdf7f2
TL
81 entity_addrvec_t get_server_addrs() const {
82 return server.get_myaddrs();
83 }
7c673cae 84
9f95a23c
TL
85 void handle_mgr_digest(ceph::ref_t<MMgrDigest> m);
86 void handle_fs_map(ceph::ref_t<MFSMap> m);
7c673cae 87 void handle_osd_map();
9f95a23c
TL
88 void handle_log(ceph::ref_t<MLog> m);
89 void handle_service_map(ceph::ref_t<MServiceMap> m);
11fdf7f2 90 void handle_mon_map();
224ce89b
WB
91
92 bool got_mgr_map(const MgrMap& m);
7c673cae 93
9f95a23c 94 bool ms_dispatch2(const ceph::ref_t<Message>& m);
7c673cae 95
224ce89b 96 void background_init(Context *completion);
7c673cae 97 void shutdown();
c07f9fc5 98
9f95a23c
TL
99 void handle_signal(int signum);
100
3efd9988 101 std::map<std::string, std::string> get_services() const;
9f95a23c
TL
102
103 int call(
104 std::string_view command,
105 const cmdmap_t& cmdmap,
106 Formatter *f,
107 std::ostream& errss,
108 ceph::buffer::list& out) override;
7c673cae
FG
109};
110
b32b8144
FG
111/**
112 * Context for completion of metadata mon commands: take
113 * the result and stash it in DaemonStateIndex
114 */
115class MetadataUpdate : public Context
116{
117
118private:
119 DaemonStateIndex &daemon_state;
120 DaemonKey key;
121
122 std::map<std::string, std::string> defaults;
123
124public:
125 bufferlist outbl;
126 std::string outs;
127
128 MetadataUpdate(DaemonStateIndex &daemon_state_, const DaemonKey &key_)
11fdf7f2
TL
129 : daemon_state(daemon_state_), key(key_)
130 {
131 daemon_state.notify_updating(key);
132 }
b32b8144
FG
133
134 void set_default(const std::string &k, const std::string &v)
135 {
136 defaults[k] = v;
137 }
138
139 void finish(int r) override;
140};
141
142
7c673cae 143#endif