]>
Commit | Line | Data |
---|---|---|
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) 2004-2006 Sage Weil <sage@newdream.net> | |
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 | ||
15 | ||
16 | ||
17 | #ifndef CEPH_MDS_H | |
18 | #define CEPH_MDS_H | |
19 | ||
20 | #include "mdstypes.h" | |
21 | ||
22 | #include "msg/Dispatcher.h" | |
23 | #include "include/CompatSet.h" | |
24 | #include "include/types.h" | |
25 | #include "include/Context.h" | |
26 | #include "common/DecayCounter.h" | |
27 | #include "common/perf_counters.h" | |
28 | #include "common/Mutex.h" | |
29 | #include "common/Cond.h" | |
30 | #include "common/Timer.h" | |
31 | #include "common/LogClient.h" | |
32 | #include "common/TrackedOp.h" | |
33 | #include "common/Finisher.h" | |
34 | #include "common/cmdparse.h" | |
35 | #include "mgr/MgrClient.h" | |
36 | ||
37 | #include "MDSRank.h" | |
38 | #include "MDSMap.h" | |
39 | ||
40 | #include "Beacon.h" | |
41 | ||
42 | ||
43 | #define CEPH_MDS_PROTOCOL 29 /* cluster internal */ | |
44 | ||
45 | class MonClient; | |
46 | ||
47 | class Server; | |
48 | class Locker; | |
49 | class MDCache; | |
50 | class MDBalancer; | |
51 | class MDSInternalContextBase; | |
52 | ||
53 | class Messenger; | |
54 | class Message; | |
55 | ||
56 | class SnapServer; | |
57 | class SnapClient; | |
58 | ||
59 | class MDSTableServer; | |
60 | class MDSTableClient; | |
61 | ||
62 | class AuthAuthorizeHandlerRegistry; | |
63 | ||
64 | class MDSDaemon : public Dispatcher, public md_config_obs_t { | |
65 | public: | |
66 | /* Global MDS lock: every time someone takes this, they must | |
67 | * also check the `stopping` flag. If stopping is true, you | |
68 | * must either do nothing and immediately drop the lock, or | |
69 | * never drop the lock again (i.e. call respawn()) */ | |
70 | Mutex mds_lock; | |
71 | bool stopping; | |
72 | ||
73 | SafeTimer timer; | |
74 | ||
75 | protected: | |
76 | Beacon beacon; | |
77 | ||
78 | AuthAuthorizeHandlerRegistry *authorize_handler_cluster_registry; | |
79 | AuthAuthorizeHandlerRegistry *authorize_handler_service_registry; | |
80 | ||
81 | std::string name; | |
82 | ||
83 | Messenger *messenger; | |
84 | MonClient *monc; | |
85 | MgrClient mgrc; | |
86 | MDSMap *mdsmap; | |
87 | LogClient log_client; | |
88 | LogChannelRef clog; | |
89 | ||
90 | MDSRankDispatcher *mds_rank; | |
91 | ||
92 | public: | |
93 | MDSDaemon(const std::string &n, Messenger *m, MonClient *mc); | |
94 | ~MDSDaemon() override; | |
95 | int orig_argc; | |
96 | const char **orig_argv; | |
97 | ||
98 | // handle a signal (e.g., SIGTERM) | |
99 | void handle_signal(int signum); | |
100 | ||
101 | int init(); | |
102 | ||
103 | /** | |
104 | * Hint at whether we were shutdown gracefully (i.e. we were only | |
105 | * in standby, or our rank was stopped). Should be removed once | |
106 | * we handle shutdown properly (e.g. clear out all message queues) | |
107 | * such that deleting xlists doesn't assert. | |
108 | */ | |
109 | bool is_clean_shutdown(); | |
110 | ||
111 | // config observer bits | |
112 | const char** get_tracked_conf_keys() const override; | |
113 | void handle_conf_change(const struct md_config_t *conf, | |
114 | const std::set <std::string> &changed) override; | |
115 | protected: | |
116 | // tick and other timer fun | |
117 | class C_MDS_Tick; | |
118 | C_MDS_Tick *tick_event; | |
119 | void reset_tick(); | |
120 | ||
121 | void wait_for_omap_osds(); | |
122 | ||
123 | private: | |
124 | bool ms_dispatch(Message *m) override; | |
125 | bool ms_get_authorizer(int dest_type, AuthAuthorizer **authorizer, bool force_new) override; | |
126 | bool ms_verify_authorizer(Connection *con, int peer_type, | |
127 | int protocol, bufferlist& authorizer_data, bufferlist& authorizer_reply, | |
128 | bool& isvalid, CryptoKey& session_key) override; | |
129 | void ms_handle_accept(Connection *con) override; | |
130 | void ms_handle_connect(Connection *con) override; | |
131 | bool ms_handle_reset(Connection *con) override; | |
132 | void ms_handle_remote_reset(Connection *con) override; | |
133 | bool ms_handle_refused(Connection *con) override; | |
134 | ||
135 | protected: | |
136 | // admin socket handling | |
137 | friend class MDSSocketHook; | |
138 | class MDSSocketHook *asok_hook; | |
139 | void set_up_admin_socket(); | |
140 | void clean_up_admin_socket(); | |
141 | void check_ops_in_flight(); // send off any slow ops to monitor | |
142 | bool asok_command(string command, cmdmap_t& cmdmap, string format, | |
143 | ostream& ss); | |
144 | ||
145 | void dump_status(Formatter *f); | |
146 | ||
147 | /** | |
148 | * Terminate this daemon process. | |
149 | * | |
150 | * This function will return, but once it does so the calling thread | |
151 | * must do no more work as all subsystems will have been shut down. | |
152 | */ | |
153 | void suicide(); | |
154 | ||
155 | /** | |
156 | * Start a new daemon process with the same command line parameters that | |
157 | * this process was run with, then terminate this process | |
158 | */ | |
159 | void respawn(); | |
160 | ||
161 | void tick(); | |
162 | ||
163 | // messages | |
164 | bool _dispatch(Message *m, bool new_msg); | |
165 | ||
166 | protected: | |
167 | bool handle_core_message(Message *m); | |
168 | ||
169 | // special message types | |
170 | friend class C_MDS_Send_Command_Reply; | |
171 | static void send_command_reply(MCommand *m, MDSRank* mds_rank, int r, | |
172 | bufferlist outbl, const std::string& outs); | |
173 | int _handle_command( | |
174 | const cmdmap_t &cmdmap, | |
175 | MCommand *m, | |
176 | bufferlist *outbl, | |
177 | std::string *outs, | |
178 | Context **run_later, | |
179 | bool *need_reply); | |
180 | void handle_command(class MCommand *m); | |
181 | void handle_mds_map(class MMDSMap *m); | |
182 | void _handle_mds_map(MDSMap *oldmap); | |
183 | }; | |
184 | ||
185 | ||
186 | #endif |