Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / messages / MExportDirPrep.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_MEXPORTDIRPREP_H
17 #define CEPH_MEXPORTDIRPREP_H
18
19 #include "msg/Message.h"
20 #include "include/types.h"
21
22 class MExportDirPrep : public Message {
23   dirfrag_t dirfrag;
24  public:
25   bufferlist basedir;
26   list<dirfrag_t> bounds;
27   list<bufferlist> traces;
28 private:
29   set<mds_rank_t> bystanders;
30   bool b_did_assim;
31
32 public:
33   dirfrag_t get_dirfrag() { return dirfrag; }
34   list<dirfrag_t>& get_bounds() { return bounds; }
35   set<mds_rank_t> &get_bystanders() { return bystanders; }
36
37   bool did_assim() { return b_did_assim; }
38   void mark_assim() { b_did_assim = true; }
39
40   MExportDirPrep() {
41     b_did_assim = false;
42   }
43   MExportDirPrep(dirfrag_t df, uint64_t tid) :
44     Message(MSG_MDS_EXPORTDIRPREP),
45     dirfrag(df), b_did_assim(false) {
46     set_tid(tid);
47   }
48 private:
49   ~MExportDirPrep() override {}
50
51 public:
52   const char *get_type_name() const override { return "ExP"; }
53   void print(ostream& o) const override {
54     o << "export_prep(" << dirfrag << ")";
55   }
56
57   void add_bound(dirfrag_t df) {
58     bounds.push_back( df );
59   }
60   void add_trace(bufferlist& bl) {
61     traces.push_back(bl);
62   }
63   void add_bystander(mds_rank_t who) {
64     bystanders.insert(who);
65   }
66
67   void decode_payload() override {
68     bufferlist::iterator p = payload.begin();
69     ::decode(dirfrag, p);
70     ::decode(basedir, p);
71     ::decode(bounds, p);
72     ::decode(traces, p);
73     ::decode(bystanders, p);
74   }
75
76   void encode_payload(uint64_t features) override {
77     ::encode(dirfrag, payload);
78     ::encode(basedir, payload);
79     ::encode(bounds, payload);
80     ::encode(traces, payload);
81     ::encode(bystanders, payload);
82   }
83 };
84
85 #endif