Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / messages / MClientRequestForward.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_MCLIENTREQUESTFORWARD_H
17 #define CEPH_MCLIENTREQUESTFORWARD_H
18
19 #include "msg/Message.h"
20
21 class MClientRequestForward : public Message {
22   int32_t dest_mds;
23   int32_t num_fwd;
24   bool client_must_resend;
25
26  public:
27   MClientRequestForward()
28     : Message(CEPH_MSG_CLIENT_REQUEST_FORWARD),
29       dest_mds(-1), num_fwd(-1), client_must_resend(false) {}
30   MClientRequestForward(ceph_tid_t t, int dm, int nf, bool cmr) :
31     Message(CEPH_MSG_CLIENT_REQUEST_FORWARD),
32     dest_mds(dm), num_fwd(nf), client_must_resend(cmr) {
33     assert(client_must_resend);
34     header.tid = t;
35   }
36 private:
37   ~MClientRequestForward() override {}
38
39 public:
40   int get_dest_mds() { return dest_mds; }
41   int get_num_fwd() { return num_fwd; }
42   bool must_resend() { return client_must_resend; }
43
44   const char *get_type_name() const override { return "client_request_forward"; }
45   void print(ostream& o) const override {
46     o << "client_request_forward(" << get_tid()
47       << " to mds." << dest_mds
48       << " num_fwd=" << num_fwd
49       << (client_must_resend ? " client_must_resend":"")
50       << ")";
51   }
52
53   void encode_payload(uint64_t features) override {
54     ::encode(dest_mds, payload);
55     ::encode(num_fwd, payload);
56     ::encode(client_must_resend, payload);
57   }
58
59   void decode_payload() override {
60     bufferlist::iterator p = payload.begin();
61     ::decode(dest_mds, p);
62     ::decode(num_fwd, p);
63     ::decode(client_must_resend, p);
64   }
65 };
66
67 #endif