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) 2016 John Spray <john.spray@redhat.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.
14 #ifndef CEPH_MGRMONITOR_H
15 #define CEPH_MGRMONITOR_H
17 #include "include/Context.h"
19 #include "PaxosService.h"
21 class MgrMonitor
: public PaxosService
25 bool ever_had_active_mgr
= false;
27 utime_t first_seen_inactive
;
29 std::map
<uint64_t, ceph::coarse_mono_clock::time_point
> last_beacon
;
32 * If a standby is available, make it active, given that
33 * there is currently no active daemon.
35 * @return true if a standby was promoted
37 bool promote_standby();
39 void drop_standby(uint64_t gid
);
41 Context
*digest_event
= nullptr;
44 bool check_caps(MonOpRequestRef op
, const uuid_d
& fsid
);
46 health_status_t
should_warn_about_mgr_down();
49 MgrMonitor(Monitor
*mn
, Paxos
*p
, const string
& service_name
)
50 : PaxosService(mn
, p
, service_name
)
52 ~MgrMonitor() override
{}
55 void on_shutdown() override
;
57 const MgrMap
&get_map() const { return map
; }
59 bool in_use() const { return map
.epoch
> 0; }
61 void create_initial() override
;
62 void update_from_paxos(bool *need_bootstrap
) override
;
63 void create_pending() override
;
64 void encode_pending(MonitorDBStore::TransactionRef t
) override
;
66 bool preprocess_query(MonOpRequestRef op
) override
;
67 bool prepare_update(MonOpRequestRef op
) override
;
69 bool preprocess_command(MonOpRequestRef op
);
70 bool prepare_command(MonOpRequestRef op
);
72 void encode_full(MonitorDBStore::TransactionRef t
) override
{ }
74 bool preprocess_beacon(MonOpRequestRef op
);
75 bool prepare_beacon(MonOpRequestRef op
);
77 void check_sub(Subscription
*sub
);
81 void on_active() override
;
82 void on_restart() override
;
84 void get_health(list
<pair
<health_status_t
,string
> >& summary
,
85 list
<pair
<health_status_t
,string
> > *detail
,
86 CephContext
*cct
) const override
;
89 void print_summary(Formatter
*f
, std::ostream
*ss
) const;
91 friend class C_Updated
;