]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
logclient: limit messages per MLog message
authorSage Weil <sage@inktank.com>
Tue, 5 Jun 2012 21:21:33 +0000 (14:21 -0700)
committerSage Weil <sage@inktank.com>
Tue, 5 Jun 2012 23:38:59 +0000 (16:38 -0700)
This will avoid sending huge chunks of entries to the monitor and making
its life difficult.

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Yehuda Sadeh <yehuda@inktank.com>
src/common/LogClient.cc
src/common/config_opts.h

index 29a83637cb1e1adfd88dbfcaa7367d4b0169bc83..7a2513a47fd3c3649f5e11bede5e49365b003de9 100644 (file)
@@ -154,18 +154,26 @@ Message *LogClient::_get_mon_log_message()
   if (last_log_sent == last_log)
     return NULL;
 
-  unsigned i = last_log - last_log_sent;
+  // limit entries per message
+  unsigned num = last_log - last_log_sent;
+  unsigned i;
+  if (cct->_conf->mon_client_max_log_entries_per_message > 0)
+    i = MIN(num, cct->_conf->mon_client_max_log_entries_per_message);
+  else
+    i = num;
+
   ldout(cct,10) << " log_queue is " << log_queue.size() << " last_log " << last_log << " sent " << last_log_sent
-          << " i " << i << dendl;
+               << " num " << num << " sending " << i << dendl;
   std::deque<LogEntry> o(i);
-  std::deque<LogEntry>::reverse_iterator p = log_queue.rbegin();
-  while (i > 0) {
-    i--;
-    o[i] = *p++;
-    ldout(cct,10) << " will send " << o[i] << dendl;
+  std::deque<LogEntry>::iterator p = log_queue.begin();
+  std::deque<LogEntry>::iterator q = o.begin();
+  while (q != o.end()) {
+    *q = *p;
+    last_log_sent = p->seq;
+    ldout(cct,10) << " will send " << *p << dendl;
+    p++;
+    q++;
   }
-
-  last_log_sent = last_log;
   
   MLog *log = new MLog(monmap->get_fsid());
   log->entries.swap(o);
index cf40d01005423b8c7618552e224beff2aa21ceb6..e26ec3b9d017e7ffce9ba9acce6af036db1ecffb 100644 (file)
@@ -136,6 +136,7 @@ OPTION(auth_mon_ticket_ttl, OPT_DOUBLE, 60*60*12)
 OPTION(auth_service_ticket_ttl, OPT_DOUBLE, 60*60)
 OPTION(mon_client_hunt_interval, OPT_DOUBLE, 3.0)   // try new mon every N seconds until we connect
 OPTION(mon_client_ping_interval, OPT_DOUBLE, 10.0)  // ping every N seconds
+OPTION(mon_client_max_log_entries_per_message, OPT_INT, 1000)
 OPTION(client_cache_size, OPT_INT, 16384)
 OPTION(client_cache_mid, OPT_FLOAT, .75)
 OPTION(client_cache_stat_ttl, OPT_INT, 0) // seconds until cached stat results become invalid