Repository: mesos Updated Branches: refs/heads/master 119c6d46b -> 86e635b9f
Made additional Fetcher and FetcherProcess methods const. Review: https://reviews.apache.org/r/59854/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/34a31f00 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/34a31f00 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/34a31f00 Branch: refs/heads/master Commit: 34a31f002fd69fa21f0598443d9288b0556746f4 Parents: 119c6d4 Author: James Peach <[email protected]> Authored: Wed Jun 21 11:44:23 2017 -0700 Committer: Joseph Wu <[email protected]> Committed: Wed Jun 21 11:44:23 2017 -0700 ---------------------------------------------------------------------- src/slave/containerizer/fetcher.cpp | 17 +++++++++-------- src/slave/containerizer/fetcher.hpp | 21 +++++++++++---------- 2 files changed, 20 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/34a31f00/src/slave/containerizer/fetcher.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/fetcher.cpp b/src/slave/containerizer/fetcher.cpp index 770cad3..f0b2503 100644 --- a/src/slave/containerizer/fetcher.cpp +++ b/src/slave/containerizer/fetcher.cpp @@ -597,7 +597,7 @@ static off_t delta( // For testing only. -Try<list<Path>> FetcherProcess::cacheFiles() +Try<list<Path>> FetcherProcess::cacheFiles() const { list<Path> result; @@ -623,13 +623,13 @@ Try<list<Path>> FetcherProcess::cacheFiles() // For testing only. -size_t FetcherProcess::cacheSize() +size_t FetcherProcess::cacheSize() const { return cache.size(); } -Bytes FetcherProcess::availableCacheSpace() +Bytes FetcherProcess::availableCacheSpace() const { return cache.availableSpace(); } @@ -964,14 +964,15 @@ FetcherProcess::Cache::get( bool FetcherProcess::Cache::contains( const Option<string>& user, - const string& uri) + const string& uri) const { const string key = cacheKey(user, uri); return table.get(key).isSome(); } -bool FetcherProcess::Cache::contains(const shared_ptr<Cache::Entry>& entry) +bool FetcherProcess::Cache::contains( + const shared_ptr<Cache::Entry>& entry) const { Option<shared_ptr<Cache::Entry>> found = table.get(entry->key); if (found.isNone()) { @@ -1129,7 +1130,7 @@ Try<Nothing> FetcherProcess::Cache::adjust( } -size_t FetcherProcess::Cache::size() +size_t FetcherProcess::Cache::size() const { return table.size(); } @@ -1175,7 +1176,7 @@ void FetcherProcess::Cache::releaseSpace(const Bytes& bytes) } -Bytes FetcherProcess::Cache::availableSpace() +Bytes FetcherProcess::Cache::availableSpace() const { if (tally > space) { LOG(WARNING) << "Fetcher cache space overflow - space used: " << tally @@ -1223,7 +1224,7 @@ void FetcherProcess::Cache::Entry::unreference() } -bool FetcherProcess::Cache::Entry::isReferenced() +bool FetcherProcess::Cache::Entry::isReferenced() const { return referenceCount > 0; } http://git-wip-us.apache.org/repos/asf/mesos/blob/34a31f00/src/slave/containerizer/fetcher.hpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/fetcher.hpp b/src/slave/containerizer/fetcher.hpp index efeadbf..7b51495 100644 --- a/src/slave/containerizer/fetcher.hpp +++ b/src/slave/containerizer/fetcher.hpp @@ -171,12 +171,12 @@ public: // cache. void reference(); void unreference(); - bool isReferenced(); + bool isReferenced() const; // Returns the path in the filesystem where cache entry resides. // TODO(bernd-mesos): Remove this construct after refactoring so // that the slave flags get injected into the fetcher. - Path path() { return Path(path::join(directory, filename)); } + Path path() const { return Path(path::join(directory, filename)); } // Uniquely identifies a user/URI combination. const std::string key; @@ -214,7 +214,7 @@ public: void claimSpace(const Bytes& bytes); void releaseSpace(const Bytes& bytes); - Bytes availableSpace(); + Bytes availableSpace() const; // Invents a new, distinct base name for a cache file, using the same // filename extension as the URI. @@ -234,10 +234,11 @@ public: const std::string& uri); // Returns whether an entry for this user and URI is in the cache. - bool contains(const Option<std::string>& user, const std::string& uri); + bool contains( + const Option<std::string>& user, const std::string& uri) const; // Returns whether this identical entry is in the cache. - bool contains(const std::shared_ptr<Cache::Entry>& entry); + bool contains(const std::shared_ptr<Cache::Entry>& entry) const; // Completely deletes a cache entry and its file. Warns on failure. // Virtual for mock testing. @@ -259,7 +260,7 @@ public: Try<Nothing> adjust(const std::shared_ptr<Cache::Entry>& entry); // Number of entries. - size_t size(); + size_t size() const; private: // Maximum storable number of bytes in the cache directory. @@ -292,15 +293,15 @@ public: // Returns a list of cache files on disk for the given slave // (for all users combined). For testing. - Try<std::list<Path>> cacheFiles(); + Try<std::list<Path>> cacheFiles() const; // Returns the number of cache entries for the given slave (for all // users combined). For testing. - size_t cacheSize(); + size_t cacheSize() const; // Returns the amount of remaining cache space that is not occupied // by cache entries. For testing. - Bytes availableCacheSpace(); + Bytes availableCacheSpace() const; private: process::Future<Nothing> __fetch( @@ -318,7 +319,7 @@ private: const Try<Bytes>& requestedSpace, const std::shared_ptr<Cache::Entry>& entry); - Flags flags; + const Flags flags; Cache cache;
