]>
Commit | Line | Data |
---|---|---|
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) 2004-2006 Sage Weil <sage@newdream.net> | |
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 CEPH_MHEARTBEAT_H | |
17 | #define CEPH_MHEARTBEAT_H | |
18 | ||
19 | #include "include/types.h" | |
20 | #include "msg/Message.h" | |
11fdf7f2 | 21 | #include "common/DecayCounter.h" |
7c673cae | 22 | |
9f95a23c | 23 | class MHeartbeat : public Message { |
11fdf7f2 | 24 | private: |
7c673cae | 25 | mds_load_t load; |
28e407b8 | 26 | __s32 beat = 0; |
7c673cae FG |
27 | map<mds_rank_t, float> import_map; |
28 | ||
29 | public: | |
11fdf7f2 TL |
30 | const mds_load_t& get_load() const { return load; } |
31 | int get_beat() const { return beat; } | |
7c673cae | 32 | |
11fdf7f2 TL |
33 | const map<mds_rank_t, float>& get_import_map() const { return import_map; } |
34 | map<mds_rank_t, float>& get_import_map() { return import_map; } | |
7c673cae | 35 | |
11fdf7f2 | 36 | protected: |
9f95a23c | 37 | MHeartbeat() : Message(MSG_MDS_HEARTBEAT), load(DecayRate()) {} |
7c673cae | 38 | MHeartbeat(mds_load_t& load, int beat) |
9f95a23c TL |
39 | : Message(MSG_MDS_HEARTBEAT), |
40 | load(load), | |
41 | beat(beat) | |
42 | {} | |
7c673cae FG |
43 | ~MHeartbeat() override {} |
44 | ||
45 | public: | |
11fdf7f2 | 46 | std::string_view get_type_name() const override { return "HB"; } |
7c673cae FG |
47 | |
48 | void encode_payload(uint64_t features) override { | |
11fdf7f2 TL |
49 | using ceph::encode; |
50 | encode(load, payload); | |
51 | encode(beat, payload); | |
52 | encode(import_map, payload); | |
7c673cae FG |
53 | } |
54 | void decode_payload() override { | |
11fdf7f2 TL |
55 | auto p = payload.cbegin(); |
56 | decode(load, p); | |
57 | decode(beat, p); | |
58 | decode(import_map, p); | |
7c673cae | 59 | } |
9f95a23c TL |
60 | private: |
61 | template<class T, typename... Args> | |
62 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
7c673cae FG |
63 | }; |
64 | ||
65 | #endif |