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) 2014 John Spray <john.spray@inktank.com>
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.
17 // Python.h comes first because otherwise it clobbers ceph's assert
20 #include "mds/FSMap.h"
21 #include "messages/MFSMap.h"
22 #include "msg/Messenger.h"
23 #include "auth/Auth.h"
24 #include "common/Finisher.h"
25 #include "mon/MgrMap.h"
27 #include "DaemonServer.h"
28 #include "PyModuleRegistry.h"
30 #include "DaemonState.h"
31 #include "ClusterState.h"
40 class Mgr
: public AdminSocketHook
{
45 Messenger
*client_messenger
;
47 mutable ceph::mutex lock
= ceph::make_mutex("Mgr::lock");
50 // Track receipt of initial data during startup
51 ceph::condition_variable fs_map_cond
;
53 ceph::condition_variable digest_cond
;
55 PyModuleRegistry
*py_module_registry
;
56 DaemonStateIndex daemon_state
;
57 ClusterState cluster_state
;
62 LogChannelRef audit_clog
;
64 std::map
<std::string
, std::string
> pre_init_store
;
66 void load_all_metadata();
67 std::map
<std::string
, std::string
> load_store();
74 Mgr(MonClient
*monc_
, const MgrMap
& mgrmap
,
75 PyModuleRegistry
*py_module_registry_
,
76 Messenger
*clientm_
, Objecter
*objecter_
,
77 Client
*client_
, LogChannelRef clog_
, LogChannelRef audit_clog_
);
80 bool is_initialized() const {return initialized
;}
81 entity_addrvec_t
get_server_addrs() const {
82 return server
.get_myaddrs();
85 void handle_mgr_digest(ceph::ref_t
<MMgrDigest
> m
);
86 void handle_fs_map(ceph::ref_t
<MFSMap
> m
);
87 void handle_osd_map();
88 void handle_log(ceph::ref_t
<MLog
> m
);
89 void handle_service_map(ceph::ref_t
<MServiceMap
> m
);
90 void handle_mon_map();
92 bool got_mgr_map(const MgrMap
& m
);
94 bool ms_dispatch2(const ceph::ref_t
<Message
>& m
);
96 void background_init(Context
*completion
);
99 void handle_signal(int signum
);
101 std::map
<std::string
, std::string
> get_services() const;
104 std::string_view command
,
105 const cmdmap_t
& cmdmap
,
108 ceph::buffer::list
& out
) override
;
112 * Context for completion of metadata mon commands: take
113 * the result and stash it in DaemonStateIndex
115 class MetadataUpdate
: public Context
119 DaemonStateIndex
&daemon_state
;
122 std::map
<std::string
, std::string
> defaults
;
128 MetadataUpdate(DaemonStateIndex
&daemon_state_
, const DaemonKey
&key_
)
129 : daemon_state(daemon_state_
), key(key_
)
131 daemon_state
.notify_updating(key
);
134 void set_default(const std::string
&k
, const std::string
&v
)
139 void finish(int r
) override
;