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.
15 #include "include/Context.h"
17 #include "PaxosService.h"
20 class MgrMonitor
: public PaxosService
25 utime_t first_seen_inactive
;
27 std::map
<uint64_t, utime_t
> last_beacon
;
30 * If a standby is available, make it active, given that
31 * there is currently no active daemon.
33 * @return true if a standby was promoted
35 bool promote_standby();
37 void drop_standby(uint64_t gid
);
39 Context
*digest_callback
;
41 bool check_caps(MonOpRequestRef op
, const uuid_d
& fsid
);
44 MgrMonitor(Monitor
*mn
, Paxos
*p
, const string
& service_name
)
45 : PaxosService(mn
, p
, service_name
), digest_callback(nullptr)
49 void on_shutdown() override
;
51 const MgrMap
&get_map() const { return map
; }
53 bool in_use() const { return map
.epoch
> 0; }
55 void create_initial() override
;
56 void update_from_paxos(bool *need_bootstrap
) override
;
57 void create_pending() override
;
58 void encode_pending(MonitorDBStore::TransactionRef t
) override
;
60 bool preprocess_query(MonOpRequestRef op
) override
;
61 bool prepare_update(MonOpRequestRef op
) override
;
63 bool preprocess_command(MonOpRequestRef op
);
64 bool prepare_command(MonOpRequestRef op
);
66 void encode_full(MonitorDBStore::TransactionRef t
) override
{ }
68 bool preprocess_beacon(MonOpRequestRef op
);
69 bool prepare_beacon(MonOpRequestRef op
);
71 void check_sub(Subscription
*sub
);
75 void on_active() override
;
76 void get_health(list
<pair
<health_status_t
,string
> >& summary
,
77 list
<pair
<health_status_t
,string
> > *detail
,
78 CephContext
*cct
) const override
;
81 void print_summary(Formatter
*f
, std::ostream
*ss
) const;
83 friend class C_Updated
;