You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by to...@apache.org on 2016/10/11 15:59:59 UTC

[1/3] kudu git commit: [c++client/samples] added README for the sample

Repository: kudu
Updated Branches:
  refs/heads/master 64ec12149 -> 1ca7ccfb4


[c++client/samples] added README for the sample

Added README in AsciiDoctor format describing how to build the sample.

Change-Id: I5d75340b2690663b56082de590cf19ea315da4fe
Reviewed-on: http://gerrit.cloudera.org:8080/4517
Tested-by: Kudu Jenkins
Reviewed-by: Todd Lipcon <to...@apache.org>


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

Branch: refs/heads/master
Commit: 5962de1580966a8a0f45700134f1e02a4b92dba6
Parents: 64ec121
Author: Alexey Serbin <as...@cloudera.com>
Authored: Thu Sep 22 11:54:47 2016 -0700
Committer: Alexey Serbin <as...@cloudera.com>
Committed: Tue Oct 11 00:44:27 2016 +0000

----------------------------------------------------------------------
 src/kudu/client/samples/README.adoc | 167 +++++++++++++++++++++++++++++++
 1 file changed, 167 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/5962de15/src/kudu/client/samples/README.adoc
----------------------------------------------------------------------
diff --git a/src/kudu/client/samples/README.adoc b/src/kudu/client/samples/README.adoc
new file mode 100644
index 0000000..7e82829
--- /dev/null
+++ b/src/kudu/client/samples/README.adoc
@@ -0,0 +1,167 @@
+= Kudu {cpp} client sample README
+:author: Kudu Team
+:homepage: https://kudu.apache.org/
+
+== Summary
+The Kudu {cpp} client library distribution contains {cpp} example application
+that demonstrates how to use the Kudu {cpp} client API.  The sample
+can be used as a starting point for a custom Kudu {cpp} client application.
+This note contains information on how to build the Kudu {cpp} client sample.
+
+== How to build the example if installing Kudu from packages
+This section describes how to build the example if installing Kudu
+using pre-built packages.
+
+. Install the required packages as described in the
+https://kudu.apache.org/docs/installation.html#install_packages[documentation on the Kudu Web site].
+The `kudu-client0` package (`libkuduclient0` on Debian/Ubuntu Linux
+distributions) contains the Kudu {cpp} client library, and the `kudu-client-dev`
+package (`libkuduclient-dev` on Debian/Ubuntu Linux distributions) contains
+the Kudu {cpp} client header files and {cpp} code sample (`sample.cc`)
+along with other auxiliary content.
+
+. Make sure `cmake` of version at least 2.8 is installed on the system.
+
+. Copy the sample into a custom location where you would like to work
+with the code. Working in the `/usr/share/doc/kuduClient/samples`
+directory is possible but is not recommended since it requires
+super-user access and pollutes the `sample` directory with
+intermediate files.
+For example, to copy the `/usr/share/doc/kuduClient/samples` directory
+recursively into `/tmp/kuduClient`:
+[source,shell]
+cp -r /usr/share/doc/kuduClient/samples /tmp/kuduClient
+
+. Navigate into the directory where the `sample.cc.gz` file was copied and
+unpack the sample source file.  For example:
+[source,shell]
+cd /tmp/kuduClient/samples
+gunzip sample.cc.gz
+
+. Run `cmake` to generate appropriate makefiles.  For example, if targeting
+for a debug build
+(for a release build, use `release` for `CMAKE_BUILD_TYPE` correspondingly):
+[source,shell]
+cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=debug
+
+. Run `make` to build the sample:
+[source,shell]
+make
+
+. After the sample is built, it is ready to run against your Kudu master server.
+The sample application assumes the target Kudu cluster has at least 3
+tablet servers up and running (because it creates a table with replication
+factor 3).  If it's not the case, you can modify the `sample.cc` accordingly
+and re-compile it.  Below is the sample output with log messages in the middle
+removed: the `sample` binary runs against Kudu master server running
+with the default parameters at the same machine.  Port 7051 is the default
+one and could be omitted along with the preceding colomn because the master
+server is running with the default parameters (it's left only to illustrate how
+to specify port number).
+[source,shell]
+$ ./sample 127.0.0.1:7051
+Running with Kudu client version: kudu 1.1.0-SNAPSHOT (rev 91a1ed09c4c572a22bab15360ddaf481d5632927)
+Long version info: kudu 1.1.0-SNAPSHOT
+revision 91a1ed09c4c572a22bab15360ddaf481d5632927
+build type DEBUG
+built by aserbin at 06 Oct 2016 14:15:10 PST on ve0518.halxg.cloudera.com
+Received log message from Kudu client library
+ Severity: 0
+ Filename: /home/aserbin/Projects/kudu/src/kudu/util/thread.cc
+ Line number: 546
+ Time: Thu Oct 06 14:50:47 2016
+ Message: Started thread 11197 - kernel-watchdog:kernel-watcher
+...
+Received log message from Kudu client library
+ Severity: 0
+ Filename: /home/aserbin/Projects/kudu/src/kudu/client/client-internal.cc
+ Line number: 534
+ Time: Thu Oct 06 14:50:47 2016
+ Message: Considering host 10.17.240.17 local
+Created a client connection
+Created a schema
+Created a table
+Altered a table
+Inserted some rows into a table
+Scanned some rows out of a table
+Deleted a table
+Done
+
+== How to build the example if building Kudu from source
+This section describes how to build the example if building Kudu from source.
+To install the `sample.cc` and other files, an alternate destination root
+is used.
+
+Specifying an alternate destination root allows you to install the
+Kudu {cpp} client library, the sample file and other content
+under the specified destination prefix.
+
+. Follow the https://kudu.apache.org/docs/installation.html#_build_from_source[instructions on the Kudu Web site]
+to build the project from source.
+
+. Once the project is built, change into the `<build_dir>/src/kudu/client`
+sub-directory.
+
+. Run `make install` with an alternate destination root.  For example, if
+installing into `/tmp/client_alt_root`
+[source,shell]
+make install DESTDIR=/tmp/client_alt_root
+
+. Change the current working directory into the
+`usr/local/share/doc/kuduClient/samples` subdirectory of the alternate
+destination root.  For example, if installing into `/tmp/client_alt_root`
+[source,shell]
+cd /tmp/client_alt_root/usr/local/share/doc/kuduClient/samples
+
+. Run `cmake` to generate appropriate makefiles.  For example, if installing
+into `/tmp/client_alt_root` and targeting for a debug build
+(for a release build, use `release` for `CMAKE_BUILD_TYPE` correspondingly):
+[source,shell]
+cmake -G "Unix Makefiles" -DkuduClient_DIR=/tmp/client_alt_root/usr/local/share/kuduClient/cmake -DCMAKE_BUILD_TYPE=debug
+
+. Run `make` to build the sample:
+[source,shell]
+make
+
+. After the sample is built, it is ready to run against your Kudu master server.
+The sample application assumes the target Kudu cluster has at least 3
+tablet servers up and running (because it creates a table with replication
+factor 3).  If it's not the case, you can modify the `sample.cc` accordingly
+and re-compile it.  Below is the sample output with log messages in the middle
+removed: the `sample` binary runs against Kudu master server running
+with the default parameters at the same machine.  Port 7051 is the default
+one and could be omitted along with the preceding colomn because the master
+server is running with the default parameters (it's left only to illustrate how
+to specify port number).
+[source,shell]
+$ ./sample 127.0.0.1:7051
+Running with Kudu client version: kudu 1.1.0-SNAPSHOT (rev 91a1ed09c4c572a22bab15360ddaf481d5632927)
+Long version info: kudu 1.1.0-SNAPSHOT
+revision 91a1ed09c4c572a22bab15360ddaf481d5632927
+build type DEBUG
+built by aserbin at 06 Oct 2016 14:15:10 PST on ve0518.halxg.cloudera.com
+Received log message from Kudu client library
+ Severity: 0
+ Filename: /home/aserbin/Projects/kudu/src/kudu/util/thread.cc
+ Line number: 546
+ Time: Thu Oct 06 14:50:47 2016
+ Message: Started thread 11197 - kernel-watchdog:kernel-watcher
+...
+Received log message from Kudu client library
+ Severity: 0
+ Filename: /home/aserbin/Projects/kudu/src/kudu/client/client-internal.cc
+ Line number: 534
+ Time: Thu Oct 06 14:50:47 2016
+ Message: Considering host 10.17.240.17 local
+Created a client connection
+Created a schema
+Created a table
+Altered a table
+Inserted some rows into a table
+Scanned some rows out of a table
+Deleted a table
+Done
+
+== References
+. https://kudu.apache.org/[The Kudu Project Web Site]
+. https://kudu.apache.org/cpp-client-api/[Kudu {cpp} client API documentation]


