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 2016/12/02 21:29:13 UTC

[06/10] mesos git commit: Tweaked usage of `getFramework`.

Tweaked usage of `getFramework`.

In a few places, calls to `getFramework` can be hoisted out of an inner
loop. This improves code clarity (as well as maybe saving a few cycles).

A call to `getFramework` can be hoisted out of an inner loop.

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


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

Branch: refs/heads/master
Commit: 432165f3ff9259204e0d65db10b3aa1dba42b2af
Parents: 9ccfa5c
Author: Neil Conway <ne...@gmail.com>
Authored: Fri Dec 2 13:28:23 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Dec 2 13:28:23 2016 -0800

----------------------------------------------------------------------
 src/master/master.cpp | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/432165f3/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index b015b8d..7417651 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -7405,20 +7405,24 @@ void Master::addSlave(
 
   // Add the slave's executors to the frameworks.
   foreachkey (const FrameworkID& frameworkId, slave->executors) {
+    Framework* framework = getFramework(frameworkId);
+
+    // The framework might not be re-registered yet.
+    if (framework == nullptr) {
+      continue;
+    }
+
     foreachvalue (const ExecutorInfo& executorInfo,
                   slave->executors[frameworkId]) {
-      Framework* framework = getFramework(frameworkId);
-      // The framework might not be re-registered yet.
-      if (framework != nullptr) {
-        framework->addExecutor(slave->id, executorInfo);
-      }
+      framework->addExecutor(slave->id, executorInfo);
     }
   }
 
   // Add the slave's tasks to the frameworks.
   foreachkey (const FrameworkID& frameworkId, slave->tasks) {
+    Framework* framework = getFramework(frameworkId);
+
     foreachvalue (Task* task, slave->tasks[frameworkId]) {
-      Framework* framework = getFramework(task->framework_id());
       // The framework might not be re-registered yet.
       if (framework != nullptr) {
         framework->addTask(task);
@@ -7569,6 +7573,8 @@ void Master::_removeSlave(
 
   // Transition the tasks to lost and remove them.
   foreachkey (const FrameworkID& frameworkId, utils::copy(slave->tasks)) {
+    Framework* framework = getFramework(frameworkId);
+
     foreachvalue (Task* task, utils::copy(slave->tasks[frameworkId])) {
       const StatusUpdate& update = protobuf::createStatusUpdate(
           task->framework_id(),
@@ -7585,7 +7591,6 @@ void Master::_removeSlave(
       updateTask(task, update);
       removeTask(task);
 
-      Framework* framework = getFramework(frameworkId);
       if (framework == nullptr) {
         LOG(WARNING) << "Dropping update " << update
                      << " for unknown framework " << frameworkId;