Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / mon / PGStatService.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) 2017 Greg Farnum/Red Hat <gfarnum@redhat.com>
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  * This service abstracts out the specific implementation providing information
17  * needed by parts of the Monitor based around PGStats. This'll make for
18  * an easier transition from the PGMonitor-based queries where we handle
19  * PGStats directly, to where we are getting information passed in from
20  * the Ceph Manager.
21  *
22  * This initial implementation cheats by wrapping a PGMap so we don't need
23  * to reimplement everything in one go.
24  */
25
26 #ifndef CEPH_PGSTATSERVICE_H
27 #define CEPH_PGSTATSERVICE_H
28
29 struct creating_pgs_t;
30
31 class PGStatService {
32 public:
33   PGStatService() {}
34   virtual ~PGStatService() {}
35   // FIXME: Kill this once we rip out PGMonitor post-luminous
36   /** returns true if the underlying data is readable. Always true
37    *  post-luminous, but not when we are redirecting to the PGMonitor
38    */
39   virtual bool is_readable() const { return true; }
40   virtual const pool_stat_t* get_pool_stat(int64_t poolid) const = 0;
41   virtual const osd_stat_t& get_osd_sum() const {
42     ceph_abort();
43   }
44   virtual const osd_stat_t *get_osd_stat(int osd) const {
45     ceph_abort();
46   }
47   virtual const mempool::pgmap::unordered_map<int32_t,osd_stat_t>& get_osd_stat() const {
48     ceph_abort();
49   }
50   virtual float get_full_ratio() const {
51     ceph_abort();
52   }
53   virtual float get_nearfull_ratio() const {
54     ceph_abort();
55   }
56   virtual bool have_creating_pgs() const {
57     ceph_abort();
58   }
59   virtual bool is_creating_pg(pg_t pgid) const {
60     ceph_abort();
61   }
62   virtual epoch_t get_min_last_epoch_clean() const {
63     ceph_abort();
64   }
65
66   virtual bool have_full_osds() const {
67     ceph_abort();
68   }
69   virtual bool have_nearfull_osds() const {
70     ceph_abort();
71   }
72
73   virtual size_t get_num_pg_by_osd(int osd) const {
74     ceph_abort();
75   }
76   virtual ceph_statfs get_statfs(OSDMap &osd_map,
77                                  boost::optional<int64_t> data_pool) const = 0;
78   virtual void print_summary(Formatter *f, ostream *out) const = 0;
79   virtual void dump_info(Formatter *f) const = 0;
80   virtual void dump_fs_stats(stringstream *ss, Formatter *f, bool verbose) const = 0;
81   virtual void dump_pool_stats(const OSDMap& osdm, stringstream *ss, Formatter *f,
82                                bool verbose) const = 0;
83
84   virtual int process_pg_command(const string& prefix,
85                                  const map<string,cmd_vartype>& cmdmap,
86                                  const OSDMap& osdmap,
87                                  Formatter *f,
88                                  stringstream *ss,
89                                  bufferlist *odata) const {
90     ceph_abort();
91   }
92
93 };
94
95 class MonPGStatService : virtual public PGStatService {
96 public:
97   MonPGStatService() : PGStatService() {}
98   virtual ~MonPGStatService() {}
99   /**
100    * For upgrades. If the PGMap has newer data than the monitor's new
101    * creating_pgs (scan_epoch), insert them into the passed pending_creates.
102    */
103   virtual unsigned maybe_add_creating_pgs(epoch_t scan_epoch,
104      const mempool::osdmap::map<int64_t,pg_pool_t>& pools,
105      creating_pgs_t *pending_creates) const {
106     ceph_abort();
107     return 0;
108   }
109   /**
110    * For upgrades. If some PGs are created before all OSDs are luminous
111    * and start sending MOSDPGCreated, we need to be sync with pgmap
112    *
113    */
114   virtual void maybe_trim_creating_pgs(creating_pgs_t *creates) const {
115     ceph_abort();
116   }
117   virtual int reweight_by_utilization(const OSDMap &osd_map,
118                               int oload,
119                               double max_changef,
120                               int max_osds,
121                               bool by_pg, const set<int64_t> *pools,
122                               bool no_increasing,
123                               mempool::osdmap::map<int32_t, uint32_t>* new_weights,
124                               std::stringstream *ss,
125                               std::string *out_str,
126                                       Formatter *f) const {
127     ceph_abort();
128   }
129 };
130
131 #endif