From f495ce54639d41ba58667946437e0ef79201d043 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 14 Sep 2017 16:11:15 +0800 Subject: [PATCH] mon: more constness Signed-off-by: Kefu Chai --- src/mon/AuthMonitor.cc | 2 +- src/mon/AuthMonitor.h | 2 +- src/mon/ConfigKeyService.cc | 2 +- src/mon/ConfigKeyService.h | 2 +- src/mon/HealthMonitor.cc | 2 +- src/mon/HealthMonitor.h | 2 +- src/mon/LogMonitor.cc | 2 +- src/mon/LogMonitor.h | 2 +- src/mon/MDSMonitor.cc | 2 +- src/mon/MDSMonitor.h | 2 +- src/mon/MgrStatMonitor.cc | 2 +- src/mon/MgrStatMonitor.h | 2 +- src/mon/OSDMonitor.cc | 4 ++-- src/mon/OSDMonitor.h | 4 ++-- src/mon/PaxosService.h | 18 +++++++++--------- 15 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index c9c836dc5151..ada1ddb4a913 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -271,7 +271,7 @@ void AuthMonitor::encode_full(MonitorDBStore::TransactionRef t) put_version_latest_full(t, version); } -version_t AuthMonitor::get_trim_to() +version_t AuthMonitor::get_trim_to() const { unsigned max = g_conf->paxos_max_join_drift * 2; version_t version = get_last_committed(); diff --git a/src/mon/AuthMonitor.h b/src/mon/AuthMonitor.h index 18b847d6456f..8f3ca30245b0 100644 --- a/src/mon/AuthMonitor.h +++ b/src/mon/AuthMonitor.h @@ -153,7 +153,7 @@ private: // propose pending update to peers void encode_pending(MonitorDBStore::TransactionRef t) override; void encode_full(MonitorDBStore::TransactionRef t) override; - version_t get_trim_to() override; + version_t get_trim_to() const override; bool preprocess_query(MonOpRequestRef op) override; // true if processed. bool prepare_update(MonOpRequestRef op) override; diff --git a/src/mon/ConfigKeyService.cc b/src/mon/ConfigKeyService.cc index 29ae9d959427..cd0587d2e2fe 100644 --- a/src/mon/ConfigKeyService.cc +++ b/src/mon/ConfigKeyService.cc @@ -40,7 +40,7 @@ int ConfigKeyService::store_get(const string &key, bufferlist &bl) return mon->store->get(STORE_PREFIX, key, bl); } -void ConfigKeyService::get_store_prefixes(set& s) +void ConfigKeyService::get_store_prefixes(set& s) const { s.insert(STORE_PREFIX); } diff --git a/src/mon/ConfigKeyService.h b/src/mon/ConfigKeyService.h index a20969939e11..690e512500d6 100644 --- a/src/mon/ConfigKeyService.h +++ b/src/mon/ConfigKeyService.h @@ -79,7 +79,7 @@ public: string get_name() const override { return "config_key"; } - virtual void get_store_prefixes(set& s); + void get_store_prefixes(set& s) const; /** * @} // ConfigKeyService_Inherited_h */ diff --git a/src/mon/HealthMonitor.cc b/src/mon/HealthMonitor.cc index 53c9999e753d..e5c331714e95 100644 --- a/src/mon/HealthMonitor.cc +++ b/src/mon/HealthMonitor.cc @@ -140,7 +140,7 @@ void HealthMonitor::encode_pending(MonitorDBStore::TransactionRef t) encode_health(pending_health, t); } -version_t HealthMonitor::get_trim_to() +version_t HealthMonitor::get_trim_to() const { // we don't actually need *any* old states, but keep a few. if (version > 5) { diff --git a/src/mon/HealthMonitor.h b/src/mon/HealthMonitor.h index 073a4e68c591..50a1699de658 100644 --- a/src/mon/HealthMonitor.h +++ b/src/mon/HealthMonitor.h @@ -46,7 +46,7 @@ public: void update_from_paxos(bool *need_bootstrap) override; void create_pending() override; void encode_pending(MonitorDBStore::TransactionRef t) override; - version_t get_trim_to() override; + version_t get_trim_to() const override; void encode_full(MonitorDBStore::TransactionRef t) override { } diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index 905249024665..60f71e108bd2 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -234,7 +234,7 @@ void LogMonitor::encode_full(MonitorDBStore::TransactionRef t) put_version_latest_full(t, summary.version); } -version_t LogMonitor::get_trim_to() +version_t LogMonitor::get_trim_to() const { if (!mon->is_leader()) return 0; diff --git a/src/mon/LogMonitor.h b/src/mon/LogMonitor.h index 0bb5e366cb90..d2f082596c5e 100644 --- a/src/mon/LogMonitor.h +++ b/src/mon/LogMonitor.h @@ -136,7 +136,7 @@ private: // propose pending update to peers void encode_pending(MonitorDBStore::TransactionRef t) override; void encode_full(MonitorDBStore::TransactionRef t) override; - version_t get_trim_to() override; + version_t get_trim_to() const override; bool preprocess_query(MonOpRequestRef op) override; // true if processed. bool prepare_update(MonOpRequestRef op) override; diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index c3f8b94ba5bc..b358d9add40a 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -241,7 +241,7 @@ void MDSMonitor::encode_pending(MonitorDBStore::TransactionRef t) encode_health(new_checks, t); } -version_t MDSMonitor::get_trim_to() +version_t MDSMonitor::get_trim_to() const { version_t floor = 0; if (g_conf->mon_mds_force_trim_to > 0 && diff --git a/src/mon/MDSMonitor.h b/src/mon/MDSMonitor.h index 0bf51adfe60d..bd1045ade2e1 100644 --- a/src/mon/MDSMonitor.h +++ b/src/mon/MDSMonitor.h @@ -48,7 +48,7 @@ class MDSMonitor : public PaxosService { void encode_pending(MonitorDBStore::TransactionRef t) override; // we don't require full versions; don't encode any. void encode_full(MonitorDBStore::TransactionRef t) override { } - version_t get_trim_to() override; + version_t get_trim_to() const override; bool preprocess_query(MonOpRequestRef op) override; // true if processed. bool prepare_update(MonOpRequestRef op) override; diff --git a/src/mon/MgrStatMonitor.cc b/src/mon/MgrStatMonitor.cc index 2e26015c7cd0..022a583cdc5f 100644 --- a/src/mon/MgrStatMonitor.cc +++ b/src/mon/MgrStatMonitor.cc @@ -127,7 +127,7 @@ void MgrStatMonitor::encode_pending(MonitorDBStore::TransactionRef t) encode_health(pending_health_checks, t); } -version_t MgrStatMonitor::get_trim_to() +version_t MgrStatMonitor::get_trim_to() const { // we don't actually need *any* old states, but keep a few. if (version > 5) { diff --git a/src/mon/MgrStatMonitor.h b/src/mon/MgrStatMonitor.h index 4f076105fb0c..3b1d54b5d016 100644 --- a/src/mon/MgrStatMonitor.h +++ b/src/mon/MgrStatMonitor.h @@ -30,7 +30,7 @@ public: void update_from_paxos(bool *need_bootstrap) override; void create_pending() override; void encode_pending(MonitorDBStore::TransactionRef t) override; - version_t get_trim_to() override; + version_t get_trim_to() const override; bool definitely_converted_snapsets() const { return digest.definitely_converted_snapsets(); diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index bf0143d2914d..e0dd2946a4b6 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -264,7 +264,7 @@ void OSDMonitor::create_initial() dout(20) << " full crc " << pending_inc.full_crc << dendl; } -void OSDMonitor::get_store_prefixes(std::set& s) +void OSDMonitor::get_store_prefixes(std::set& s) const { s.insert(service_name); s.insert(OSD_PG_CREATING_PREFIX); @@ -1311,7 +1311,7 @@ void OSDMonitor::share_map_with_random_osd() // elsewhere) as they may still need to request older values. } -version_t OSDMonitor::get_trim_to() +version_t OSDMonitor::get_trim_to() const { if (mon->get_quorum().empty()) { dout(10) << __func__ << ": quorum not formed" << dendl; diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index e4b1eb7f953f..583665d10b9c 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -165,7 +165,7 @@ public: // svc public: void create_initial() override; - void get_store_prefixes(std::set& s) override; + void get_store_prefixes(std::set& s) const override; private: void update_from_paxos(bool *need_bootstrap) override; @@ -238,7 +238,7 @@ private: bool prepare_update(MonOpRequestRef op) override; bool should_propose(double &delay) override; - version_t get_trim_to() override; + version_t get_trim_to() const override; bool can_mark_down(int o); bool can_mark_up(int o); diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h index fb383423991c..bf989d1385fc 100644 --- a/src/mon/PaxosService.h +++ b/src/mon/PaxosService.h @@ -90,7 +90,7 @@ protected: version_t format_version; public: - const health_check_map_t& get_health_checks() { + const health_check_map_t& get_health_checks() const { return health_checks; } @@ -152,12 +152,12 @@ public: * * @returns The service's name. */ - string get_service_name() { return service_name; } + const string& get_service_name() const { return service_name; } /** * Get the store prefixes we utilize */ - virtual void get_store_prefixes(set& s) { + virtual void get_store_prefixes(set& s) const { s.insert(service_name); } @@ -481,7 +481,7 @@ public: * * @returns true if we are proposing; false otherwise. */ - bool is_proposing() { + bool is_proposing() const { return proposing; } @@ -492,7 +492,7 @@ public: * * @returns true if in state ACTIVE; false otherwise. */ - bool is_active() { + bool is_active() const { return !is_proposing() && (paxos->is_active() || paxos->is_updating() || paxos->is_writing()); @@ -510,7 +510,7 @@ public: * @param ver The version we want to check if is readable * @returns true if it is readable; false otherwise */ - bool is_readable(version_t ver = 0) { + bool is_readable(version_t ver = 0) const { if (ver > get_last_committed() || !paxos->is_readable(0) || get_last_committed() == 0) @@ -529,7 +529,7 @@ public: * * @returns true if writeable; false otherwise */ - bool is_writeable() { + bool is_writeable() const { return is_write_ready(); } @@ -539,7 +539,7 @@ public: * * @returns true if we are ready to be written to; false otherwise. */ - bool is_write_ready() { + bool is_write_ready() const { return is_active() && have_pending; } @@ -674,7 +674,7 @@ public: * @returns the version we should trim to; if we return zero, it should be * assumed that there's no version to trim to. */ - virtual version_t get_trim_to() { + virtual version_t get_trim_to() const { return 0; } -- 2.47.3