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 2014/03/14 07:35:25 UTC

[3/3] git commit: Option::get reference cleanup in mesos.

Option::get reference cleanup in mesos.

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


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

Branch: refs/heads/master
Commit: e49fc2d7b7db65fa9921ba10b603f27378b1bdfa
Parents: ed9f3f9
Author: Dominic Hamon <dh...@twopensource.com>
Authored: Thu Mar 13 23:01:43 2014 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Thu Mar 13 23:01:43 2014 -0700

----------------------------------------------------------------------
 src/linux/fs.cpp                                |  2 +-
 src/linux/fs.hpp                                |  2 +-
 src/log/log.cpp                                 |  3 ++-
 src/sched/sched.cpp                             |  3 ++-
 src/slave/containerizer/mesos_containerizer.cpp | 10 ++++-----
 src/slave/slave.cpp                             | 23 ++++++++++----------
 src/slave/status_update_manager.cpp             |  8 +++----
 7 files changed, 26 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/e49fc2d7/src/linux/fs.cpp
----------------------------------------------------------------------
diff --git a/src/linux/fs.cpp b/src/linux/fs.cpp
index e5f4f9a..b01d14c 100644
--- a/src/linux/fs.cpp
+++ b/src/linux/fs.cpp
@@ -34,7 +34,7 @@ namespace internal {
 namespace fs {
 
 
-bool MountTable::Entry::hasOption(const std::string& option)
+bool MountTable::Entry::hasOption(const std::string& option) const
 {
   struct mntent mntent;
   mntent.mnt_fsname = const_cast<char*>(fsname.c_str());

http://git-wip-us.apache.org/repos/asf/mesos/blob/e49fc2d7/src/linux/fs.hpp
----------------------------------------------------------------------
diff --git a/src/linux/fs.hpp b/src/linux/fs.hpp
index 1d86dd0..ac8b5f4 100644
--- a/src/linux/fs.hpp
+++ b/src/linux/fs.hpp
@@ -60,7 +60,7 @@ struct MountTable {
     // Check whether a given mount option exists in a mount table entry.
     // @param   option    The given mount option.
     // @return  Whether the given mount option exists.
-    bool hasOption(const std::string& option);
+    bool hasOption(const std::string& option) const;
 
     std::string fsname; // Device or server for filesystem.
     std::string dir;    // Directory mounted on.

http://git-wip-us.apache.org/repos/asf/mesos/blob/e49fc2d7/src/log/log.cpp
----------------------------------------------------------------------
diff --git a/src/log/log.cpp b/src/log/log.cpp
index 6992518..d9b2687 100644
--- a/src/log/log.cpp
+++ b/src/log/log.cpp
@@ -247,7 +247,8 @@ void LogProcess::finalize()
 {
   if (recovering.isSome()) {
     // Stop the recovery if it is still pending.
-    recovering.get().discard();
+    Future<Owned<Replica> > future = recovering.get();
+    future.discard();
   }
 
   // If there exist operations that are gated by the recovery, we fail

http://git-wip-us.apache.org/repos/asf/mesos/blob/e49fc2d7/src/sched/sched.cpp
----------------------------------------------------------------------
diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp
index 00f6307..3684cfe 100644
--- a/src/sched/sched.cpp
+++ b/src/sched/sched.cpp
@@ -259,7 +259,8 @@ protected:
       // are here, making the 'discard' here a no-op. This is ok
       // because we set 'reauthenticate' here which enforces a retry
       // in '_authenticate'.
-      authenticating.get().discard();
+      Future<bool> authenticating_ = authenticating.get();
+      authenticating_.discard();
       reauthenticate = true;
       return;
     }

http://git-wip-us.apache.org/repos/asf/mesos/blob/e49fc2d7/src/slave/containerizer/mesos_containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos_containerizer.cpp b/src/slave/containerizer/mesos_containerizer.cpp
index c1a3e0f..c819c97 100644
--- a/src/slave/containerizer/mesos_containerizer.cpp
+++ b/src/slave/containerizer/mesos_containerizer.cpp
@@ -194,18 +194,18 @@ Future<Nothing> MesosContainerizerProcess::recover(
 
         // We are only interested in the latest run of the executor!
         const ContainerID& containerId = executor.latest.get();
-        CHECK(executor.runs.contains(containerId));
-        const RunState& run = executor.runs.get(containerId).get();
+        Option<RunState> run = executor.runs.get(containerId);
+        CHECK_SOME(run);
 
         // We need the pid so the reaper can monitor the executor so skip this
         // executor if it's not present. This is not an error because the slave
         // will try to wait on the container which will return a failed
         // Termination and everything will get cleaned up.
-        if (!run.forkedPid.isSome()) {
+        if (!run.get().forkedPid.isSome()) {
           continue;
         }
 
-        if (run.completed) {
+        if (run.get().completed) {
           VLOG(1) << "Skipping recovery of executor '" << executor.id
                   << "' of framework " << framework.id
                   << " because its latest run "
@@ -217,7 +217,7 @@ Future<Nothing> MesosContainerizerProcess::recover(
                   << "' for executor '" << executor.id
                   << "' of framework " << framework.id;
 
-        recoverable.push_back(run);
+        recoverable.push_back(run.get());
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/e49fc2d7/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 6abb95d..d8d3e0f 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -3024,11 +3024,10 @@ void Framework::recoverExecutor(const ExecutorState& state)
     }
   }
 
-  CHECK(state.runs.contains(latest))
-    << "Cannot find latest run " << latest << " for executor " << state.id
-    << " of framework " << id;
-
-  const RunState& run = state.runs.get(latest).get();
+  Option<RunState> run = state.runs.get(latest);
+  CHECK_SOME(run)
+      << "Cannot find latest run " << latest << " for executor " << state.id
+      << " of framework " << id;
 
   // Create executor.
   const string& directory = paths::getExecutorRunPath(
@@ -3038,21 +3037,21 @@ void Framework::recoverExecutor(const ExecutorState& state)
       slave, id, state.info.get(), latest, directory, info.checkpoint());
 
   // Recover the libprocess PID if possible.
-  if (run.libprocessPid.isSome()) {
+  if (run.get().libprocessPid.isSome()) {
     // When recovering in non-strict mode, the assumption is that the
     // slave can die after checkpointing the forked pid but before the
     // libprocess pid. So, it is not possible for the libprocess pid
     // to exist but not the forked pid. If so, it is a really bad
     // situation (e.g., disk corruption).
-    CHECK_SOME(run.forkedPid)
+    CHECK_SOME(run.get().forkedPid)
       << "Failed to get forked pid for executor " << state.id
       << " of framework " << id;
 
-    executor->pid = run.libprocessPid.get();
+    executor->pid = run.get().libprocessPid.get();
   }
 
   // And finally recover all the executor's tasks.
-  foreachvalue (const TaskState& taskState, run.tasks) {
+  foreachvalue (const TaskState& taskState, run.get().tasks) {
     executor->recoverTask(taskState);
   }
 
@@ -3069,11 +3068,11 @@ void Framework::recoverExecutor(const ExecutorState& state)
   // If the latest run of the executor was completed (i.e., terminated
   // and all updates are acknowledged) in the previous run, we
   // transition its state to 'TERMINATED' and gc the directories.
-  if (run.completed) {
+  if (run.get().completed) {
     executor->state = Executor::TERMINATED;
 
-    CHECK_SOME(run.id);
-    const ContainerID& runId = run.id.get();
+    CHECK_SOME(run.get().id);
+    const ContainerID& runId = run.get().id.get();
 
     // GC the executor run's work directory.
     const string& path = paths::getExecutorRunPath(

http://git-wip-us.apache.org/repos/asf/mesos/blob/e49fc2d7/src/slave/status_update_manager.cpp
----------------------------------------------------------------------
diff --git a/src/slave/status_update_manager.cpp b/src/slave/status_update_manager.cpp
index 9db53e8..5d5cf23 100644
--- a/src/slave/status_update_manager.cpp
+++ b/src/slave/status_update_manager.cpp
@@ -219,10 +219,10 @@ Future<Nothing> StatusUpdateManagerProcess::recover(
 
       // We are only interested in the latest run of the executor!
       const ContainerID& latest = executor.latest.get();
-      CHECK(executor.runs.contains(latest));
-      const RunState& run  = executor.runs.get(latest).get();
+      Option<RunState> run = executor.runs.get(latest);
+      CHECK_SOME(run);
 
-      if (run.completed) {
+      if (run.get().completed) {
         VLOG(1) << "Skipping recovering updates of"
                 << " executor '" << executor.id
                 << "' of framework " << framework.id
@@ -231,7 +231,7 @@ Future<Nothing> StatusUpdateManagerProcess::recover(
         continue;
       }
 
-      foreachvalue (const TaskState& task, run.tasks) {
+      foreachvalue (const TaskState& task, run.get().tasks) {
         // No updates were ever received for this task!
         // This means either:
         // 1) the executor never received this task or