Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / mgr / Mgr.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) 2014 John Spray <john.spray@inktank.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 CEPH_MGR_H_
15 #define CEPH_MGR_H_
16
17 // Python.h comes first because otherwise it clobbers ceph's assert
18 #include "Python.h"
19 // Python's pyconfig-64.h conflicts with ceph's acconfig.h
20 #undef HAVE_SYS_WAIT_H
21 #undef HAVE_UNISTD_H
22 #undef HAVE_UTIME_H
23 #undef _POSIX_C_SOURCE
24 #undef _XOPEN_SOURCE
25
26 #include "mds/FSMap.h"
27 #include "messages/MFSMap.h"
28 #include "msg/Messenger.h"
29 #include "auth/Auth.h"
30 #include "common/Finisher.h"
31 #include "common/Timer.h"
32 #include "mon/MgrMap.h"
33
34 #include "DaemonServer.h"
35 #include "PyModuleRegistry.h"
36
37 #include "DaemonState.h"
38 #include "ClusterState.h"
39
40 class MCommand;
41 class MMgrDigest;
42 class MLog;
43 class MServiceMap;
44 class Objecter;
45 class Client;
46
47 class Mgr {
48 protected:
49   MonClient *monc;
50   Objecter  *objecter;
51   Client    *client;
52   Messenger *client_messenger;
53
54   mutable Mutex lock;
55   SafeTimer timer;
56   Finisher finisher;
57
58   // Track receipt of initial data during startup
59   Cond fs_map_cond;
60   bool digest_received;
61   Cond digest_cond;
62
63   PyModuleRegistry *py_module_registry;
64   DaemonStateIndex daemon_state;
65   ClusterState cluster_state;
66
67   DaemonServer server;
68
69   LogChannelRef clog;
70   LogChannelRef audit_clog;
71
72   PyModuleConfig load_config();
73   void load_all_metadata();
74   void init();
75
76   bool initialized;
77   bool initializing;
78
79 public:
80   Mgr(MonClient *monc_, const MgrMap& mgrmap,
81       PyModuleRegistry *py_module_registry_,
82       Messenger *clientm_, Objecter *objecter_,
83       Client *client_, LogChannelRef clog_, LogChannelRef audit_clog_);
84   ~Mgr();
85
86   bool is_initialized() const {return initialized;}
87   entity_addr_t get_server_addr() const { return server.get_myaddr(); }
88
89   void handle_mgr_digest(MMgrDigest* m);
90   void handle_fs_map(MFSMap* m);
91   void handle_osd_map();
92   void handle_log(MLog *m);
93   void handle_service_map(MServiceMap *m);
94
95   bool got_mgr_map(const MgrMap& m);
96
97   bool ms_dispatch(Message *m);
98
99   void tick();
100
101   void background_init(Context *completion);
102   void shutdown();
103
104   std::vector<MonCommand> get_command_set() const;
105   std::map<std::string, std::string> get_services() const;
106 };
107
108 #endif