From bd59d1ca5321a8828266246d94da2c03f8412f9d Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 12 Apr 2018 13:40:41 -0500 Subject: [PATCH] mon/LogMonitor: simplify summary logic Instead of sending the last 1 message, send from the last committed segment. This may be >1 entry, which is a bit odd, but otherwise the behavior is similar. Note that since the channel filtering is happening on the client this may mean a higher chance of getting something visible at all. Signed-off-by: Sage Weil --- src/mon/LogMonitor.cc | 38 +------------------------------------- src/mon/LogMonitor.h | 1 - 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index 2d785d4d884..bfcd2a42afa 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -563,12 +563,7 @@ void LogMonitor::check_sub(Subscription *s) if (s->next == 0) { /* First timer, heh? */ - bool ret = _create_sub_summary(mlog, sub_level); - if (!ret) { - dout(1) << __func__ << " ret = " << ret << dendl; - mlog->put(); - return; - } + _create_sub_incremental(mlog, sub_level, get_last_committed()); } else { /* let us send you an incremental log... */ _create_sub_incremental(mlog, sub_level, s->next); @@ -589,37 +584,6 @@ void LogMonitor::check_sub(Subscription *s) s->next = summary_version+1; } -/** - * Create a log message containing only the last message in the summary. - * - * @param mlog Log message we'll send to the client. - * @param level Maximum log level the client is interested in. - * @return 'true' if we consider we successfully populated @mlog; - * 'false' otherwise. - */ -bool LogMonitor::_create_sub_summary(MLog *mlog, int level) -{ - dout(10) << __func__ << dendl; - - assert(mlog != NULL); - - if (!summary.tail.size()) - return false; - - list::reverse_iterator it = summary.tail.rbegin(); - for (; it != summary.tail.rend(); ++it) { - LogEntry e = *it; - if (e.prio < level) - continue; - - mlog->entries.push_back(e); - mlog->version = summary.version; - break; - } - - return true; -} - /** * Create an incremental log message from version \p sv to \p summary.version * diff --git a/src/mon/LogMonitor.h b/src/mon/LogMonitor.h index 7c8043689ec..023251609e6 100644 --- a/src/mon/LogMonitor.h +++ b/src/mon/LogMonitor.h @@ -155,7 +155,6 @@ private: bool preprocess_command(MonOpRequestRef op); bool prepare_command(MonOpRequestRef op); - bool _create_sub_summary(MLog *mlog, int level); void _create_sub_incremental(MLog *mlog, int level, version_t sv); public: -- 2.39.5