[2/3] kudu git commit: [flaky tests] Address SIGSEGV on ResultTracker while running alter_table_randomized-test

Posted by to...@apache.org.
[flaky tests] Address SIGSEGV on ResultTracker while running alter_table_randomized-test

This addresses a flakyness in the alter_table_randomized-test whereby
calling ResultTracker::FailAndRespond() on a transaction that was never
tracked (a legal and possible thing for follower transactions) would
cause a SIGSEGV. The SIGSEGV is caused because we try to deference
the CompletionRecord* to track its memory, even though we already
know it doesn't exist.

This is hard to reproduce in either exactly once tests, but the change
is pretty obvious.

I also added some comment on how that can happen, it took me a while
to find the path that could cause this (again).

Change-Id: I961af334fa2dd7faff0e95c7a49f2f16b2096fe0
Reviewed-on: http://gerrit.cloudera.org:8080/4629
Reviewed-by: Dan Burkert <da...@cloudera.com>
Tested-by: David Ribeiro Alves <dr...@apache.org>
Reviewed-by: Todd Lipcon <to...@apache.org>


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

Branch: refs/heads/master
Commit: 8f853d7a3ac56ac884c67b37744d0eeb237c69ef
Parents: 5962de1
Author: David Alves <dr...@apache.org>
Authored: Wed Oct 5 00:00:50 2016 -0700
Committer: Todd Lipcon <to...@apache.org>
Committed: Tue Oct 11 05:16:55 2016 +0000

