]>
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_MDIRUPDATE_H | |
17 | #define CEPH_MDIRUPDATE_H | |
18 | ||
19 | #include "msg/Message.h" | |
20 | ||
21 | class MDirUpdate : public Message { | |
94b18763 FG |
22 | public: |
23 | MDirUpdate() : Message(MSG_MDS_DIRUPDATE) {} | |
24 | MDirUpdate(mds_rank_t f, | |
25 | dirfrag_t dirfrag, | |
26 | int dir_rep, | |
27 | const std::set<int32_t>& dir_rep_by, | |
28 | filepath& path, | |
29 | bool discover = false) : | |
30 | Message(MSG_MDS_DIRUPDATE), from_mds(f), dirfrag(dirfrag), | |
31 | dir_rep(dir_rep), dir_rep_by(dir_rep_by), path(path) { | |
32 | this->discover = discover ? 5 : 0; | |
33 | } | |
7c673cae | 34 | |
7c673cae FG |
35 | mds_rank_t get_source_mds() const { return from_mds; } |
36 | dirfrag_t get_dirfrag() const { return dirfrag; } | |
37 | int get_dir_rep() const { return dir_rep; } | |
94b18763 | 38 | const std::set<int32_t>& get_dir_rep_by() const { return dir_rep_by; } |
224ce89b | 39 | bool should_discover() const { return discover > tried_discover; } |
7c673cae FG |
40 | const filepath& get_path() const { return path; } |
41 | ||
224ce89b WB |
42 | bool has_tried_discover() const { return tried_discover > 0; } |
43 | void inc_tried_discover() { ++tried_discover; } | |
7c673cae | 44 | |
7c673cae FG |
45 | const char *get_type_name() const override { return "dir_update"; } |
46 | void print(ostream& out) const override { | |
47 | out << "dir_update(" << get_dirfrag() << ")"; | |
48 | } | |
49 | ||
50 | void decode_payload() override { | |
51 | bufferlist::iterator p = payload.begin(); | |
52 | ::decode(from_mds, p); | |
53 | ::decode(dirfrag, p); | |
54 | ::decode(dir_rep, p); | |
55 | ::decode(discover, p); | |
56 | ::decode(dir_rep_by, p); | |
57 | ::decode(path, p); | |
58 | } | |
59 | ||
60 | void encode_payload(uint64_t features) override { | |
61 | ::encode(from_mds, payload); | |
62 | ::encode(dirfrag, payload); | |
63 | ::encode(dir_rep, payload); | |
64 | ::encode(discover, payload); | |
65 | ::encode(dir_rep_by, payload); | |
66 | ::encode(path, payload); | |
67 | } | |
94b18763 FG |
68 | |
69 | private: | |
70 | ~MDirUpdate() override {} | |
71 | ||
72 | mds_rank_t from_mds = -1; | |
73 | dirfrag_t dirfrag; | |
74 | int32_t dir_rep = 5; | |
75 | int32_t discover = 5; | |
76 | std::set<int32_t> dir_rep_by; | |
77 | filepath path; | |
78 | int tried_discover = 0; | |
7c673cae FG |
79 | }; |
80 | ||
81 | #endif |