You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by gi...@apache.org on 2017/07/28 06:55:08 UTC

[2/2] mesos git commit: Store container reference in a variable if it will be used repeatedly.

Store container reference in a variable if it will be used repeatedly.

The containerizer already does it in some places, this patch makes it
more consistent.

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


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

Branch: refs/heads/master
Commit: bdf274044b7cd1c1938fc69e8b9f9510e2a35357
Parents: 68d1357
Author: Jiang Yan Xu <ya...@jxu.me>
Authored: Thu Jul 27 23:37:52 2017 -0700
Committer: Gilbert Song <so...@gmail.com>
Committed: Thu Jul 27 23:37:52 2017 -0700

----------------------------------------------------------------------
 src/slave/containerizer/mesos/containerizer.cpp | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/bdf27404/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index 1f40d0f..6f100b5 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -1779,11 +1779,13 @@ Future<bool> MesosContainerizerProcess::isolate(
     return Failure("Container destroyed during preparing");
   }
 
-  if (containers_.at(containerId)->state == DESTROYING) {
+  const Owned<Container>& container = containers_.at(containerId);
+
+  if (container->state == DESTROYING) {
     return Failure("Container is being destroyed during preparing");
   }
 
-  CHECK_EQ(containers_.at(containerId)->state, PREPARING);
+  CHECK_EQ(container->state, PREPARING);
 
   transition(containerId, ISOLATING);
 
@@ -1817,7 +1819,7 @@ Future<bool> MesosContainerizerProcess::isolate(
   // Wait for all isolators to complete.
   Future<list<Nothing>> future = collect(futures);
 
-  containers_.at(containerId)->isolation = future;
+  container->isolation = future;
 
   return future.then([]() { return true; });
 }
@@ -1833,11 +1835,13 @@ Future<bool> MesosContainerizerProcess::exec(
     return Failure("Container destroyed during fetching");
   }
 
-  if (containers_.at(containerId)->state == DESTROYING) {
+  const Owned<Container>& container = containers_.at(containerId);
+
+  if (container->state == DESTROYING) {
     return Failure("Container is being destroyed during fetching");
   }
 
-  CHECK_EQ(containers_.at(containerId)->state, FETCHING);
+  CHECK_EQ(container->state, FETCHING);
 
   // Now that we've contained the child we can signal it to continue
   // by writing to the pipe.