----------------------------------------------------------------------
 src/kudu/rpc/result_tracker.cc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/8f853d7a/src/kudu/rpc/result_tracker.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/result_tracker.cc b/src/kudu/rpc/result_tracker.cc
index 259d12a..2638492 100644
--- a/src/kudu/rpc/result_tracker.cc
+++ b/src/kudu/rpc/result_tracker.cc
@@ -347,12 +347,16 @@ void ResultTracker::FailAndRespondInternal(const RequestIdPB& request_id,
   }
 
   CompletionRecord* completion_record = state_and_record.second;
-  ScopedMemTrackerUpdater<CompletionRecord> cr_updater(mem_tracker_.get(), completion_record);
 
+  // It is possible for this method to be called for an RPC that was never actually tracked (though
+  // RecordCompletionAndRespond() can't). One such case is when a follower transaction fails
+  // on the TransactionManager, for some reason, before it was tracked. The CompletionCallback still
+  // calls this method. In this case, do nothing.
   if (completion_record == nullptr) {
     return;
   }
 
+  ScopedMemTrackerUpdater<CompletionRecord> cr_updater(mem_tracker_.get(), completion_record);
   completion_record->last_updated = MonoTime::Now();
 
   int64_t seq_no = request_id.seq_no();


[3/3] kudu git commit: consensus: remove ConsensusFaultHooks

Posted by to...@apache.org.
consensus: remove ConsensusFaultHooks

We never actually implemented tests that used these to inject faults,
and in fact we only used a single one of the "hooks" as a mechanism for
counting calls to Update(). I replaced that with a simple variable so
that we could remove all of this extra code.

Change-Id: I49880cb4492c5bd911099510d05b75995573fe1d
Reviewed-on: http://gerrit.cloudera.org:8080/4669
Reviewed-by: David Ribeiro Alves <dr...@apache.org>
Tested-by: Todd Lipcon <to...@apache.org>


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

