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/04/10 01:31:44 UTC

git commit: Used implicit Try -> Future flattening in the Slave.

Repository: mesos
Updated Branches:
  refs/heads/master 675e0ac57 -> 1649aedd5


Used implicit Try -> Future flattening in the Slave.

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


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

Branch: refs/heads/master
Commit: 1649aedd5ad6fc754f7c4e5d351a115b0f8d290b
Parents: 675e0ac
Author: Ritwik Yadav <ri...@gmail.com>
Authored: Wed Apr 9 16:29:13 2014 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Wed Apr 9 16:31:00 2014 -0700

----------------------------------------------------------------------
 src/slave/slave.cpp | 30 +++++++++++-------------------
 src/slave/slave.hpp |  2 +-
 2 files changed, 12 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1649aedd/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index a356f5f..cddb241 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -2617,34 +2617,26 @@ void Slave::checkDiskUsage()
   // fs::usage() into async.
   // NOTE: We calculate disk usage of the file system on which the
   // slave work directory is mounted.
-  Future<Try<double> >(fs::usage(flags.work_dir))
+  Future<double>(fs::usage(flags.work_dir))
     .onAny(defer(self(), &Slave::_checkDiskUsage, lambda::_1));
 }
 
 
-void Slave::_checkDiskUsage(const Future<Try<double> >& usage)
+void Slave::_checkDiskUsage(const Future<double>& usage)
 {
   if (!usage.isReady()) {
     LOG(ERROR) << "Failed to get disk usage: "
                << (usage.isFailed() ? usage.failure() : "future discarded");
   } else {
-    Try<double> result = usage.get();
-
-    if (result.isSome()) {
-      double use = result.get();
-
-      LOG(INFO) << "Current usage " << std::setiosflags(std::ios::fixed)
-                << std::setprecision(2) << 100 * use << "%."
-                << " Max allowed age: " << age(use);
-
-      // We prune all directories whose deletion time is within
-      // the next 'gc_delay - age'. Since a directory is always
-      // scheduled for deletion 'gc_delay' into the future, only directories
-      // that are at least 'age' old are deleted.
-      gc.prune(flags.gc_delay - age(use));
-    } else {
-      LOG(WARNING) << "Unable to get disk usage: " << result.error();
-    }
+    LOG(INFO) << "Current usage " << std::setiosflags(std::ios::fixed)
+              << std::setprecision(2) << 100 * usage.get() << "%."
+              << " Max allowed age: " << age(usage.get());
+
+    // We prune all directories whose deletion time is within
+    // the next 'gc_delay - age'. Since a directory is always
+    // scheduled for deletion 'gc_delay' into the future, only directories
+    // that are at least 'age' old are deleted.
+    gc.prune(flags.gc_delay - age(usage.get()));
   }
   delay(flags.disk_watch_interval, self(), &Slave::checkDiskUsage);
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/1649aedd/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 15e23ce..08f6005 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -195,7 +195,7 @@ public:
   // TODO(vinod): Instead of making this function public, we need to
   // mock both GarbageCollector (and pass it through slave's constructor)
   // and os calls.
-  void _checkDiskUsage(const process::Future<Try<double> >& usage);
+  void _checkDiskUsage(const process::Future<double>& usage);
 
   // Shut down an executor. This is a two phase process. First, an
   // executor receives a shut down message (shut down phase), then