You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2015/05/19 21:22:16 UTC
[3/3] mesos git commit: Removed Master::getSlave.
Removed Master::getSlave.
Review: https://reviews.apache.org/r/34389
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c24268f1
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c24268f1
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c24268f1
Branch: refs/heads/master
Commit: c24268f13a2307ef12bfea794a48786338b422fe
Parents: 42cf03a
Author: Benjamin Mahler <be...@gmail.com>
Authored: Mon May 18 18:41:38 2015 -0700
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Tue May 19 11:55:31 2015 -0700
----------------------------------------------------------------------
src/master/master.cpp | 43 +++++++++++++++++++++---------------------
src/master/master.hpp | 6 ++----
src/master/validation.cpp | 2 +-
3 files changed, 24 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/c24268f1/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index d2df99c..1526f59 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -2403,7 +2403,8 @@ void Master::accept(
}
CHECK_SOME(slaveId);
- Slave* slave = CHECK_NOTNULL(getSlave(slaveId.get()));
+ Slave* slave = slaves.registered.get(slaveId.get());
+ CHECK_NOTNULL(slave);
LOG(INFO) << "Processing ACCEPT call for offers: " << accept.offer_ids()
<< " on slave " << *slave << " for framework " << *framework;
@@ -2477,7 +2478,7 @@ void Master::_accept(
return;
}
- Slave* slave = getSlave(slaveId);
+ Slave* slave = slaves.registered.get(slaveId);
if (slave == NULL || !slave->connected) {
foreach (const Offer::Operation& operation, accept.operations()) {
@@ -2870,7 +2871,7 @@ void Master::kill(Framework* framework, const scheduler::Call::Kill& kill)
return;
}
- Slave* slave = getSlave(task->slave_id());
+ Slave* slave = slaves.registered.get(task->slave_id());
CHECK(slave != NULL) << "Unknown slave " << task->slave_id();
// We add the task to 'killedTasks' here because the slave
@@ -2934,7 +2935,7 @@ void Master::statusUpdateAcknowledgement(
return;
}
- Slave* slave = getSlave(slaveId);
+ Slave* slave = slaves.registered.get(slaveId);
if (slave == NULL) {
LOG(WARNING)
@@ -3030,7 +3031,8 @@ void Master::schedulerMessage(
return;
}
- Slave* slave = getSlave(slaveId);
+ Slave* slave = slaves.registered.get(slaveId);
+
if (slave == NULL) {
LOG(WARNING) << "Cannot send framework message for framework "
<< *framework << " to slave " << slaveId
@@ -3256,7 +3258,7 @@ void Master::reregisterSlave(
return;
}
- Slave* slave = getSlave(slaveInfo.id());
+ Slave* slave = slaves.registered.get(slaveInfo.id());
if (slave != NULL) {
slave->reregisteredTime = Clock::now();
@@ -3435,7 +3437,7 @@ void Master::unregisterSlave(const UPID& from, const SlaveID& slaveId)
LOG(INFO) << "Asked to unregister slave " << slaveId;
- Slave* slave = getSlave(slaveId);
+ Slave* slave = slaves.registered.get(slaveId);
if (slave != NULL) {
if (slave->pid != from) {
@@ -3473,7 +3475,7 @@ void Master::statusUpdate(const StatusUpdate& update, const UPID& pid)
return;
}
- Slave* slave = getSlave(update.slave_id());
+ Slave* slave = slaves.registered.get(update.slave_id());
if (slave == NULL) {
LOG(WARNING) << "Ignoring status update " << update
@@ -4457,7 +4459,8 @@ void Master::removeFramework(Framework* framework)
// Remove pointers to the framework's tasks in slaves.
foreachvalue (Task* task, utils::copy(framework->tasks)) {
- Slave* slave = getSlave(task->slave_id());
+ Slave* slave = slaves.registered.get(task->slave_id());
+
// Since we only find out about tasks when the slave re-registers,
// it must be the case that the slave exists!
CHECK(slave != NULL)
@@ -4501,7 +4504,8 @@ void Master::removeFramework(Framework* framework)
// Remove the framework's executors for correct resource accounting.
foreachkey (const SlaveID& slaveId, utils::copy(framework->executors)) {
- Slave* slave = getSlave(slaveId);
+ Slave* slave = slaves.registered.get(slaveId);
+
if (slave != NULL) {
foreachkey (const ExecutorID& executorId,
utils::copy(framework->executors[slaveId])) {
@@ -4896,7 +4900,9 @@ void Master::updateTask(Task* task, const StatusUpdate& update)
None());
// The slave owns the Task object and cannot be NULL.
- Slave* slave = CHECK_NOTNULL(getSlave(task->slave_id()));
+ Slave* slave = slaves.registered.get(task->slave_id());
+ CHECK_NOTNULL(slave);
+
slave->taskTerminated(task);
Framework* framework = getFramework(task->framework_id());
@@ -4928,7 +4934,8 @@ void Master::removeTask(Task* task)
CHECK_NOTNULL(task);
// The slave owns the Task object and cannot be NULL.
- Slave* slave = CHECK_NOTNULL(getSlave(task->slave_id()));
+ Slave* slave = slaves.registered.get(task->slave_id());
+ CHECK_NOTNULL(slave);
if (!protobuf::isTerminalState(task->state())) {
LOG(WARNING) << "Removing task " << task->task_id()
@@ -5040,7 +5047,8 @@ void Master::removeOffer(Offer* offer, bool rescind)
framework->removeOffer(offer);
// Remove from slave.
- Slave* slave = getSlave(offer->slave_id());
+ Slave* slave = slaves.registered.get(offer->slave_id());
+
CHECK(slave != NULL)
<< "Unknown slave " << offer->slave_id()
<< " in the offer " << offer->id();
@@ -5076,15 +5084,6 @@ Framework* Master::getFramework(const FrameworkID& frameworkId)
// TODO(bmahler): Consider killing this.
-Slave* Master::getSlave(const SlaveID& slaveId)
-{
- return slaves.registered.contains(slaveId)
- ? slaves.registered[slaveId]
- : NULL;
-}
-
-
-// TODO(bmahler): Consider killing this.
Offer* Master::getOffer(const OfferID& offerId)
{
return offers.contains(offerId) ? offers[offerId] : NULL;
http://git-wip-us.apache.org/repos/asf/mesos/blob/c24268f1/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 4a94e23..c8c6251 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -975,7 +975,6 @@ protected:
void removeOffer(Offer* offer, bool rescind = false);
Framework* getFramework(const FrameworkID& frameworkId);
- Slave* getSlave(const SlaveID& slaveId);
Offer* getOffer(const OfferID& offerId);
FrameworkID newFrameworkId();
@@ -1103,9 +1102,8 @@ private:
friend struct Metrics;
- // NOTE: Since 'getOffer' and 'getSlave' are protected, we need to
- // make the following functions friends so that validation functions
- // can get Offer* and Slave*.
+ // NOTE: Since 'getOffer' and 'slaves' are protected,
+ // we need to make the following functions friends.
friend Offer* validation::offer::getOffer(
Master* master, const OfferID& offerId);
http://git-wip-us.apache.org/repos/asf/mesos/blob/c24268f1/src/master/validation.cpp
----------------------------------------------------------------------
diff --git a/src/master/validation.cpp b/src/master/validation.cpp
index 20a6ac8..1793b0e 100644
--- a/src/master/validation.cpp
+++ b/src/master/validation.cpp
@@ -447,7 +447,7 @@ Offer* getOffer(Master* master, const OfferID& offerId)
Slave* getSlave(Master* master, const SlaveID& slaveId)
{
CHECK_NOTNULL(master);
- return master->getSlave(slaveId);
+ return master->slaves.registered.get(slaveId);
}