]>
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 { | |
22 | mds_rank_t from_mds; | |
23 | dirfrag_t dirfrag; | |
24 | int32_t dir_rep; | |
25 | int32_t discover; | |
26 | compact_set<int32_t> dir_rep_by; | |
27 | filepath path; | |
28 | ||
29 | public: | |
30 | mds_rank_t get_source_mds() const { return from_mds; } | |
31 | dirfrag_t get_dirfrag() const { return dirfrag; } | |
32 | int get_dir_rep() const { return dir_rep; } | |
33 | const compact_set<int>& get_dir_rep_by() const { return dir_rep_by; } | |
34 | bool should_discover() const { return discover > 0; } | |
35 | const filepath& get_path() const { return path; } | |
36 | ||
37 | void tried_discover() { | |
38 | if (discover) discover--; | |
39 | } | |
40 | ||
41 | MDirUpdate() : Message(MSG_MDS_DIRUPDATE) {} | |
42 | MDirUpdate(mds_rank_t f, | |
43 | dirfrag_t dirfrag, | |
44 | int dir_rep, | |
45 | compact_set<int>& dir_rep_by, | |
46 | filepath& path, | |
47 | bool discover = false) : | |
48 | Message(MSG_MDS_DIRUPDATE) { | |
49 | this->from_mds = f; | |
50 | this->dirfrag = dirfrag; | |
51 | this->dir_rep = dir_rep; | |
52 | this->dir_rep_by = dir_rep_by; | |
53 | if (discover) this->discover = 5; | |
54 | else this->discover = 0; | |
55 | this->path = path; | |
56 | } | |
57 | private: | |
58 | ~MDirUpdate() override {} | |
59 | ||
60 | public: | |
61 | const char *get_type_name() const override { return "dir_update"; } | |
62 | void print(ostream& out) const override { | |
63 | out << "dir_update(" << get_dirfrag() << ")"; | |
64 | } | |
65 | ||
66 | void decode_payload() override { | |
67 | bufferlist::iterator p = payload.begin(); | |
68 | ::decode(from_mds, p); | |
69 | ::decode(dirfrag, p); | |
70 | ::decode(dir_rep, p); | |
71 | ::decode(discover, p); | |
72 | ::decode(dir_rep_by, p); | |
73 | ::decode(path, p); | |
74 | } | |
75 | ||
76 | void encode_payload(uint64_t features) override { | |
77 | ::encode(from_mds, payload); | |
78 | ::encode(dirfrag, payload); | |
79 | ::encode(dir_rep, payload); | |
80 | ::encode(discover, payload); | |
81 | ::encode(dir_rep_by, payload); | |
82 | ::encode(path, payload); | |
83 | } | |
84 | }; | |
85 | ||
86 | #endif |