Branch: refs/heads/master
Commit: 1ca7ccfb4d0440ad09077f1f8f2bb2571dec3dc9
Parents: 8f853d7
Author: Todd Lipcon <to...@apache.org>
Authored: Fri Oct 7 16:19:57 2016 -0700
Committer: Todd Lipcon <to...@apache.org>
Committed: Tue Oct 11 06:19:05 2016 +0000

----------------------------------------------------------------------
 src/kudu/consensus/consensus-test-util.h        | 157 -------------------
 src/kudu/consensus/consensus.cc                 |  27 ----
 src/kudu/consensus/consensus.h                  |  41 -----
 src/kudu/consensus/raft_consensus.cc            |  20 +--
 src/kudu/consensus/raft_consensus.h             |   9 +-
 .../consensus/raft_consensus_quorum-test.cc     |  20 +--
 6 files changed, 15 insertions(+), 259 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/1ca7ccfb/src/kudu/consensus/consensus-test-util.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus-test-util.h b/src/kudu/consensus/consensus-test-util.h
index f45783f..80f6a6f 100644
--- a/src/kudu/consensus/consensus-test-util.h
+++ b/src/kudu/consensus/consensus-test-util.h
@@ -684,163 +684,6 @@ class TestTransactionFactory : public ReplicaTransactionFactory {
   Log* log_;
 };
 
