]> git.proxmox.com Git - ceph.git/blame - ceph/src/mon/PaxosFSMap.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / mon / PaxosFSMap.h
CommitLineData
28e407b8
AA
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
11fdf7f2 21#include "include/ceph_assert.h"
28e407b8
AA
22
23class PaxosFSMap {
24public:
25 virtual ~PaxosFSMap() {}
26
11fdf7f2 27 const FSMap &get_pending_fsmap() const { ceph_assert(is_leader()); return pending_fsmap; }
28e407b8
AA
28 const FSMap &get_fsmap() const { return fsmap; }
29
30 virtual bool is_leader() const = 0;
31
32protected:
11fdf7f2 33 FSMap &get_pending_fsmap_writeable() { ceph_assert(is_leader()); return pending_fsmap; }
28e407b8 34
28e407b8 35 FSMap &create_pending() {
11fdf7f2 36 ceph_assert(is_leader());
28e407b8
AA
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
47private:
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