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