1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
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.
18 #include "common/LogClient.h"
19 #include "common/Mutex.h"
20 #include "common/Timer.h"
21 #include "include/Context.h"
22 #include "include/types.h"
23 #include "mgr/MgrClient.h"
24 #include "msg/Dispatcher.h"
30 #define CEPH_MDS_PROTOCOL 30 /* cluster internal */
32 class AuthAuthorizeHandlerRegistry;
37 class MDSDaemon : public Dispatcher, public md_config_obs_t {
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()) */
51 AuthAuthorizeHandlerRegistry *authorize_handler_cluster_registry;
52 AuthAuthorizeHandlerRegistry *authorize_handler_service_registry;
63 MDSRankDispatcher *mds_rank;
66 MDSDaemon(const std::string &n, Messenger *m, MonClient *mc);
67 ~MDSDaemon() override;
69 const char **orig_argv;
71 // handle a signal (e.g., SIGTERM)
72 void handle_signal(int signum);
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.
82 bool is_clean_shutdown();
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;
89 // tick and other timer fun
90 Context *tick_event = nullptr;
93 void wait_for_omap_osds();
96 bool ms_dispatch(Message *m) override;
97 bool ms_get_authorizer(int dest_type, AuthAuthorizer **authorizer, bool force_new) override;
98 bool ms_verify_authorizer(Connection *con, int peer_type,
99 int protocol, bufferlist& authorizer_data, bufferlist& authorizer_reply,
100 bool& isvalid, CryptoKey& session_key) override;
101 void ms_handle_accept(Connection *con) override;
102 void ms_handle_connect(Connection *con) override;
103 bool ms_handle_reset(Connection *con) override;
104 void ms_handle_remote_reset(Connection *con) override;
105 bool ms_handle_refused(Connection *con) override;
108 // admin socket handling
109 friend class MDSSocketHook;
110 class MDSSocketHook *asok_hook;
111 void set_up_admin_socket();
112 void clean_up_admin_socket();
113 void check_ops_in_flight(); // send off any slow ops to monitor
114 bool asok_command(string command, cmdmap_t& cmdmap, string format,
117 void dump_status(Formatter *f);
120 * Terminate this daemon process.
122 * This function will return, but once it does so the calling thread
123 * must do no more work as all subsystems will have been shut down.
128 * Start a new daemon process with the same command line parameters that
129 * this process was run with, then terminate this process
136 bool _dispatch(Message *m, bool new_msg);
139 bool handle_core_message(Message *m);
141 // special message types
142 friend class C_MDS_Send_Command_Reply;
143 static void send_command_reply(MCommand *m, MDSRank* mds_rank, int r,
144 bufferlist outbl, const std::string& outs);
146 const cmdmap_t &cmdmap,
152 void handle_command(class MCommand *m);
153 void handle_mds_map(class MMDSMap *m);
154 void _handle_mds_map(MDSMap *oldmap);