Repository: mesos Updated Branches: refs/heads/master 82b6112ca -> 0de0a1985
Updated declineOffer use Call::DECLINE to decline offer. Review: https://reviews.apache.org/r/39843 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0de0a198 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0de0a198 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0de0a198 Branch: refs/heads/master Commit: 0de0a1985533ea5b1202f4a7c599ec7eafa2889b Parents: 82b6112 Author: Guangya Liu <[email protected]> Authored: Tue Nov 3 12:13:25 2015 -0800 Committer: Vinod Kone <[email protected]> Committed: Tue Nov 3 12:13:26 2015 -0800 ---------------------------------------------------------------------- src/sched/sched.cpp | 40 +++++++++++++++++++++++++++++++++++++--- src/tests/master_tests.cpp | 6 +++--- 2 files changed, 40 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/0de0a198/src/sched/sched.cpp ---------------------------------------------------------------------- diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp index 9c5e3b8..4ec1633 100644 --- a/src/sched/sched.cpp +++ b/src/sched/sched.cpp @@ -1233,6 +1233,29 @@ protected: send(master.get().pid(), call); } + void declineOffer( + const OfferID& offerId, + const Filters& filters) + { + if (!connected) { + VLOG(1) << "Ignoring decline offer message as master is disconnected"; + return; + } + + Call call; + + CHECK(framework.has_id()); + call.mutable_framework_id()->CopyFrom(framework.id()); + call.set_type(Call::DECLINE); + + Call::Decline* decline = call.mutable_decline(); + decline->add_offer_ids()->CopyFrom(offerId); + decline->mutable_filters()->CopyFrom(filters); + + CHECK_SOME(master); + send(master.get().pid(), call); + } + void reviveOffers() { if (!connected) { @@ -1938,10 +1961,21 @@ Status MesosSchedulerDriver::declineOffer( const OfferID& offerId, const Filters& filters) { - vector<OfferID> offerIds; - offerIds.push_back(offerId); + synchronized (mutex) { + if (status != DRIVER_RUNNING) { + return status; + } - return launchTasks(offerIds, vector<TaskInfo>(), filters); + CHECK(process != NULL); + + dispatch( + process, + &SchedulerProcess::declineOffer, + offerId, + filters); + + return status; + } } http://git-wip-us.apache.org/repos/asf/mesos/blob/0de0a198/src/tests/master_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp index 67531db..8564405 100644 --- a/src/tests/master_tests.cpp +++ b/src/tests/master_tests.cpp @@ -2635,8 +2635,8 @@ TEST_F(MasterTest, OfferNotRescindedOnceDeclined) EXPECT_CALL(sched, resourceOffers(_, _)) .WillRepeatedly(DeclineOffers()); // Decline all offers. - Future<mesos::scheduler::Call> acceptCall = FUTURE_CALL( - mesos::scheduler::Call(), mesos::scheduler::Call::ACCEPT, _, _); + Future<mesos::scheduler::Call> declineCall = FUTURE_CALL( + mesos::scheduler::Call(), mesos::scheduler::Call::DECLINE, _, _); EXPECT_CALL(sched, offerRescinded(&driver, _)) .Times(0); @@ -2645,7 +2645,7 @@ TEST_F(MasterTest, OfferNotRescindedOnceDeclined) AWAIT_READY(registered); // Wait for the framework to decline the offers. - AWAIT_READY(acceptCall); + AWAIT_READY(declineCall); // Now advance to the offer timeout, we need to settle the clock to // ensure that the offer rescind timeout would be processed
