]>
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" | |
11fdf7f2 | 20 | #include "common/DecayCounter.h" |
f67539c2 | 21 | #include "messages/MMDSOp.h" |
7c673cae | 22 | |
f67539c2 | 23 | class MHeartbeat final : public MMDSOp { |
11fdf7f2 | 24 | private: |
7c673cae | 25 | mds_load_t load; |
f67539c2 TL |
26 | __s32 beat = 0; |
27 | std::map<mds_rank_t, float> import_map; | |
7c673cae FG |
28 | |
29 | public: | |
11fdf7f2 TL |
30 | const mds_load_t& get_load() const { return load; } |
31 | int get_beat() const { return beat; } | |
7c673cae | 32 | |
f67539c2 TL |
33 | const std::map<mds_rank_t, float>& get_import_map() const { return import_map; } |
34 | std::map<mds_rank_t, float>& get_import_map() { return import_map; } | |
7c673cae | 35 | |
11fdf7f2 | 36 | protected: |
f67539c2 | 37 | MHeartbeat() : MMDSOp(MSG_MDS_HEARTBEAT), load(DecayRate()) {} |
7c673cae | 38 | MHeartbeat(mds_load_t& load, int beat) |
f67539c2 | 39 | : MMDSOp(MSG_MDS_HEARTBEAT), |
9f95a23c TL |
40 | load(load), |
41 | beat(beat) | |
42 | {} | |
f67539c2 | 43 | ~MHeartbeat() final {} |
7c673cae FG |
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 { | |
f67539c2 | 55 | using ceph::decode; |
11fdf7f2 TL |
56 | auto p = payload.cbegin(); |
57 | decode(load, p); | |
58 | decode(beat, p); | |
59 | decode(import_map, p); | |
7c673cae | 60 | } |
9f95a23c TL |
61 | private: |
62 | template<class T, typename... Args> | |
63 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
20effc67 TL |
64 | template<class T, typename... Args> |
65 | friend MURef<T> crimson::make_message(Args&&... args); | |
7c673cae FG |
66 | }; |
67 | ||
68 | #endif |