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
26 utime_t first_seen_inactive
;
28 std::map
<uint64_t, ceph::coarse_mono_clock::time_point
> last_beacon
;
31 * If a standby is available, make it active, given that
32 * there is currently no active daemon.
34 * @return true if a standby was promoted
36 bool promote_standby();
38 void drop_standby(uint64_t gid
);
40 Context
*digest_event
= nullptr;
43 bool check_caps(MonOpRequestRef op
, const uuid_d
& fsid
);
46 MgrMonitor(Monitor
*mn
, Paxos
*p
, const string
& service_name
)
47 : PaxosService(mn
, p
, service_name
)
49 ~MgrMonitor() override
{}
52 void on_shutdown() override
;
54 const MgrMap
&get_map() const { return map
; }
56 bool in_use() const { return map
.epoch
> 0; }
58 void create_initial() override
;
59 void update_from_paxos(bool *need_bootstrap
) override
;
60 void create_pending() override
;
61 void encode_pending(MonitorDBStore::TransactionRef t
) override
;
63 bool preprocess_query(MonOpRequestRef op
) override
;
64 bool prepare_update(MonOpRequestRef op
) override
;
66 bool preprocess_command(MonOpRequestRef op
);
67 bool prepare_command(MonOpRequestRef op
);
69 void encode_full(MonitorDBStore::TransactionRef t
) override
{ }
71 bool preprocess_beacon(MonOpRequestRef op
);
72 bool prepare_beacon(MonOpRequestRef op
);
74 void check_sub(Subscription
*sub
);
78 void on_active() override
;
79 void get_health(list
<pair
<health_status_t
,string
> >& summary
,
80 list
<pair
<health_status_t
,string
> > *detail
,
81 CephContext
*cct
) const override
;
84 void print_summary(Formatter
*f
, std::ostream
*ss
) const;
86 friend class C_Updated
;