-// Consensus fault hooks impl. that simply counts the number of calls to
-// each method.
-// Allows passing another hook instance so that we can use both.
-// If non-null, the passed hook instance will be called first for all methods.
-class CounterHooks : public Consensus::ConsensusFaultHooks {
- public:
-  explicit CounterHooks(
-      std::shared_ptr<Consensus::ConsensusFaultHooks> current_hook)
-      : current_hook_(std::move(current_hook)),
-        pre_start_calls_(0),
-        post_start_calls_(0),
-        pre_config_change_calls_(0),
-        post_config_change_calls_(0),
-        pre_replicate_calls_(0),
-        post_replicate_calls_(0),
-        pre_update_calls_(0),
-        post_update_calls_(0),
-        pre_shutdown_calls_(0),
-        post_shutdown_calls_(0) {}
-
-  virtual Status PreStart() OVERRIDE {
-    if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PreStart());
-    std::lock_guard<simple_spinlock> lock(lock_);
-    pre_start_calls_++;
-    return Status::OK();
-  }
-
-  virtual Status PostStart() OVERRIDE {
-    if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PostStart());
-    std::lock_guard<simple_spinlock> lock(lock_);
-    post_start_calls_++;
-    return Status::OK();
-  }
-
-  virtual Status PreConfigChange() OVERRIDE {
-    if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PreConfigChange());
-    std::lock_guard<simple_spinlock> lock(lock_);
-    pre_config_change_calls_++;
-    return Status::OK();
-  }
-
-  virtual Status PostConfigChange() OVERRIDE {
-    if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PostConfigChange());
-    std::lock_guard<simple_spinlock> lock(lock_);
-    post_config_change_calls_++;
-    return Status::OK();
-  }
-
-  virtual Status PreReplicate() OVERRIDE {
-    if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PreReplicate());
-    std::lock_guard<simple_spinlock> lock(lock_);
-    pre_replicate_calls_++;
-    return Status::OK();
-  }
-
-  virtual Status PostReplicate() OVERRIDE {
-    if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PostReplicate());
-    std::lock_guard<simple_spinlock> lock(lock_);
-    post_replicate_calls_++;
-    return Status::OK();
-  }
-
-  virtual Status PreUpdate() OVERRIDE {
-    if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PreUpdate());
-    std::lock_guard<simple_spinlock> lock(lock_);
-    pre_update_calls_++;
-    return Status::OK();
-  }
-
-  virtual Status PostUpdate() OVERRIDE {
-    if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PostUpdate());
-    std::lock_guard<simple_spinlock> lock(lock_);
-    post_update_calls_++;
-    return Status::OK();
-  }
-
-  virtual Status PreShutdown() OVERRIDE {
-    if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PreShutdown());
-    std::lock_guard<simple_spinlock> lock(lock_);
-    pre_shutdown_calls_++;
-    return Status::OK();
-  }
-
-  virtual Status PostShutdown() OVERRIDE {
-    if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PostShutdown());
-    std::lock_guard<simple_spinlock> lock(lock_);
-    post_shutdown_calls_++;
-    return Status::OK();
-  }
-
-  int num_pre_start_calls() {
-    std::lock_guard<simple_spinlock> lock(lock_);
-    return pre_start_calls_;
-  }
-
-  int num_post_start_calls() {
-    std::lock_guard<simple_spinlock> lock(lock_);
-    return post_start_calls_;
-  }
-
-  int num_pre_config_change_calls() {
-    std::lock_guard<simple_spinlock> lock(lock_);
-    return pre_config_change_calls_;
-  }
-
-  int num_post_config_change_calls() {
-    std::lock_guard<simple_spinlock> lock(lock_);
-    return post_config_change_calls_;
-  }
-
-  int num_pre_replicate_calls() {
-    std::lock_guard<simple_spinlock> lock(lock_);
-    return pre_replicate_calls_;
-  }
-
-  int num_post_replicate_calls() {
-    std::lock_guard<simple_spinlock> lock(lock_);
-    return post_replicate_calls_;
-  }
-
-  int num_pre_update_calls() {
-    std::lock_guard<simple_spinlock> lock(lock_);
-    return pre_update_calls_;
-  }
-
-  int num_post_update_calls() {
-    std::lock_guard<simple_spinlock> lock(lock_);
-    return post_update_calls_;
-  }
-
-  int num_pre_shutdown_calls() {
-    std::lock_guard<simple_spinlock> lock(lock_);
-    return pre_shutdown_calls_;
-  }
-
-  int num_post_shutdown_calls() {
-    std::lock_guard<simple_spinlock> lock(lock_);
-    return post_shutdown_calls_;
-  }
-
- private:
-  std::shared_ptr<Consensus::ConsensusFaultHooks> current_hook_;
-  int pre_start_calls_;
-  int post_start_calls_;
-  int pre_config_change_calls_;
-  int post_config_change_calls_;
-  int pre_replicate_calls_;
-  int post_replicate_calls_;
-  int pre_update_calls_;
-  int post_update_calls_;
-  int pre_shutdown_calls_;
-  int post_shutdown_calls_;
-
-  // Lock that protects updates to the counters.
-  mutable simple_spinlock lock_;
-};
-
 }  // namespace consensus
 }  // namespace kudu
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/1ca7ccfb/src/kudu/consensus/consensus.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus.cc b/src/kudu/consensus/consensus.cc
index ee3a398..0553b5c 100644
--- a/src/kudu/consensus/consensus.cc
+++ b/src/kudu/consensus/consensus.cc
@@ -77,32 +77,5 @@ scoped_refptr<ConsensusRound> Consensus::NewRound(
   return make_scoped_refptr(new ConsensusRound(this, std::move(replicate_msg), replicated_cb));
 }
 
-void Consensus::SetFaultHooks(const shared_ptr<ConsensusFaultHooks>& hooks) {
-  fault_hooks_ = hooks;
-}
-
-const shared_ptr<Consensus::ConsensusFaultHooks>& Consensus::GetFaultHooks() const {
-  return fault_hooks_;
-}
-
-Status Consensus::ExecuteHook(HookPoint point) {
-  if (PREDICT_FALSE(fault_hooks_ != nullptr)) {
-    switch (point) {
-      case Consensus::PRE_START: return fault_hooks_->PreStart();
-      case Consensus::POST_START: return fault_hooks_->PostStart();
-      case Consensus::PRE_CONFIG_CHANGE: return fault_hooks_->PreConfigChange();
-      case Consensus::POST_CONFIG_CHANGE: return fault_hooks_->PostConfigChange();
-      case Consensus::PRE_REPLICATE: return fault_hooks_->PreReplicate();
-      case Consensus::POST_REPLICATE: return fault_hooks_->PostReplicate();
-      case Consensus::PRE_UPDATE: return fault_hooks_->PreUpdate();
-      case Consensus::POST_UPDATE: return fault_hooks_->PostUpdate();
-      case Consensus::PRE_SHUTDOWN: return fault_hooks_->PreShutdown();
-      case Consensus::POST_SHUTDOWN: return fault_hooks_->PostShutdown();
-      default: LOG(FATAL) << "Unknown fault hook.";
-    }
-  }
-  return Status::OK();
-}
-
 } // namespace consensus
 } // namespace kudu

