Repository: kudu
Updated Branches:
  refs/heads/master 0259586af -> 2b0bb5116


tablet_bootstrap: periodically update status during replay

This makes the bootstrap code update its status once every 5 seconds
while replaying each segment. This is useful to watch during server
startup in particular.

Change-Id: If48e5bf8745be163baa8c512229708973747eb3a
Reviewed-on: http://gerrit.cloudera.org:8080/5472
Tested-by: Kudu Jenkins
Reviewed-by: Mike Percy <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/a684b7aa
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/a684b7aa
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/a684b7aa

Branch: refs/heads/master
Commit: a684b7aa604eff8eaf4450198bae3e68cfbc0ff6
Parents: 0259586
Author: Todd Lipcon <[email protected]>
Authored: Mon Dec 12 09:57:49 2016 +0700
Committer: Mike Percy <[email protected]>
Committed: Wed Dec 14 14:18:47 2016 +0000

----------------------------------------------------------------------
 src/kudu/consensus/log_util.h       |  5 +++++
 src/kudu/tablet/tablet_bootstrap.cc | 18 +++++++++++++++---
 2 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/a684b7aa/src/kudu/consensus/log_util.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_util.h b/src/kudu/consensus/log_util.h
index 59b4826..e2b5a93 100644
--- a/src/kudu/consensus/log_util.h
+++ b/src/kudu/consensus/log_util.h
@@ -98,6 +98,11 @@ class LogEntryReader {
     return offset_;
   }
 
+  // Return the offset at which this reader will stop reading.
+  int64_t read_up_to_offset() const {
+    return read_up_to_;
+  }
+
  private:
   friend class ReadableLogSegment;
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/a684b7aa/src/kudu/tablet/tablet_bootstrap.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_bootstrap.cc 
b/src/kudu/tablet/tablet_bootstrap.cc
index 80e163d..af7e494 100644
--- a/src/kudu/tablet/tablet_bootstrap.cc
+++ b/src/kudu/tablet/tablet_bootstrap.cc
@@ -37,6 +37,7 @@
 #include "kudu/fs/fs_manager.h"
 #include "kudu/gutil/ref_counted.h"
 #include "kudu/gutil/stl_util.h"
+#include "kudu/gutil/strings/human_readable.h"
 #include "kudu/gutil/strings/strcat.h"
 #include "kudu/gutil/strings/substitute.h"
 #include "kudu/gutil/strings/util.h"
@@ -1041,7 +1042,10 @@ Status 
TabletBootstrap::PlaySegments(ConsensusBootstrapInfo* consensus_info) {
   // writing.
   RETURN_NOT_OK_PREPEND(OpenNewLog(), "Failed to open new log");
 
+  auto last_status_update = MonoTime::Now();
+  const auto kStatusUpdateInterval = MonoDelta::FromSeconds(5);
   int segment_count = 0;
+
   for (const scoped_refptr<ReadableLogSegment>& segment : segments) {
     log::LogEntryReader reader(segment.get());
 
@@ -1075,11 +1079,19 @@ Status 
TabletBootstrap::PlaySegments(ConsensusBootstrapInfo* consensus_info) {
 
       // If HandleEntry returns OK, then it has taken ownership of the entry.
       entry.release();
+
+      auto now = MonoTime::Now();
+      if (now - last_status_update > kStatusUpdateInterval) {
+        StatusMessage(Substitute("Bootstrap replaying log segment $0/$1 "
+                                 "($2/$3 this segment, stats: $4)",
+                                 segment_count + 1, 
log_reader_->num_segments(),
+                                 
HumanReadableNumBytes::ToString(reader.offset()),
+                                 
HumanReadableNumBytes::ToString(reader.read_up_to_offset()),
+                                 stats_.ToString()));
+        last_status_update = now;
+      }
     }
 
-    // TODO: could be more granular here and log during the segments as well,
-    // plus give info about number of MB processed, but this is better than
-    // nothing.
     StatusMessage(Substitute("Bootstrap replayed $0/$1 log segments. "
                              "Stats: $2. Pending: $3 replicates",
                              segment_count + 1, log_reader_->num_segments(),

Reply via email to