You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2014/01/15 23:02:24 UTC
[3/5] git commit: Made ZooKeeperMasterContenderProcess::master an
option to codify the fact that it can be unset after construction.
Made ZooKeeperMasterContenderProcess::master an option to codify the
fact that it can be unset after construction.
From: Jiang Yan Xu <ya...@jxu.me>
Review: https://reviews.apache.org/r/16588
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e03700a9
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e03700a9
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e03700a9
Branch: refs/heads/master
Commit: e03700a92a1c7945da1dbbffa45733f92d5ed65b
Parents: fe86c8b
Author: Vinod Kone <vi...@twitter.com>
Authored: Wed Jan 15 12:50:44 2014 -0800
Committer: Vinod Kone <vi...@twitter.com>
Committed: Wed Jan 15 12:54:57 2014 -0800
----------------------------------------------------------------------
src/master/contender.cpp | 15 +++++++++++----
src/master/contender.hpp | 2 ++
2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/e03700a9/src/master/contender.cpp
----------------------------------------------------------------------
diff --git a/src/master/contender.cpp b/src/master/contender.cpp
index 72a7796..7bd25b5 100644
--- a/src/master/contender.cpp
+++ b/src/master/contender.cpp
@@ -62,7 +62,9 @@ public:
private:
Owned<zookeeper::Group> group;
LeaderContender* contender;
- PID<Master> master;
+
+ // The master this contender contends on behalf of.
+ Option<PID<Master> > master;
};
@@ -115,9 +117,12 @@ void StandaloneMasterContender::initialize(
initialized = true;
}
+
Future<Future<Nothing> > StandaloneMasterContender::contend()
{
- CHECK(initialized) << "Initialize the contender first";
+ if (!initialized) {
+ return Failure("Initialize the contender first");
+ }
if (promise != NULL) {
LOG(INFO) << "Withdrawing the previous membership before recontending";
@@ -194,14 +199,16 @@ void ZooKeeperMasterContenderProcess::initialize(
Future<Future<Nothing> > ZooKeeperMasterContenderProcess::contend()
{
- CHECK(master) << "Initialize the contender first";
+ if (master.isNone()) {
+ return Failure("Initialize the contender first");
+ }
if (contender != NULL) {
LOG(INFO) << "Withdrawing the previous membership before recontending";
delete contender;
}
- contender = new LeaderContender(group.get(), master);
+ contender = new LeaderContender(group.get(), master.get());
return contender->contend();
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/e03700a9/src/master/contender.hpp
----------------------------------------------------------------------
diff --git a/src/master/contender.hpp b/src/master/contender.hpp
index 7764edd..0156369 100644
--- a/src/master/contender.hpp
+++ b/src/master/contender.hpp
@@ -69,6 +69,8 @@ public:
// Returns a Future<Nothing> once the contender has entered the
// contest (by obtaining a membership) and an error otherwise.
+ // A failed future is returned if this method is called before
+ // initialize().
// The inner Future returns Nothing when the contender is out of
// the contest (i.e. its membership is lost).
//