http://git-wip-us.apache.org/repos/asf/kudu/blob/1ca7ccfb/src/kudu/consensus/consensus.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus.h b/src/kudu/consensus/consensus.h
index 259a1c3..ba0d510 100644
--- a/src/kudu/consensus/consensus.h
+++ b/src/kudu/consensus/consensus.h
@@ -105,8 +105,6 @@ struct ConsensusBootstrapInfo {
 // 3 - destroy Consensus
 class Consensus : public RefCountedThreadSafe<Consensus> {
  public:
-  class ConsensusFaultHooks;
-
   Consensus() {}
 
   // Starts running the consensus algorithm.
@@ -247,10 +245,6 @@ class Consensus : public RefCountedThreadSafe<Consensus> {
 
   virtual void DumpStatusHtml(std::ostream& out) const = 0;
 
-  void SetFaultHooks(const std::shared_ptr<ConsensusFaultHooks>& hooks);
-
-  const std::shared_ptr<ConsensusFaultHooks>& GetFaultHooks() const;
-
   // Stops running the consensus algorithm.
   virtual void Shutdown() = 0;
 
@@ -278,26 +272,6 @@ class Consensus : public RefCountedThreadSafe<Consensus> {
   // This class is refcounted.
   virtual ~Consensus() {}
 
-  // Fault hooks for tests. In production code this will always be null.
-  std::shared_ptr<ConsensusFaultHooks> fault_hooks_;
-
-  enum HookPoint {
-    PRE_START,
-    POST_START,
-    PRE_CONFIG_CHANGE,
-    POST_CONFIG_CHANGE,
-    PRE_REPLICATE,
-    POST_REPLICATE,
-    PRE_COMMIT,
-    POST_COMMIT,
-    PRE_UPDATE,
-    POST_UPDATE,
-    PRE_SHUTDOWN,
-    POST_SHUTDOWN
-  };
-
-  Status ExecuteHook(HookPoint point);
-
   enum State {
     kNotInitialized,
     kInitializing,
@@ -422,21 +396,6 @@ class ConsensusRound : public RefCountedThreadSafe<ConsensusRound> {
   int64_t bound_term_;
 };
 
-class Consensus::ConsensusFaultHooks {
- public:
-  virtual Status PreStart() { return Status::OK(); }
-  virtual Status PostStart() { return Status::OK(); }
-  virtual Status PreConfigChange() { return Status::OK(); }
-  virtual Status PostConfigChange() { return Status::OK(); }
-  virtual Status PreReplicate() { return Status::OK(); }
-  virtual Status PostReplicate() { return Status::OK(); }
-  virtual Status PreUpdate() { return Status::OK(); }
-  virtual Status PostUpdate() { return Status::OK(); }
-  virtual Status PreShutdown() { return Status::OK(); }
-  virtual Status PostShutdown() { return Status::OK(); }
-  virtual ~ConsensusFaultHooks() {}
-};
-
 } // namespace consensus
 } // namespace kudu
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/1ca7ccfb/src/kudu/consensus/raft_consensus.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus.cc b/src/kudu/consensus/raft_consensus.cc
index f09fda8..1ff1de3 100644
--- a/src/kudu/consensus/raft_consensus.cc
+++ b/src/kudu/consensus/raft_consensus.cc
@@ -235,6 +235,7 @@ RaftConsensus::RaftConsensus(
       last_received_cur_leader_(MinimumOpId()),
       mark_dirty_clbk_(std::move(mark_dirty_clbk)),
       shutdown_(false),
+      update_calls_for_tests_(0),
       follower_memory_pressure_rejections_(metric_entity->FindOrCreateCounter(
           &METRIC_follower_memory_pressure_rejections)),
       term_metric_(metric_entity->FindOrCreateGauge(&METRIC_raft_term,
@@ -252,8 +253,6 @@ RaftConsensus::~RaftConsensus() {
 }
 
 Status RaftConsensus::Start(const ConsensusBootstrapInfo& info) {
-  RETURN_NOT_OK(ExecuteHook(PRE_START));
-
   // This just starts the monitor thread -- no failure detector is registered yet.
   if (FLAGS_enable_leader_failure_detection) {
     RETURN_NOT_OK(failure_monitor_.Start());
@@ -322,8 +321,6 @@ Status RaftConsensus::Start(const ConsensusBootstrapInfo& info) {
     RETURN_NOT_OK(StartElection(NORMAL_ELECTION));
   }
 
-  RETURN_NOT_OK(ExecuteHook(POST_START));
-
   // Report become visible to the Master.
   MarkDirty("RaftConsensus started");
 
@@ -526,8 +523,6 @@ Status RaftConsensus::BecomeReplicaUnlocked() {
 
 Status RaftConsensus::Replicate(const scoped_refptr<ConsensusRound>& round) {
 
-  RETURN_NOT_OK(ExecuteHook(PRE_REPLICATE));
-
   std::lock_guard<simple_spinlock> lock(update_lock_);
   {
     ReplicaState::UniqueLock lock;
@@ -537,8 +532,6 @@ Status RaftConsensus::Replicate(const scoped_refptr<ConsensusRound>& round) {
   }
 
   peer_manager_->SignalRequest();
-
-  RETURN_NOT_OK(ExecuteHook(POST_REPLICATE));
   return Status::OK();
 }
 
@@ -666,13 +659,13 @@ void RaftConsensus::TryRemoveFollowerTask(const string& uuid,
 
 Status RaftConsensus::Update(const ConsensusRequestPB* request,
                              ConsensusResponsePB* response) {
+  update_calls_for_tests_.Increment();
 
   if (PREDICT_FALSE(FLAGS_follower_reject_update_consensus_requests)) {
     return Status::IllegalState("Rejected: --follower_reject_update_consensus_requests "
                                 "is set to true.");
   }
 
-  RETURN_NOT_OK(ExecuteHook(PRE_UPDATE));
   response->set_responder_uuid(state_->GetPeerUuid());
 
   VLOG_WITH_PREFIX(2) << "Replica received request: " << request->ShortDebugString();
@@ -686,10 +679,7 @@ Status RaftConsensus::Update(const ConsensusRequestPB* request,
                           << state_->ToString() << ". Response: " << response->ShortDebugString();
     }
   }
-  RETURN_NOT_OK(s);
-
-  RETURN_NOT_OK(ExecuteHook(POST_UPDATE));
-  return Status::OK();
+  return s;
 }
 
 // Helper function to check if the op is a non-Transaction op.
@@ -1478,8 +1468,6 @@ void RaftConsensus::Shutdown() {
   // the last outstanding reference.
   if (shutdown_.Load(kMemOrderAcquire)) return;
 
-  CHECK_OK(ExecuteHook(PRE_SHUTDOWN));
-
   {
     ReplicaState::UniqueLock lock;
     // Transition to kShuttingDown state.
@@ -1507,8 +1495,6 @@ void RaftConsensus::Shutdown() {
   thread_pool_->Shutdown();
   failure_monitor_.Shutdown();
 
-  CHECK_OK(ExecuteHook(POST_SHUTDOWN));
-
   shutdown_.Store(true, kMemOrderRelease);
 }
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/1ca7ccfb/src/kudu/consensus/raft_consensus.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus.h b/src/kudu/consensus/raft_consensus.h
index 07ef186..eb71b94 100644
--- a/src/kudu/consensus/raft_consensus.h
+++ b/src/kudu/consensus/raft_consensus.h
@@ -61,8 +61,6 @@ struct ElectionResult;
 class RaftConsensus : public Consensus,
                       public PeerMessageQueueObserver {
  public:
-  class ConsensusFaultHooks;
-
   static scoped_refptr<RaftConsensus> Create(
     const ConsensusOptions& options,
     std::unique_ptr<ConsensusMetadata> cmeta,
@@ -149,6 +147,10 @@ class RaftConsensus : public Consensus,
   // can cause consensus to deadlock.
   ReplicaState* GetReplicaStateForTests();
 
+  int update_calls_for_tests() const {
+    return update_calls_for_tests_.Load();
+  }
+
   //------------------------------------------------------------
   // PeerMessageQueueObserver implementation
   //------------------------------------------------------------
@@ -463,6 +465,9 @@ class RaftConsensus : public Consensus,
 
   AtomicBool shutdown_;
 
+  // The number of times Update() has been called, used for some test assertions.
+  AtomicInt<int32_t> update_calls_for_tests_;
+
   scoped_refptr<Counter> follower_memory_pressure_rejections_;
   scoped_refptr<AtomicGauge<int64_t> > term_metric_;
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/1ca7ccfb/src/kudu/consensus/raft_consensus_quorum-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus_quorum-test.cc b/src/kudu/consensus/raft_consensus_quorum-test.cc
index 362a230..465cfdb 100644
--- a/src/kudu/consensus/raft_consensus_quorum-test.cc
+++ b/src/kudu/consensus/raft_consensus_quorum-test.cc
@@ -805,7 +805,7 @@ TEST_F(RaftConsensusQuorumTest, TestReplicasHandleCommunicationErrors) {
 
 // In this test we test the ability of the leader to send heartbeats
 // to replicas by simply pushing nothing after the configuration round
-// and still expecting for the replicas Update() hooks to be called.
+// and still expecting for the replicas' Update() method to be called.
 TEST_F(RaftConsensusQuorumTest, TestLeaderHeartbeats) {
   // Constants with the indexes of peers with certain roles,
   // since peers don't change roles in this test.
@@ -820,16 +820,6 @@ TEST_F(RaftConsensusQuorumTest, TestLeaderHeartbeats) {
   scoped_refptr<RaftConsensus> follower1;
   CHECK_OK(peers_->GetPeerByIdx(kFollower1Idx, &follower1));
 
-  shared_ptr<CounterHooks> counter_hook_rpl0(
-      new CounterHooks(follower0->GetFaultHooks()));
-  shared_ptr<CounterHooks> counter_hook_rpl1(
-      new CounterHooks(follower1->GetFaultHooks()));
-
-  // Replace the default fault hooks on the replicas with counter hooks
-  // before we start the configuration.
-  follower0->SetFaultHooks(counter_hook_rpl0);
-  follower1->SetFaultHooks(counter_hook_rpl1);
-
   ASSERT_OK(StartPeers());
 
   scoped_refptr<RaftConsensus> leader;
@@ -844,15 +834,15 @@ TEST_F(RaftConsensusQuorumTest, TestLeaderHeartbeats) {
   WaitForCommitIfNotAlreadyPresent(config_round.index(), kFollower0Idx, kLeaderIdx);
   WaitForCommitIfNotAlreadyPresent(config_round.index(), kFollower1Idx, kLeaderIdx);
 
-  int repl0_init_count = counter_hook_rpl0->num_pre_update_calls();
-  int repl1_init_count = counter_hook_rpl1->num_pre_update_calls();
+  int repl0_init_count = follower0->update_calls_for_tests();
+  int repl1_init_count = follower1->update_calls_for_tests();
 
   // Now wait for about 4 times the hearbeat period the counters
   // should have increased 3/4 times.
   SleepFor(MonoDelta::FromMilliseconds(FLAGS_raft_heartbeat_interval_ms * 4LL));
 
-  int repl0_final_count = counter_hook_rpl0->num_pre_update_calls();
-  int repl1_final_count = counter_hook_rpl1->num_pre_update_calls();
+  int repl0_final_count = follower0->update_calls_for_tests();
+  int repl1_final_count = follower1->update_calls_for_tests();
 
   ASSERT_GE(repl0_final_count - repl0_init_count, 3);
   ASSERT_LE(repl0_final_count - repl0_init_count, 4);