mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject [6/6] git commit: Simplified coordinator election semantics.
Date Mon, 10 Mar 2014 06:39:02 GMT
Simplified coordinator election semantics.

Review: https://reviews.apache.org/r/17344


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

Branch: refs/heads/master
Commit: 2c12b260a71bca2e06f26971cfce9cde85c4b114
Parents: 93c4d4d
Author: Benjamin Hindman <benjamin.hindman@gmail.com>
Authored: Mon Jan 20 20:06:14 2014 -0800
Committer: Benjamin Hindman <benjamin.hindman@gmail.com>
Committed: Sun Mar 9 23:35:10 2014 -0700

----------------------------------------------------------------------
 src/log/coordinator.cpp | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2c12b260/src/log/coordinator.cpp
----------------------------------------------------------------------
diff --git a/src/log/coordinator.cpp b/src/log/coordinator.cpp
index aacbcba..caa4b85 100644
--- a/src/log/coordinator.cpp
+++ b/src/log/coordinator.cpp
@@ -143,9 +143,9 @@ private:
 Future<Option<uint64_t> > CoordinatorProcess::elect()
 {
   if (state == ELECTING) {
-    return Failure("Coordinator already being elected");
+    return electing;
   } else if (state == ELECTED) {
-    return Failure("Coordinator already elected");
+    return index - 1; // The last learned position!
   } else if (state == WRITING) {
     return Failure("Coordinator already elected, and is currently writing");
   }
@@ -288,10 +288,8 @@ Future<uint64_t> CoordinatorProcess::demote()
 
 Future<Option<uint64_t> > CoordinatorProcess::append(const string& bytes)
 {
-  if (state == INITIAL) {
+  if (state == INITIAL || state == ELECTING) {
     return None();
-  } else if (state == ELECTING) {
-    return Failure("Coordinator is being elected");
   } else if (state == WRITING) {
     return Failure("Coordinator is currently writing");
   }
@@ -310,10 +308,8 @@ Future<Option<uint64_t> > CoordinatorProcess::append(const
string& bytes)
 
 Future<Option<uint64_t> > CoordinatorProcess::truncate(uint64_t to)
 {
-  if (state == INITIAL) {
+  if (state == INITIAL || state == ELECTING) {
     return None();
-  } else if (state == ELECTING) {
-    return Failure("Coordinator is being elected");
   } else if (state == WRITING) {
     return Failure("Coordinator is currently writing");
   }


Mime
View raw message