Addressed a TODO about setting fetcher cache size at construction.

Now that agent flags are passed into the fetcher at construction,
it is trivial to set the fetcher cache size (--fetcher_cache_size)
at construction time too.

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


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

Branch: refs/heads/master
Commit: 6db493c07487c63595bfcc11a9881f3af396051a
Parents: 34a31f0
Author: James Peach <[email protected]>
Authored: Wed Jun 21 11:49:20 2017 -0700
Committer: Joseph Wu <[email protected]>
Committed: Wed Jun 21 11:49:20 2017 -0700

----------------------------------------------------------------------
 src/slave/containerizer/fetcher.cpp | 22 ++++++----------------
 src/slave/containerizer/fetcher.hpp |  9 +++------
 2 files changed, 9 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6db493c0/src/slave/containerizer/fetcher.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/fetcher.cpp 
b/src/slave/containerizer/fetcher.cpp
index f0b2503..34c4b5d 100644
--- a/src/slave/containerizer/fetcher.cpp
+++ b/src/slave/containerizer/fetcher.cpp
@@ -252,6 +252,12 @@ void Fetcher::kill(const ContainerID& containerId)
 }
 
 
+FetcherProcess::FetcherProcess(const Flags& _flags)
+    : ProcessBase(process::ID::generate("fetcher")),
+      flags(_flags),
+      cache(_flags.fetcher_cache_size) {}
+
+
 FetcherProcess::~FetcherProcess()
 {
   foreachkey (const ContainerID& containerId, subprocessPids) {
@@ -324,11 +330,6 @@ Future<Nothing> FetcherProcess::fetch(
   VLOG(1) << "Starting to fetch URIs for container: " << containerId
           << ", directory: " << sandboxDirectory;
 
-  // TODO(bernd-mesos): This will disappear once we inject flags at
-  // Fetcher/FetcherProcess creation time. For now we trust this is
-  // always the exact same value.
-  cache.setSpace(flags.fetcher_cache_size);
-
   Try<Nothing> validated = validateUris(commandInfo);
   if (validated.isError()) {
     return Failure("Could not fetch: " + validated.error());
@@ -1136,17 +1137,6 @@ size_t FetcherProcess::Cache::size() const
 }
 
 
-void FetcherProcess::Cache::setSpace(const Bytes& bytes)
-{
-  if (space > 0) {
-    // Dynamic cache size changes not supported.
-    CHECK_EQ(space, bytes);
-  } else {
-    space = bytes;
-  }
-}
-
-
 void FetcherProcess::Cache::claimSpace(const Bytes& bytes)
 {
   tally += bytes;

http://git-wip-us.apache.org/repos/asf/mesos/blob/6db493c0/src/slave/containerizer/fetcher.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/fetcher.hpp 
b/src/slave/containerizer/fetcher.hpp
index 7b51495..efc714f 100644
--- a/src/slave/containerizer/fetcher.hpp
+++ b/src/slave/containerizer/fetcher.hpp
@@ -109,10 +109,7 @@ private:
 class FetcherProcess : public process::Process<FetcherProcess>
 {
 public:
-  FetcherProcess(const Flags& _flags)
-    : ProcessBase(process::ID::generate("fetcher")),
-      flags(_flags) {}
-
+  explicit FetcherProcess(const Flags& _flags);
   virtual ~FetcherProcess();
 
   process::Future<Nothing> fetch(
@@ -204,7 +201,7 @@ public:
       process::Promise<Nothing> promise;
     };
 
-    Cache() : space(0), tally(0), filenameSerial(0) {}
+    explicit Cache(Bytes _space) : space(_space), tally(0), filenameSerial(0) 
{}
     virtual ~Cache() {}
 
     // Registers the maximum usable space in the cache directory.
@@ -264,7 +261,7 @@ public:
 
   private:
     // Maximum storable number of bytes in the cache directory.
-    Bytes space;
+    const Bytes space;
 
     // How much space has been reserved to be occupied by cache files.
     Bytes tally;

Reply via email to