]>
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 | #ifndef CEPH_MDSTABLESERVER_H | |
16 | #define CEPH_MDSTABLESERVER_H | |
17 | ||
18 | #include "MDSTable.h" | |
19 | ||
20 | class MMDSTableRequest; | |
21 | ||
22 | class MDSTableServer : public MDSTable { | |
23 | public: | |
24 | int table; | |
25 | map<version_t,mds_table_pending_t> pending_for_mds; // ** child should encode this! ** | |
26 | ||
27 | ||
28 | private: | |
29 | void handle_prepare(MMDSTableRequest *m); | |
30 | void _prepare_logged(MMDSTableRequest *m, version_t tid); | |
31 | friend class C_Prepare; | |
32 | ||
33 | void handle_commit(MMDSTableRequest *m); | |
34 | void _commit_logged(MMDSTableRequest *m); | |
35 | friend class C_Commit; | |
36 | ||
37 | ||
38 | void handle_rollback(MMDSTableRequest *m); | |
39 | ||
40 | public: | |
41 | virtual void handle_query(MMDSTableRequest *m) = 0; | |
42 | virtual void _prepare(bufferlist &bl, uint64_t reqid, mds_rank_t bymds) = 0; | |
43 | virtual bool _commit(version_t tid, MMDSTableRequest *req=NULL) = 0; | |
44 | virtual void _rollback(version_t tid) = 0; | |
45 | virtual void _server_update(bufferlist& bl) { ceph_abort(); } | |
46 | ||
47 | void _note_prepare(mds_rank_t mds, uint64_t reqid) { | |
48 | pending_for_mds[version].mds = mds; | |
49 | pending_for_mds[version].reqid = reqid; | |
50 | pending_for_mds[version].tid = version; | |
51 | } | |
52 | void _note_commit(uint64_t tid) { | |
53 | pending_for_mds.erase(tid); | |
54 | } | |
55 | void _note_rollback(uint64_t tid) { | |
56 | pending_for_mds.erase(tid); | |
57 | } | |
58 | ||
59 | ||
60 | MDSTableServer(MDSRank *m, int tab) : MDSTable(m, get_mdstable_name(tab), false), table(tab) {} | |
61 | ~MDSTableServer() override {} | |
62 | ||
63 | void handle_request(MMDSTableRequest *m); | |
64 | void do_server_update(bufferlist& bl); | |
65 | ||
66 | virtual void encode_server_state(bufferlist& bl) const = 0; | |
67 | virtual void decode_server_state(bufferlist::iterator& bl) = 0; | |
68 | ||
69 | void encode_state(bufferlist& bl) const override { | |
70 | encode_server_state(bl); | |
71 | ::encode(pending_for_mds, bl); | |
72 | } | |
73 | void decode_state(bufferlist::iterator& bl) override { | |
74 | decode_server_state(bl); | |
75 | ::decode(pending_for_mds, bl); | |
76 | } | |
77 | ||
78 | // recovery | |
79 | void finish_recovery(set<mds_rank_t>& active); | |
80 | void handle_mds_recovery(mds_rank_t who); | |
81 | }; | |
82 | ||
83 | #endif |