This is an automated email from the ASF dual-hosted git repository.

mzhu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit ceb1120e8c53771219363e0bf579a770b914a592
Author: Meng Zhu <[email protected]>
AuthorDate: Thu Jun 6 16:18:45 2019 -0700

    Used the new quota struct for the allocator recover call.
    
    Review: https://reviews.apache.org/r/70804
---
 include/mesos/allocator/allocator.hpp       | 2 +-
 src/master/allocator/mesos/allocator.hpp    | 6 +++---
 src/master/allocator/mesos/hierarchical.cpp | 6 +++---
 src/master/allocator/mesos/hierarchical.hpp | 2 +-
 src/master/master.cpp                       | 8 +++++++-
 src/tests/allocator.hpp                     | 2 +-
 6 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/include/mesos/allocator/allocator.hpp 
b/include/mesos/allocator/allocator.hpp
index a01775b..0aef003 100644
--- a/include/mesos/allocator/allocator.hpp
+++ b/include/mesos/allocator/allocator.hpp
@@ -141,7 +141,7 @@ public:
    */
   virtual void recover(
       const int expectedAgentCount,
-      const hashmap<std::string, Quota>& quotas) = 0;
+      const hashmap<std::string, Quota2>& quotas) = 0;
 
   /**
    * Adds a framework to the Mesos cluster. The allocator is invoked when
diff --git a/src/master/allocator/mesos/allocator.hpp 
b/src/master/allocator/mesos/allocator.hpp
index 3c04b4f..0ae7e36 100644
--- a/src/master/allocator/mesos/allocator.hpp
+++ b/src/master/allocator/mesos/allocator.hpp
@@ -59,7 +59,7 @@ public:
 
   void recover(
       const int expectedAgentCount,
-      const hashmap<std::string, Quota>& quotas) override;
+      const hashmap<std::string, Quota2>& quotas) override;
 
   void addFramework(
       const FrameworkID& frameworkId,
@@ -210,7 +210,7 @@ public:
 
   virtual void recover(
       const int expectedAgentCount,
-      const hashmap<std::string, Quota>& quotas) = 0;
+      const hashmap<std::string, Quota2>& quotas) = 0;
 
   virtual void addFramework(
       const FrameworkID& frameworkId,
@@ -380,7 +380,7 @@ inline void MesosAllocator<AllocatorProcess>::initialize(
 template <typename AllocatorProcess>
 inline void MesosAllocator<AllocatorProcess>::recover(
     const int expectedAgentCount,
-    const hashmap<std::string, Quota>& quotas)
+    const hashmap<std::string, Quota2>& quotas)
 {
   process::dispatch(
       process,
diff --git a/src/master/allocator/mesos/hierarchical.cpp 
b/src/master/allocator/mesos/hierarchical.cpp
index 50a4982..0d8b0ca 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -225,7 +225,7 @@ void HierarchicalAllocatorProcess::initialize(
 
 void HierarchicalAllocatorProcess::recover(
     const int _expectedAgentCount,
-    const hashmap<string, Quota>& quotas)
+    const hashmap<string, Quota2>& quotas)
 {
   // Recovery should start before actual allocation starts.
   CHECK(initialized);
@@ -249,8 +249,8 @@ void HierarchicalAllocatorProcess::recover(
     return;
   }
 
-  foreachpair (const string& role, const Quota& quota, quotas) {
-    setQuota(role, quota);
+  foreachpair (const string& role, const Quota2& quota, quotas) {
+    updateQuota(role, quota);
   }
 
   // TODO(alexr): Consider exposing these constants.
diff --git a/src/master/allocator/mesos/hierarchical.hpp 
b/src/master/allocator/mesos/hierarchical.hpp
index 93555f6..25472eb 100644
--- a/src/master/allocator/mesos/hierarchical.hpp
+++ b/src/master/allocator/mesos/hierarchical.hpp
@@ -323,7 +323,7 @@ public:
 
   void recover(
       const int _expectedAgentCount,
-      const hashmap<std::string, Quota>& quotas) override;
+      const hashmap<std::string, Quota2>& quotas) override;
 
   void addFramework(
       const FrameworkID& frameworkId,
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 2b4e51d..8a238aa 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -1740,7 +1740,13 @@ Future<Nothing> Master::_recover(const Registry& 
registry)
   // allocations. An allocator may decide to hold off with allocation
   // until after it restores a view of the cluster state.
   int expectedAgentCount = registry.slaves().slaves().size();
-  allocator->recover(expectedAgentCount, quotas);
+
+  // TODO(mzhu): Remove this conversion once we replace `Quota` with `Quota2`.
+  hashmap<string, Quota2> quota2s;
+  foreachpair (const string& role, const Quota& quota, quotas) {
+    quota2s[role] = Quota2{quota.info};
+  }
+  allocator->recover(expectedAgentCount, quota2s);
 
   // TODO(alexr): Consider adding a sanity check: whether quotas are
   // satisfiable given all recovering agents reregister. We may want
diff --git a/src/tests/allocator.hpp b/src/tests/allocator.hpp
index bc6e3a9..765968d 100644
--- a/src/tests/allocator.hpp
+++ b/src/tests/allocator.hpp
@@ -422,7 +422,7 @@ public:
 
   MOCK_METHOD2(recover, void(
       const int expectedAgentCount,
-      const hashmap<std::string, Quota>&));
+      const hashmap<std::string, Quota2>&));
 
   MOCK_METHOD5(addFramework, void(
       const FrameworkID&,

Reply via email to