summaryrefslogtreecommitdiffstats
path: root/src/messages/MOSDBeacon.h
blob: 998d6e638946ab41f9dea192fd75ea268e9a7088 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#pragma once

#include "PaxosServiceMessage.h"

class MOSDBeacon : public PaxosServiceMessage {
private:
  static constexpr int HEAD_VERSION = 3;
  static constexpr int COMPAT_VERSION = 1;
public:
  std::vector<pg_t> pgs;
  epoch_t min_last_epoch_clean = 0;
  utime_t last_purged_snaps_scrub;
  int osd_beacon_report_interval = 0;

  MOSDBeacon()
    : PaxosServiceMessage{MSG_OSD_BEACON, 0,
			  HEAD_VERSION, COMPAT_VERSION}
  {}
  MOSDBeacon(epoch_t e, epoch_t min_lec, utime_t ls, int interval)
    : PaxosServiceMessage{MSG_OSD_BEACON, e,
			  HEAD_VERSION, COMPAT_VERSION},
      min_last_epoch_clean(min_lec),
      last_purged_snaps_scrub(ls),
      osd_beacon_report_interval(interval)
  {}
  void encode_payload(uint64_t features) override {
    using ceph::encode;
    paxos_encode();
    encode(pgs, payload);
    encode(min_last_epoch_clean, payload);
    encode(last_purged_snaps_scrub, payload);
    encode(osd_beacon_report_interval, payload);
  }
  void decode_payload() override {
    auto p = payload.cbegin();
    using ceph::decode;
    paxos_decode(p);
    decode(pgs, p);
    decode(min_last_epoch_clean, p);
    if (header.version >= 2) {
      decode(last_purged_snaps_scrub, p);
    }
    if (header.version >= 3) {
      decode(osd_beacon_report_interval, p);
    } else {
      osd_beacon_report_interval = 0;
    }
  }
  std::string_view get_type_name() const override { return "osd_beacon"; }
  void print(std::ostream &out) const {
    out << get_type_name()
        << "(pgs " << pgs
        << " lec " << min_last_epoch_clean
        << " last_purged_snaps_scrub " << last_purged_snaps_scrub
        << " osd_beacon_report_interval " << osd_beacon_report_interval
        << " v" << version << ")";
  }
private:
  template<class T, typename... Args>
  friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};