]> git.proxmox.com Git - ceph.git/blame - ceph/src/mds/Beacon.h
bump version to 12.2.1-pve3
[ceph.git] / ceph / src / mds / Beacon.h
CommitLineData
7c673cae
FG
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) 2012 Red Hat
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
15
16#ifndef BEACON_STATE_H
17#define BEACON_STATE_H
18
19#include "include/types.h"
20#include "include/Context.h"
21#include "common/Mutex.h"
22#include "msg/Dispatcher.h"
23#include "messages/MMDSBeacon.h"
24
25class MonClient;
26class MMDSBeacon;
27class Message;
28class MDSRank;
29
30
31/**
32 * One of these per MDS. Handle beacon logic in this separate class so
33 * that a busy MDS holding its own lock does not hold up sending beacon
34 * messages to the mon and cause false lagginess.
35 *
36 * So that we can continue to operate while the MDS is holding its own lock,
37 * we keep copies of the data needed to generate beacon messages. The MDS is
38 * responsible for calling Beacon::notify_* when things change.
39 */
40class Beacon : public Dispatcher
41{
42public:
43 Beacon(CephContext *cct_, MonClient *monc_, std::string name);
44 ~Beacon() override;
45
46 void init(MDSMap const *mdsmap);
47 void shutdown();
48
49 bool ms_dispatch(Message *m) override;
50 void ms_handle_connect(Connection *c) override {}
51 bool ms_handle_reset(Connection *c) override {return false;}
52 void ms_handle_remote_reset(Connection *c) override {}
53 bool ms_handle_refused(Connection *c) override {return false;}
54
55 void notify_mdsmap(MDSMap const *mdsmap);
56 void notify_health(MDSRank const *mds);
57
58 void handle_mds_beacon(MMDSBeacon *m);
59 void send();
60
61 void set_want_state(MDSMap const *mdsmap, MDSMap::DaemonState const newstate);
62 MDSMap::DaemonState get_want_state() const;
63
64 /**
65 * Send a beacon, and block until the ack is received from the mon
66 * or `duration` seconds pass, whichever happens sooner. Useful
67 * for emitting a last message on shutdown.
68 */
69 void send_and_wait(const double duration);
70
71 bool is_laggy();
72 utime_t get_laggy_until() const;
73
74private:
75 void _notify_mdsmap(MDSMap const *mdsmap);
76 void _send();
77
78 //CephContext *cct;
79 mutable Mutex lock;
80 MonClient* monc;
81 SafeTimer timer;
82
83 // Items we duplicate from the MDS to have access under our own lock
84 std::string name;
85 version_t epoch;
86 CompatSet compat;
87 mds_rank_t standby_for_rank;
88 std::string standby_for_name;
89 fs_cluster_id_t standby_for_fscid;
90 bool standby_replay;
91 MDSMap::DaemonState want_state;
92
93 // Internal beacon state
94 version_t last_seq; // last seq sent to monitor
95 std::map<version_t,utime_t> seq_stamp; // seq # -> time sent
96 utime_t last_acked_stamp; // last time we sent a beacon that got acked
97 utime_t last_mon_reconnect;
98 bool was_laggy;
99 utime_t laggy_until;
100
101 // Health status to be copied into each beacon message
102 MDSHealth health;
103
104 // Ticker
105 class C_MDS_BeaconSender;
106 C_MDS_BeaconSender *sender;
107
108 version_t awaiting_seq;
109 Cond waiting_cond;
110};
111
112#endif // BEACON_STATE_H
113