From 1effdfe19bf9fd6d546620b96eaf452e889b15dc Mon Sep 17 00:00:00 2001 From: liuchang0812 Date: Wed, 15 Feb 2017 21:18:22 +0800 Subject: [PATCH] mon: add override in mon subsystem Fixes: http://tracker.ceph.com/issues/18922 Signed-off-by: liuchang0812 --- src/mon/Elector.cc | 2 +- src/mon/LogMonitor.cc | 2 +- src/mon/MDSMonitor.cc | 14 ++++----- src/mon/MgrMonitor.cc | 2 +- src/mon/MonClient.cc | 4 +-- src/mon/Monitor.cc | 8 ++--- src/mon/MonmapMonitor.cc | 2 +- src/mon/OSDMonitor.cc | 12 ++++---- src/mon/PGMonitor.cc | 4 +-- src/mon/Paxos.cc | 14 ++++----- src/mon/PaxosService.cc | 6 ++-- src/test/mon/test-mon-msg.cc | 16 +++++----- src/test/mon/test_mon_workloadgen.cc | 46 ++++++++++++++-------------- 13 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/mon/Elector.cc b/src/mon/Elector.cc index eb9885f98255b..c3c8fd8845f43 100644 --- a/src/mon/Elector.cc +++ b/src/mon/Elector.cc @@ -144,7 +144,7 @@ void Elector::reset_timer(double plus) Elector *elector; public: explicit C_ElectionExpire(Elector *e) : elector(e) { } - void finish(int r) { + void finish(int r) override { elector->expire(); } }; diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index b8fd9c966414f..c8e746377ab04 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -315,7 +315,7 @@ struct LogMonitor::C_Log : public C_MonOp { LogMonitor *logmon; C_Log(LogMonitor *p, MonOpRequestRef o) : C_MonOp(o), logmon(p) {} - void _finish(int r) { + void _finish(int r) override { if (r == -ECANCELED) { return; } diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 1fcc585468782..4dbce27162c7d 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -1515,7 +1515,7 @@ class FlagSetHandler : public FileSystemCommandHandler FSMap &fsmap, MonOpRequestRef op, map &cmdmap, - std::stringstream &ss) + std::stringstream &ss) override { string flag_name; cmd_getval(g_ceph_context, cmdmap, "flag_name", flag_name); @@ -1799,12 +1799,12 @@ public: : FileSystemCommandHandler("fs set") {} - virtual int handle( + int handle( Monitor *mon, FSMap &fsmap, MonOpRequestRef op, map &cmdmap, - std::stringstream &ss) + std::stringstream &ss) override { std::string fs_name; if (!cmd_getval(g_ceph_context, cmdmap, "fs_name", fs_name) || fs_name.empty()) { @@ -2046,7 +2046,7 @@ class AddDataPoolHandler : public FileSystemCommandHandler FSMap &fsmap, MonOpRequestRef op, map &cmdmap, - std::stringstream &ss) + std::stringstream &ss) override { string poolname; cmd_getval(g_ceph_context, cmdmap, "pool", poolname); @@ -2105,7 +2105,7 @@ class RemoveDataPoolHandler : public FileSystemCommandHandler FSMap &fsmap, MonOpRequestRef op, map &cmdmap, - std::stringstream &ss) + std::stringstream &ss) override { string poolname; cmd_getval(g_ceph_context, cmdmap, "pool", poolname); @@ -2185,14 +2185,14 @@ class LegacyHandler : public T legacy_prefix = new_prefix; } - virtual std::string const &get_prefix() {return legacy_prefix;} + std::string const &get_prefix() override {return legacy_prefix;} int handle( Monitor *mon, FSMap &fsmap, MonOpRequestRef op, map &cmdmap, - std::stringstream &ss) + std::stringstream &ss) override { auto fs = fsmap.get_legacy_filesystem(); if (fs == nullptr) { diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc index 5b681e861a80b..d9cee80b463fc 100644 --- a/src/mon/MgrMonitor.cc +++ b/src/mon/MgrMonitor.cc @@ -106,7 +106,7 @@ class C_Updated : public Context { public: C_Updated(MgrMonitor *a, MonOpRequestRef c) : mm(a), op(c) {} - void finish(int r) { + void finish(int r) override { if (r >= 0) { // Success } else if (r == -ECANCELED) { diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index 20abe28cd36df..76d3e39a54e94 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -748,7 +748,7 @@ void MonClient::schedule_tick() struct C_Tick : public Context { MonClient *monc; explicit C_Tick(MonClient *m) : monc(m) {} - void finish(int r) { + void finish(int r) override { monc->tick(); } }; @@ -1025,7 +1025,7 @@ int MonClient::start_mon_command(const vector& cmd, MonClient *monc; public: C_CancelMonCommand(uint64_t tid, MonClient *monc) : tid(tid), monc(monc) {} - void finish(int r) { + void finish(int r) override { monc->_cancel_mon_command(tid, -ETIMEDOUT); } }; diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index f441a69cf4d04..f23f91a7b8b67 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -263,7 +263,7 @@ class AdminHook : public AdminSocketHook { public: explicit AdminHook(Monitor *m) : mon(m) {} bool call(std::string command, cmdmap_t& cmdmap, std::string format, - bufferlist& out) { + bufferlist& out) override { stringstream ss; mon->do_admin_command(command, cmdmap, format, ss); out.append(ss); @@ -5009,7 +5009,7 @@ void Monitor::scrub_event_start() struct C_Scrub : public Context { Monitor *mon; explicit C_Scrub(Monitor *m) : mon(m) { } - void finish(int r) { + void finish(int r) override { mon->scrub_start(); } }; @@ -5043,7 +5043,7 @@ void Monitor::scrub_reset_timeout() struct C_ScrubTimeout : public Context { Monitor *mon; explicit C_ScrubTimeout(Monitor *m) : mon(m) { } - void finish(int r) { + void finish(int r) override { mon->scrub_timeout(); } }; @@ -5058,7 +5058,7 @@ class C_Mon_Tick : public Context { Monitor *mon; public: explicit C_Mon_Tick(Monitor *m) : mon(m) {} - void finish(int r) { + void finish(int r) override { mon->tick(); } }; diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index fb86e82054953..8d9ef32f37a55 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -106,7 +106,7 @@ class C_ApplyFeatures : public Context { public: C_ApplyFeatures(MonmapMonitor *s, const mon_feature_t& f) : svc(s), features(f) { } - void finish(int r) { + void finish(int r) override { if (r >= 0) { svc->apply_mon_features(features); } else if (r == -EAGAIN || r == -ECANCELED) { diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 881a4611ec5a5..ee26e24c32dab 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -633,7 +633,7 @@ protected: } } - virtual void dump_item(const CrushTreeDumper::Item &qi, F *f) { + void dump_item(const CrushTreeDumper::Item &qi, F *f) override { if (!tree && qi.is_bucket()) return; @@ -784,7 +784,7 @@ protected: friend std::ostream &operator<<(ostream& out, const lowprecision_t& v); using OSDUtilizationDumper::dump_item; - virtual void dump_item(const CrushTreeDumper::Item &qi, + void dump_item(const CrushTreeDumper::Item &qi, float &reweight, int64_t kb, int64_t kb_used, @@ -792,7 +792,7 @@ protected: double& util, double& var, const size_t num_pgs, - TextTable *tbl) { + TextTable *tbl) override { *tbl << qi.id << weightf_t(qi.weight) << weightf_t(reweight) @@ -868,7 +868,7 @@ public: protected: using OSDUtilizationDumper::dump_item; - virtual void dump_item(const CrushTreeDumper::Item &qi, + void dump_item(const CrushTreeDumper::Item &qi, float &reweight, int64_t kb, int64_t kb_used, @@ -876,7 +876,7 @@ protected: double& util, double& var, const size_t num_pgs, - Formatter *f) { + Formatter *f) override { f->open_object_section("item"); CrushTreeDumper::dump_item_fields(crush, qi, f); f->dump_float("reweight", reweight); @@ -1520,7 +1520,7 @@ public: MonOpRequestRef op) : C_MonOp(op), osdmon(osdmon) {} - void _finish(int) { + void _finish(int) override { MOSDMarkMeDown *m = static_cast(op->get_req()); osdmon->mon->send_reply( op, diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index b7c9870058c1a..286e5c70fe9e4 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -708,7 +708,7 @@ struct PGMonitor::C_Stats : public C_MonOp { MonOpRequestRef op, MonOpRequestRef op_ack) : C_MonOp(op), pgmon(p), stats_op_ack(op_ack) {} - void _finish(int r) { + void _finish(int r) override { if (r >= 0) { pgmon->_updated_stats(op, stats_op_ack); } else if (r == -ECANCELED) { @@ -830,7 +830,7 @@ struct RetryCheckOSDMap : public Context { epoch_t epoch; RetryCheckOSDMap(PGMonitor *p, epoch_t e) : pgmon(p), epoch(e) { } - void finish(int r) { + void finish(int r) override { if (r == -ECANCELED) return; diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index 06f1521427073..2e905ac8fb795 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -41,7 +41,7 @@ class Paxos::C_CollectTimeout : public Context { Paxos *paxos; public: explicit C_CollectTimeout(Paxos *p) : paxos(p) {} - void finish(int r) { + void finish(int r) override { if (r == -ECANCELED) return; paxos->collect_timeout(); @@ -52,7 +52,7 @@ class Paxos::C_AcceptTimeout : public Context { Paxos *paxos; public: explicit C_AcceptTimeout(Paxos *p) : paxos(p) {} - void finish(int r) { + void finish(int r) override { if (r == -ECANCELED) return; paxos->accept_timeout(); @@ -63,7 +63,7 @@ class Paxos::C_LeaseAckTimeout : public Context { Paxos *paxos; public: explicit C_LeaseAckTimeout(Paxos *p) : paxos(p) {} - void finish(int r) { + void finish(int r) override { if (r == -ECANCELED) return; paxos->lease_ack_timeout(); @@ -74,7 +74,7 @@ class Paxos::C_LeaseTimeout : public Context { Paxos *paxos; public: explicit C_LeaseTimeout(Paxos *p) : paxos(p) {} - void finish(int r) { + void finish(int r) override { if (r == -ECANCELED) return; paxos->lease_timeout(); @@ -85,7 +85,7 @@ class Paxos::C_LeaseRenew : public Context { Paxos *paxos; public: explicit C_LeaseRenew(Paxos *p) : paxos(p) {} - void finish(int r) { + void finish(int r) override { if (r == -ECANCELED) return; paxos->lease_renew_timeout(); @@ -96,7 +96,7 @@ class Paxos::C_Trimmed : public Context { Paxos *paxos; public: explicit C_Trimmed(Paxos *p) : paxos(p) { } - void finish(int r) { + void finish(int r) override { paxos->trimming = false; } }; @@ -860,7 +860,7 @@ void Paxos::accept_timeout() struct C_Committed : public Context { Paxos *paxos; explicit C_Committed(Paxos *p) : paxos(p) {} - void finish(int r) { + void finish(int r) override { assert(r >= 0); Mutex::Locker l(paxos->mon->lock); paxos->commit_finish(); diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index 09143e7c1250e..203be1c817c53 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -104,7 +104,7 @@ bool PaxosService::dispatch(MonOpRequestRef op) PaxosService *ps; public: explicit C_Propose(PaxosService *p) : ps(p) { } - void finish(int r) { + void finish(int r) override { ps->proposal_timer = 0; if (r >= 0) ps->propose_pending(); @@ -226,7 +226,7 @@ void PaxosService::propose_pending() PaxosService *ps; public: explicit C_Committed(PaxosService *p) : ps(p) { } - void finish(int r) { + void finish(int r) override { ps->proposing = false; if (r >= 0) ps->_active(); @@ -303,7 +303,7 @@ void PaxosService::_active() PaxosService *svc; public: explicit C_Active(PaxosService *s) : svc(s) {} - void finish(int r) { + void finish(int r) override { if (r >= 0) svc->_active(); } diff --git a/src/test/mon/test-mon-msg.cc b/src/test/mon/test-mon-msg.cc index ddf333d87a778..b4b7c0e8dc97e 100644 --- a/src/test/mon/test-mon-msg.cc +++ b/src/test/mon/test-mon-msg.cc @@ -183,13 +183,13 @@ fail: return true; } - bool ms_dispatch(Message *m) { + bool ms_dispatch(Message *m) override { return handle_message(m); } - void ms_handle_connect(Connection *con) { } - void ms_handle_remote_reset(Connection *con) { } - bool ms_handle_reset(Connection *con) { return false; } - bool ms_handle_refused(Connection *con) { return false; } + void ms_handle_connect(Connection *con) override { } + void ms_handle_remote_reset(Connection *con) override { } + bool ms_handle_reset(Connection *con) override { return false; } + bool ms_handle_refused(Connection *con) override { return false; } bool is_wanted(Message *m) { dout(20) << __func__ << " " << *m << " type " << m->get_type() << dendl; @@ -228,7 +228,7 @@ protected: lock("lock") { } public: - virtual void SetUp() { + void SetUp() override { reply_type = -1; if (reply_msg) { reply_msg->put(); @@ -237,7 +237,7 @@ public: ASSERT_EQ(init(), 0); } - virtual void TearDown() { + void TearDown() override { shutdown(); if (reply_msg) { reply_msg->put(); @@ -245,7 +245,7 @@ public: } } - void handle_wanted(Message *m) { + void handle_wanted(Message *m) override { lock.Lock(); // caller will put() after they call us, so hold on to a ref m->get(); diff --git a/src/test/mon/test_mon_workloadgen.cc b/src/test/mon/test_mon_workloadgen.cc index 1efc879d02143..309dcf636eff1 100644 --- a/src/test/mon/test_mon_workloadgen.cc +++ b/src/test/mon/test_mon_workloadgen.cc @@ -92,7 +92,7 @@ class TestStub : public Dispatcher struct C_Tick : public Context { TestStub *s; explicit C_Tick(TestStub *stub) : s(stub) {} - void finish(int r) { + void finish(int r) override { generic_dout(20) << "C_Tick::" << __func__ << dendl; if (r == -ECANCELED) { generic_dout(20) << "C_Tick::" << __func__ @@ -103,9 +103,9 @@ class TestStub : public Dispatcher } }; - virtual bool ms_dispatch(Message *m) = 0; - virtual void ms_handle_connect(Connection *con) = 0; - virtual void ms_handle_remote_reset(Connection *con) = 0; + bool ms_dispatch(Message *m) override = 0; + void ms_handle_connect(Connection *con) override = 0; + void ms_handle_remote_reset(Connection *con) override = 0; virtual int _shutdown() = 0; // courtesy method to be implemented by the stubs at their // own discretion @@ -188,7 +188,7 @@ class ClientStub : public TestStub rngen_t gen; protected: - bool ms_dispatch(Message *m) { + bool ms_dispatch(Message *m) override { Mutex::Locker l(lock); dout(1) << "client::" << __func__ << " " << *m << dendl; switch (m->get_type()) { @@ -200,34 +200,34 @@ class ClientStub : public TestStub return true; } - void ms_handle_connect(Connection *con) { + void ms_handle_connect(Connection *con) override { dout(1) << "client::" << __func__ << " " << con << dendl; Mutex::Locker l(lock); objecter->ms_handle_connect(con); } - void ms_handle_remote_reset(Connection *con) { + void ms_handle_remote_reset(Connection *con) override { dout(1) << "client::" << __func__ << " " << con << dendl; Mutex::Locker l(lock); objecter->ms_handle_remote_reset(con); } - bool ms_handle_reset(Connection *con) { + bool ms_handle_reset(Connection *con) override { dout(1) << "client::" << __func__ << dendl; Mutex::Locker l(lock); objecter->ms_handle_reset(con); return false; } - bool ms_handle_refused(Connection *con) { + bool ms_handle_refused(Connection *con) override { return false; } - const string get_name() { + const string get_name() override { return "client"; } - virtual int _shutdown() { + int _shutdown() override { if (objecter) { objecter->shutdown(); } @@ -240,7 +240,7 @@ class ClientStub : public TestStub gen((int) time(NULL)) { } - int init() { + int init() override { int err; err = monc.build_initial_monmap(); if (err < 0) { @@ -334,7 +334,7 @@ class OSDStub : public TestStub struct C_CreatePGs : public Context { OSDStub *s; explicit C_CreatePGs(OSDStub *stub) : s(stub) {} - void finish(int r) { + void finish(int r) override { if (r == -ECANCELED) { generic_dout(20) << "C_CreatePGs::" << __func__ << " shutdown" << dendl; @@ -395,7 +395,7 @@ class OSDStub : public TestStub monc.set_messenger(messenger.get()); } - int init() { + int init() override { dout(10) << __func__ << dendl; Mutex::Locker l(lock); @@ -443,7 +443,7 @@ class OSDStub : public TestStub return 0; } - int _shutdown() { + int _shutdown() override { return 0; } @@ -719,7 +719,7 @@ class OSDStub : public TestStub monc.send_mon_message(m); } - void _tick() { + void _tick() override { if (!osdmap.exists(whoami)) { std::cout << __func__ << " not in the cluster; boot!" << std::endl; boot(); @@ -874,7 +874,7 @@ class OSDStub : public TestStub m->put(); } - bool ms_dispatch(Message *m) { + bool ms_dispatch(Message *m) override { dout(1) << __func__ << " " << *m << dendl; switch (m->get_type()) { @@ -891,16 +891,16 @@ class OSDStub : public TestStub return true; } - void ms_handle_connect(Connection *con) { + void ms_handle_connect(Connection *con) override { dout(1) << __func__ << " " << con << dendl; if (con->get_peer_type() == CEPH_ENTITY_TYPE_MON) { dout(10) << __func__ << " on mon" << dendl; } } - void ms_handle_remote_reset(Connection *con) {} + void ms_handle_remote_reset(Connection *con) override {} - bool ms_handle_reset(Connection *con) { + bool ms_handle_reset(Connection *con) override { dout(1) << __func__ << dendl; Session *session = (Session *)con->get_priv(); if (!session) @@ -909,11 +909,11 @@ class OSDStub : public TestStub return true; } - bool ms_handle_refused(Connection *con) { + bool ms_handle_refused(Connection *con) override { return false; } - const string get_name() { + const string get_name() override { stringstream ss; ss << "osd." << whoami; return ss.str(); @@ -934,7 +934,7 @@ SafeTimer *shutdown_timer = NULL; struct C_Shutdown : public Context { - void finish(int r) { + void finish(int r) override { generic_dout(10) << "main::shutdown time has ran out" << dendl; shutdown_cond.Signal(); } -- 2.39.5