Made Subscribe.force optional in the Call protobuf. Review: https://reviews.apache.org/r/36560
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/fc85cc51 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/fc85cc51 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/fc85cc51 Branch: refs/heads/master Commit: fc85cc512b7767fc2e3921b15cf6602c0c68593e Parents: f9a0d23 Author: Vinod Kone <[email protected]> Authored: Thu Jul 16 14:21:48 2015 -0700 Committer: Vinod Kone <[email protected]> Committed: Thu Jul 16 15:33:11 2015 -0700 ---------------------------------------------------------------------- include/mesos/scheduler/scheduler.proto | 26 ++++++++++++++------------ src/examples/event_call_framework.cpp | 5 ++++- src/tests/scheduler_tests.cpp | 8 -------- 3 files changed, 18 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/fc85cc51/include/mesos/scheduler/scheduler.proto ---------------------------------------------------------------------- diff --git a/include/mesos/scheduler/scheduler.proto b/include/mesos/scheduler/scheduler.proto index a027da2..e2ca8e5 100644 --- a/include/mesos/scheduler/scheduler.proto +++ b/include/mesos/scheduler/scheduler.proto @@ -172,18 +172,20 @@ message Call { // 'framework_info.id'. required FrameworkInfo framework_info = 1; - // 'force' tells the master what to do in case an instance of the - // scheduler attempts to subscribe when another instance of it - // is already connected (e.g., split brain due to network - // partition). If 'force' is true, the newly subscribing scheduler - // instance is allowed and the old connected scheduler instance - // is disconnected. If false, the newly subscribing scheduler - // instance is disallowed subscription in favor of the already - // connected scheduler instance. It is recommended to set this to - // true only when a scheduler instance is (just) elected but not - // when it is retrying subscription (disconnection or master - // failover; see sched/sched.cpp for an example). - required bool force = 2; + // 'force' field is only relevant when 'framework_info.id' is set. + // It tells the master what to do in case an instance of the + // scheduler attempts to subscribe when another instance of it is + // already connected (e.g., split brain due to network partition). + // If 'force' is true, this scheduler instance is allowed and the + // old connected scheduler instance is disconnected. If false, + // this scheduler instance is disallowed subscription in favor of + // the already connected scheduler instance. + // + // It is recommended to set this to true only when a newly elected + // scheduler instance is attempting to subscribe but not when a + // scheduler is retrying subscription (e.g., disconnection or + // master failover; see sched/sched.cpp for an example). + optional bool force = 2; } // Accepts an offer, performing the specified operations http://git-wip-us.apache.org/repos/asf/mesos/blob/fc85cc51/src/examples/event_call_framework.cpp ---------------------------------------------------------------------- diff --git a/src/examples/event_call_framework.cpp b/src/examples/event_call_framework.cpp index 17fdcac..8054068 100644 --- a/src/examples/event_call_framework.cpp +++ b/src/examples/event_call_framework.cpp @@ -306,7 +306,10 @@ private: Call::Subscribe* subscribe = call.mutable_subscribe(); subscribe->mutable_framework_info()->CopyFrom(framework); - subscribe->set_force(true); + + if (framework.has_id()) { + subscribe->set_force(true); + } mesos.send(call); http://git-wip-us.apache.org/repos/asf/mesos/blob/fc85cc51/src/tests/scheduler_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/scheduler_tests.cpp b/src/tests/scheduler_tests.cpp index 946fa82..6e83e64 100644 --- a/src/tests/scheduler_tests.cpp +++ b/src/tests/scheduler_tests.cpp @@ -145,7 +145,6 @@ TEST_F(SchedulerTest, TaskRunning) Call::Subscribe* subscribe = call.mutable_subscribe(); subscribe->mutable_framework_info()->CopyFrom(DEFAULT_FRAMEWORK_INFO); - subscribe->set_force(true); mesos.send(call); } @@ -252,7 +251,6 @@ TEST_F(SchedulerTest, ReconcileTask) Call::Subscribe* subscribe = call.mutable_subscribe(); subscribe->mutable_framework_info()->CopyFrom(DEFAULT_FRAMEWORK_INFO); - subscribe->set_force(true); mesos.send(call); } @@ -361,7 +359,6 @@ TEST_F(SchedulerTest, KillTask) Call::Subscribe* subscribe = call.mutable_subscribe(); subscribe->mutable_framework_info()->CopyFrom(DEFAULT_FRAMEWORK_INFO); - subscribe->set_force(true); mesos.send(call); } @@ -485,7 +482,6 @@ TEST_F(SchedulerTest, ShutdownExecutor) Call::Subscribe* subscribe = call.mutable_subscribe(); subscribe->mutable_framework_info()->CopyFrom(DEFAULT_FRAMEWORK_INFO); - subscribe->set_force(true); mesos.send(call); } @@ -598,7 +594,6 @@ TEST_F(SchedulerTest, Teardown) Call::Subscribe* subscribe = call.mutable_subscribe(); subscribe->mutable_framework_info()->CopyFrom(DEFAULT_FRAMEWORK_INFO); - subscribe->set_force(true); mesos.send(call); } @@ -695,7 +690,6 @@ TEST_F(SchedulerTest, Decline) Call::Subscribe* subscribe = call.mutable_subscribe(); subscribe->mutable_framework_info()->CopyFrom(DEFAULT_FRAMEWORK_INFO); - subscribe->set_force(true); mesos.send(call); } @@ -774,7 +768,6 @@ TEST_F(SchedulerTest, Revive) Call::Subscribe* subscribe = call.mutable_subscribe(); subscribe->mutable_framework_info()->CopyFrom(DEFAULT_FRAMEWORK_INFO); - subscribe->set_force(true); mesos.send(call); } @@ -873,7 +866,6 @@ TEST_F(SchedulerTest, Message) Call::Subscribe* subscribe = call.mutable_subscribe(); subscribe->mutable_framework_info()->CopyFrom(DEFAULT_FRAMEWORK_INFO); - subscribe->set_force(true); mesos.send(call); }
