]> git.proxmox.com Git - ceph.git/blob - ceph/src/mgr/DaemonServer.h
update sources to v12.1.1
[ceph.git] / ceph / src / mgr / DaemonServer.h
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
17 #include "PyModules.h"
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
30 #include "ServiceMap.h"
31 #include "MgrSession.h"
32 #include "DaemonState.h"
33
34 class MMgrReport;
35 class MMgrOpen;
36 class MMonMgrReport;
37 class MCommand;
38 struct MgrCommand;
39
40
41 /**
42 * Server used in ceph-mgr to communicate with Ceph daemons like
43 * MDSs and OSDs.
44 */
45 class DaemonServer : public Dispatcher
46 {
47 protected:
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;
62 PyModules &py_modules;
63 LogChannelRef clog, audit_clog;
64
65 AuthAuthorizeHandlerRegistry auth_registry;
66
67 /// connections for osds
68 ceph::unordered_map<int,set<ConnectionRef>> osd_cons;
69
70 ServiceMap pending_service_map; // uncommitted
71 epoch_t pending_service_map_dirty = 0;
72
73 Mutex lock;
74
75 static void _generate_command_map(map<string,cmd_vartype>& cmdmap,
76 map<string,string> &param_str_map);
77 static const MgrCommand *_get_mgrcommand(const string &cmd_prefix,
78 MgrCommand *cmds, int cmds_size);
79 bool _allowed_command(
80 MgrSession *s, const string &module, const string &prefix,
81 const map<string,cmd_vartype>& cmdmap,
82 const map<string,string>& param_str_map,
83 const MgrCommand *this_cmd);
84
85 private:
86 friend class ReplyOnFinish;
87 bool _reply(MCommand* m,
88 int ret, const std::string& s, const bufferlist& payload);
89
90 void _prune_pending_service_map();
91
92 utime_t started_at;
93 bool pgmap_ready = false;
94 std::set<int32_t> reported_osds;
95 void maybe_ready(int32_t osd_id);
96
97 public:
98 int init(uint64_t gid, entity_addr_t client_addr);
99 void shutdown();
100
101 entity_addr_t get_myaddr() const;
102
103 DaemonServer(MonClient *monc_,
104 Finisher &finisher_,
105 DaemonStateIndex &daemon_state_,
106 ClusterState &cluster_state_,
107 PyModules &py_modules_,
108 LogChannelRef cl,
109 LogChannelRef auditcl);
110 ~DaemonServer() override;
111
112 bool ms_dispatch(Message *m) override;
113 bool ms_handle_reset(Connection *con) override;
114 void ms_handle_remote_reset(Connection *con) override {}
115 bool ms_handle_refused(Connection *con) override;
116 bool ms_get_authorizer(int dest_type, AuthAuthorizer **authorizer,
117 bool force_new) override;
118 bool ms_verify_authorizer(Connection *con,
119 int peer_type,
120 int protocol,
121 ceph::bufferlist& authorizer,
122 ceph::bufferlist& authorizer_reply,
123 bool& isvalid,
124 CryptoKey& session_key) override;
125
126 bool handle_open(MMgrOpen *m);
127 bool handle_report(MMgrReport *m);
128 bool handle_command(MCommand *m);
129 void send_report();
130 void got_service_map();
131 };
132
133 #endif
134