initial code repo
[stor4nfv.git] / src / ceph / src / messages / MOSDBoot.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 #ifndef CEPH_MOSDBOOT_H
16 #define CEPH_MOSDBOOT_H
17
18 #include "messages/PaxosServiceMessage.h"
19
20 #include "include/types.h"
21 #include "osd/osd_types.h"
22
23 class MOSDBoot : public PaxosServiceMessage {
24
25   static const int HEAD_VERSION = 6;
26   static const int COMPAT_VERSION = 6;
27
28  public:
29   OSDSuperblock sb;
30   entity_addr_t hb_back_addr, hb_front_addr;
31   entity_addr_t cluster_addr;
32   epoch_t boot_epoch;  // last epoch this daemon was added to the map (if any)
33   map<string,string> metadata; ///< misc metadata about this osd
34   uint64_t osd_features;
35
36   MOSDBoot()
37     : PaxosServiceMessage(MSG_OSD_BOOT, 0, HEAD_VERSION, COMPAT_VERSION),
38       boot_epoch(0), osd_features(0)
39   { }
40   MOSDBoot(OSDSuperblock& s, epoch_t e, epoch_t be,
41            const entity_addr_t& hb_back_addr_ref,
42            const entity_addr_t& hb_front_addr_ref,
43            const entity_addr_t& cluster_addr_ref,
44            uint64_t feat)
45     : PaxosServiceMessage(MSG_OSD_BOOT, e, HEAD_VERSION, COMPAT_VERSION),
46       sb(s),
47       hb_back_addr(hb_back_addr_ref),
48       hb_front_addr(hb_front_addr_ref),
49       cluster_addr(cluster_addr_ref),
50       boot_epoch(be),
51       osd_features(feat)
52   { }
53   
54 private:
55   ~MOSDBoot() override { }
56
57 public:
58   const char *get_type_name() const override { return "osd_boot"; }
59   void print(ostream& out) const override {
60     out << "osd_boot(osd." << sb.whoami << " booted " << boot_epoch
61         << " features " << osd_features
62         << " v" << version << ")";
63   }
64   
65   void encode_payload(uint64_t features) override {
66     paxos_encode();
67     ::encode(sb, payload);
68     ::encode(hb_back_addr, payload, features);
69     ::encode(cluster_addr, payload, features);
70     ::encode(boot_epoch, payload);
71     ::encode(hb_front_addr, payload, features);
72     ::encode(metadata, payload);
73     ::encode(osd_features, payload);
74   }
75   void decode_payload() override {
76     bufferlist::iterator p = payload.begin();
77     paxos_decode(p);
78     ::decode(sb, p);
79     ::decode(hb_back_addr, p);
80     ::decode(cluster_addr, p);
81     ::decode(boot_epoch, p);
82     ::decode(hb_front_addr, p);
83     ::decode(metadata, p);
84     ::decode(osd_features, p);
85   }
86 };
87
88 #endif