]> git.proxmox.com Git - ceph.git/blob - ceph/src/mds/MDSTableClient.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / mds / MDSTableClient.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 #ifndef CEPH_MDSTABLECLIENT_H
16 #define CEPH_MDSTABLECLIENT_H
17
18 #include "include/types.h"
19 #include "MDSContext.h"
20 #include "mds_table_types.h"
21
22 #include "messages/MMDSTableRequest.h"
23
24 class MDSRank;
25 class LogSegment;
26
27 class MDSTableClient {
28 public:
29 MDSTableClient(MDSRank *m, int tab) :
30 mds(m), table(tab) {}
31 virtual ~MDSTableClient() {}
32
33 void handle_request(const cref_t<MMDSTableRequest> &m);
34
35 void _prepare(bufferlist& mutation, version_t *ptid, bufferlist *pbl, MDSContext *onfinish);
36 void commit(version_t tid, LogSegment *ls);
37
38 void resend_commits();
39 void resend_prepares();
40
41 // for recovery (by me)
42 void got_journaled_agree(version_t tid, LogSegment *ls);
43 void got_journaled_ack(version_t tid);
44
45 bool has_committed(version_t tid) const {
46 return pending_commit.count(tid) == 0;
47 }
48 void wait_for_ack(version_t tid, MDSContext *c) {
49 ack_waiters[tid].push_back(c);
50 }
51
52 std::set<version_t> get_journaled_tids() const {
53 std::set<version_t> tids;
54 for (auto p : pending_commit)
55 tids.insert(p.first);
56 return tids;
57 }
58
59 void handle_mds_failure(mds_rank_t mds);
60
61 // child must implement
62 virtual void resend_queries() = 0;
63 virtual void handle_query_result(const cref_t<MMDSTableRequest> &m) = 0;
64 virtual void handle_notify_prep(const cref_t<MMDSTableRequest> &m) = 0;
65 virtual void notify_commit(version_t tid) = 0;
66 protected:
67 // prepares
68 struct _pending_prepare {
69 _pending_prepare() {}
70 _pending_prepare(MDSContext *c, version_t *pt, bufferlist *pb, bufferlist& m) :
71 onfinish(c), ptid(pt), pbl(pb), mutation(m) {}
72
73 MDSContext *onfinish = nullptr;
74 version_t *ptid = nullptr;
75 bufferlist *pbl = nullptr;
76 bufferlist mutation;
77 };
78
79 friend class C_LoggedAck;
80
81 void handle_reply(class MMDSTableQuery *m);
82 void _logged_ack(version_t tid);
83
84 MDSRank *mds;
85 int table;
86
87 uint64_t last_reqid = ~0ULL;
88
89 bool server_ready = false;
90
91 std::map<uint64_t, _pending_prepare> pending_prepare;
92 std::map<version_t, uint64_t> prepared_update;
93 std::list<_pending_prepare> waiting_for_reqid;
94
95 // pending commits
96 std::map<version_t, LogSegment*> pending_commit;
97 std::map<version_t, MDSContext::vec > ack_waiters;
98 };
99 #endif