]> git.proxmox.com Git - ceph.git/blob - ceph/src/mon/PaxosFSMap.h
update sources to 12.2.8
[ceph.git] / ceph / src / mon / PaxosFSMap.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_PAXOS_FSMAP_H
16 #define CEPH_PAXOS_FSMAP_H
17
18 #include "mds/FSMap.h"
19 #include "mds/MDSMap.h"
20
21 #include "include/assert.h"
22
23 class PaxosFSMap {
24 public:
25 virtual ~PaxosFSMap() {}
26
27 const FSMap &get_pending_fsmap() const { assert(is_leader()); return pending_fsmap; }
28 const FSMap &get_fsmap() const { return fsmap; }
29
30 virtual bool is_leader() const = 0;
31
32 protected:
33 FSMap &get_pending_fsmap_writeable() { assert(is_leader()); return pending_fsmap; }
34
35 FSMap &create_pending() {
36 assert(is_leader());
37 pending_fsmap = fsmap;
38 pending_fsmap.epoch++;
39 return pending_fsmap;
40 }
41
42 void decode(bufferlist &bl) {
43 fsmap.decode(bl);
44 pending_fsmap = FSMap(); /* nuke it to catch invalid access */
45 }
46
47 private:
48 /* Keep these PRIVATE to prevent unprotected manipulation. */
49 FSMap fsmap; /* the current epoch */
50 FSMap pending_fsmap; /* the next epoch */
51 };
52
53
54 #endif