Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / messages / MHeartbeat.h
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"
21
22 class MHeartbeat : public Message {
23   mds_load_t load;
24   __s32        beat;
25   map<mds_rank_t, float> import_map;
26
27  public:
28   mds_load_t& get_load() { return load; }
29   int get_beat() { return beat; }
30
31   map<mds_rank_t, float>& get_import_map() {
32     return import_map;
33   }
34
35   MHeartbeat()
36     : Message(MSG_MDS_HEARTBEAT), load(utime_t()) { }
37   MHeartbeat(mds_load_t& load, int beat)
38     : Message(MSG_MDS_HEARTBEAT),
39       load(load) {
40     this->beat = beat;
41   }
42 private:
43   ~MHeartbeat() override {}
44
45 public:
46   const char *get_type_name() const override { return "HB"; }
47
48   void encode_payload(uint64_t features) override {
49     ::encode(load, payload);
50     ::encode(beat, payload);
51     ::encode(import_map, payload);
52   }
53   void decode_payload() override {
54     bufferlist::iterator p = payload.begin();
55     utime_t now(ceph_clock_now());
56     ::decode(load, now, p);
57     ::decode(beat, p);
58     ::decode(import_map, p);
59   }
60
61 };
62
63 #endif