]> git.proxmox.com Git - ceph.git/blame - ceph/src/mgr/DaemonServer.h
update sources to 12.2.7
[ceph.git] / ceph / src / mgr / DaemonServer.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) 2016 John Spray <john.spray@redhat.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 DAEMON_SERVER_H_
15#define DAEMON_SERVER_H_
16
3efd9988 17#include "PyModuleRegistry.h"
7c673cae
FG
18
19#include <set>
20#include <string>
21
22#include "common/Mutex.h"
23#include "common/LogClient.h"
24
25#include <msg/Messenger.h>
26#include <mon/MonClient.h>
27
28#include "auth/AuthAuthorizeHandler.h"
29
224ce89b 30#include "ServiceMap.h"
7c673cae
FG
31#include "MgrSession.h"
32#include "DaemonState.h"
33
34class MMgrReport;
35class MMgrOpen;
31f18b77 36class MMonMgrReport;
7c673cae 37class MCommand;
c07f9fc5 38struct MonCommand;
7c673cae
FG
39
40
41/**
42 * Server used in ceph-mgr to communicate with Ceph daemons like
43 * MDSs and OSDs.
44 */
3efd9988 45class DaemonServer : public Dispatcher, public md_config_obs_t
7c673cae
FG
46{
47protected:
48 boost::scoped_ptr<Throttle> client_byte_throttler;
49 boost::scoped_ptr<Throttle> client_msg_throttler;
50 boost::scoped_ptr<Throttle> osd_byte_throttler;
51 boost::scoped_ptr<Throttle> osd_msg_throttler;
52 boost::scoped_ptr<Throttle> mds_byte_throttler;
53 boost::scoped_ptr<Throttle> mds_msg_throttler;
54 boost::scoped_ptr<Throttle> mon_byte_throttler;
55 boost::scoped_ptr<Throttle> mon_msg_throttler;
56
57 Messenger *msgr;
58 MonClient *monc;
59 Finisher &finisher;
60 DaemonStateIndex &daemon_state;
61 ClusterState &cluster_state;
3efd9988 62 PyModuleRegistry &py_modules;
7c673cae
FG
63 LogChannelRef clog, audit_clog;
64
b32b8144
FG
65 // Authentication methods for cluster peers
66 AuthAuthorizeHandlerRegistry auth_cluster_registry;
67 // Authentication methods for clients
68 AuthAuthorizeHandlerRegistry auth_service_registry;
7c673cae 69
3efd9988
FG
70 // Connections for daemons, and clients with service names set
71 // (i.e. those MgrClients that are allowed to send MMgrReports)
72 std::set<ConnectionRef> daemon_connections;
73
31f18b77
FG
74 /// connections for osds
75 ceph::unordered_map<int,set<ConnectionRef>> osd_cons;
76
224ce89b 77 ServiceMap pending_service_map; // uncommitted
3efd9988 78
224ce89b
WB
79 epoch_t pending_service_map_dirty = 0;
80
7c673cae
FG
81 Mutex lock;
82
83 static void _generate_command_map(map<string,cmd_vartype>& cmdmap,
84 map<string,string> &param_str_map);
c07f9fc5
FG
85 static const MonCommand *_get_mgrcommand(const string &cmd_prefix,
86 const std::vector<MonCommand> &commands);
7c673cae
FG
87 bool _allowed_command(
88 MgrSession *s, const string &module, const string &prefix,
89 const map<string,cmd_vartype>& cmdmap,
90 const map<string,string>& param_str_map,
c07f9fc5 91 const MonCommand *this_cmd);
7c673cae
FG
92
93private:
94 friend class ReplyOnFinish;
95 bool _reply(MCommand* m,
96 int ret, const std::string& s, const bufferlist& payload);
97
224ce89b
WB
98 void _prune_pending_service_map();
99
100 utime_t started_at;
3efd9988 101 std::atomic<bool> pgmap_ready;
224ce89b
WB
102 std::set<int32_t> reported_osds;
103 void maybe_ready(int32_t osd_id);
104
7c673cae
FG
105public:
106 int init(uint64_t gid, entity_addr_t client_addr);
107 void shutdown();
108
109 entity_addr_t get_myaddr() const;
110
111 DaemonServer(MonClient *monc_,
112 Finisher &finisher_,
113 DaemonStateIndex &daemon_state_,
114 ClusterState &cluster_state_,
3efd9988 115 PyModuleRegistry &py_modules_,
7c673cae
FG
116 LogChannelRef cl,
117 LogChannelRef auditcl);
118 ~DaemonServer() override;
119
120 bool ms_dispatch(Message *m) override;
31f18b77 121 bool ms_handle_reset(Connection *con) override;
7c673cae
FG
122 void ms_handle_remote_reset(Connection *con) override {}
123 bool ms_handle_refused(Connection *con) override;
124 bool ms_get_authorizer(int dest_type, AuthAuthorizer **authorizer,
125 bool force_new) override;
28e407b8
AA
126 bool ms_verify_authorizer(
127 Connection *con,
128 int peer_type,
129 int protocol,
130 ceph::bufferlist& authorizer,
131 ceph::bufferlist& authorizer_reply,
132 bool& isvalid,
133 CryptoKey& session_key,
134 std::unique_ptr<AuthAuthorizerChallenge> *challenge) override;
7c673cae
FG
135
136 bool handle_open(MMgrOpen *m);
137 bool handle_report(MMgrReport *m);
138 bool handle_command(MCommand *m);
31f18b77 139 void send_report();
224ce89b 140 void got_service_map();
3efd9988
FG
141
142 void _send_configure(ConnectionRef c);
143
144 virtual const char** get_tracked_conf_keys() const override;
145 virtual void handle_conf_change(const struct md_config_t *conf,
146 const std::set <std::string> &changed) override;
7c673cae
FG
147};
148
149#endif
150