You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2014/01/17 01:58:30 UTC

[10/10] git commit: Changed log recover implementation to only broadcast requests when there are enough replicas in the network.

Changed log recover implementation to only broadcast requests when
there are enough replicas in the network.

From: Jie Yu <yu...@gmail.com>
Review: https://reviews.apache.org/r/16982


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

Branch: refs/heads/master
Commit: 420e30bfe5ce4c8b14bdccedff21f66475d91f18
Parents: 3e33188
Author: Benjamin Hindman <be...@gmail.com>
Authored: Thu Jan 16 16:56:46 2014 -0800
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Thu Jan 16 16:56:46 2014 -0800

----------------------------------------------------------------------
 src/log/recover.cpp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/420e30bf/src/log/recover.cpp
----------------------------------------------------------------------
diff --git a/src/log/recover.cpp b/src/log/recover.cpp
index 0ab8e95..0f827d7 100644
--- a/src/log/recover.cpp
+++ b/src/log/recover.cpp
@@ -148,6 +148,26 @@ private:
   {
     CHECK_NE(status, Metadata::VOTING);
 
+    // Wait until there are enough (i.e., quorum of) replicas in the
+    // network to avoid unnecessary retries.
+    network->watch(quorum, Network::GREATER_THAN_OR_EQUAL_TO)
+      .onAny(defer(self(), &Self::watched, lambda::_1));
+  }
+
+  void watched(const Future<size_t>& future)
+  {
+    if (!future.isReady()) {
+      promise.fail(
+          future.isFailed() ?
+          future.failure() :
+          "Not expecting discarded future");
+
+      terminate(self());
+      return;
+    }
+
+    CHECK_GE(future.get(), quorum);
+
     // Broadcast recover request to all replicas.
     network->broadcast(protocol::recover, RecoverRequest())
       .onAny(defer(self(), &Self::broadcasted, lambda::_1));