You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mz...@apache.org on 2019/06/25 21:47:22 UTC
[mesos] 05/06: Replaced the old `struct Quota`.
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 5907a357180ccd8fe398f2b6638c85912fafe8b2
Author: Meng Zhu <mz...@mesosphere.io>
AuthorDate: Thu Jun 20 18:50:38 2019 -0700
Replaced the old `struct Quota`.
The new `struct Quota` is consistent with the proto `QuotaConfig`
where guarantees and limits are decoupled and uses more proper
abstractions: `ResourceQuantities` and `ResourceLimits`.
Review: https://reviews.apache.org/r/70919
---
include/mesos/allocator/allocator.hpp | 4 +-
include/mesos/quota/quota.hpp | 24 +++-------
src/common/http.cpp | 7 +++
src/master/allocator/mesos/allocator.hpp | 12 ++---
src/master/allocator/mesos/hierarchical.cpp | 8 ++--
src/master/allocator/mesos/hierarchical.hpp | 8 ++--
src/master/allocator/mesos/metrics.cpp | 2 +-
src/master/allocator/mesos/metrics.hpp | 2 +-
src/master/constants.hpp | 2 +-
src/master/master.cpp | 2 +-
src/master/master.hpp | 4 +-
src/master/quota.cpp | 10 ++--
src/master/quota_handler.cpp | 24 +++++-----
src/master/readonly_handler.cpp | 2 +-
src/tests/allocator.cpp | 4 +-
src/tests/allocator.hpp | 6 +--
src/tests/hierarchical_allocator_tests.cpp | 74 ++++++++++++++---------------
src/tests/master_quota_tests.cpp | 14 +++---
18 files changed, 103 insertions(+), 106 deletions(-)
diff --git a/include/mesos/allocator/allocator.hpp b/include/mesos/allocator/allocator.hpp
index 4f9e253..2bab53a 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, Quota2>& quotas) = 0;
+ const hashmap<std::string, Quota>& quotas) = 0;
/**
* Adds a framework to the Mesos cluster. The allocator is invoked when
@@ -424,7 +424,7 @@ public:
*/
virtual void updateQuota(
const std::string& role,
- const Quota2& quota) = 0;
+ const Quota& quota) = 0;
/**
* Updates the weight associated with one or more roles. If a role
diff --git a/include/mesos/quota/quota.hpp b/include/mesos/quota/quota.hpp
index edfd1c0..01311d3 100644
--- a/include/mesos/quota/quota.hpp
+++ b/include/mesos/quota/quota.hpp
@@ -22,31 +22,21 @@
// ONLY USEFUL AFTER RUNNING PROTOC.
#include <mesos/quota/quota.pb.h>
-// A C++ wrapper for `QuotaInfo` used to communicate between the
-// Allocator and Master.
-struct Quota
-{
- // Holds the quota protobuf, as constructed from an operator's request.
- mesos::quota::QuotaInfo info;
-};
-
-
namespace mesos {
-// TODO(mzhu): replace `struct Quota` above.
-struct Quota2
+struct Quota
{
ResourceQuantities guarantees;
ResourceLimits limits;
- Quota2() {};
+ Quota() {};
- Quota2(const mesos::quota::QuotaConfig& config);
- Quota2(const mesos::quota::QuotaInfo& info);
- Quota2(const mesos::quota::QuotaRequest& request);
+ Quota(const mesos::quota::QuotaConfig& config);
+ Quota(const mesos::quota::QuotaInfo& info);
+ Quota(const mesos::quota::QuotaRequest& request);
- bool operator==(const Quota2& quota) const;
- bool operator!=(const Quota2& quota) const;
+ bool operator==(const Quota& quota) const;
+ bool operator!=(const Quota& quota) const;
};
} // namespace mesos {
diff --git a/src/common/http.cpp b/src/common/http.cpp
index ae026f6..b79074f 100644
--- a/src/common/http.cpp
+++ b/src/common/http.cpp
@@ -871,6 +871,13 @@ static void json(JSON::StringWriter* writer, const Value::Text& text)
}
+void json(JSON::ObjectWriter* writer, const Quota& quota)
+{
+ writer->field("guarantees", quota.guarantees);
+ writer->field("limits", quota.limits);
+}
+
+
Future<Owned<ObjectApprovers>> ObjectApprovers::create(
const Option<Authorizer*>& authorizer,
const Option<Principal>& principal,
diff --git a/src/master/allocator/mesos/allocator.hpp b/src/master/allocator/mesos/allocator.hpp
index bedf558..6921581 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, Quota2>& quotas) override;
+ const hashmap<std::string, Quota>& quotas) override;
void addFramework(
const FrameworkID& frameworkId,
@@ -160,7 +160,7 @@ public:
void updateQuota(
const std::string& role,
- const Quota2& quota) override;
+ const Quota& quota) override;
void updateWeights(
const std::vector<WeightInfo>& weightInfos) override;
@@ -203,7 +203,7 @@ public:
virtual void recover(
const int expectedAgentCount,
- const hashmap<std::string, Quota2>& quotas) = 0;
+ const hashmap<std::string, Quota>& quotas) = 0;
virtual void addFramework(
const FrameworkID& frameworkId,
@@ -304,7 +304,7 @@ public:
virtual void updateQuota(
const std::string& role,
- const Quota2& quota) = 0;
+ const Quota& quota) = 0;
virtual void updateWeights(
const std::vector<WeightInfo>& weightInfos) = 0;
@@ -366,7 +366,7 @@ inline void MesosAllocator<AllocatorProcess>::initialize(
template <typename AllocatorProcess>
inline void MesosAllocator<AllocatorProcess>::recover(
const int expectedAgentCount,
- const hashmap<std::string, Quota2>& quotas)
+ const hashmap<std::string, Quota>& quotas)
{
process::dispatch(
process,
@@ -673,7 +673,7 @@ inline void MesosAllocator<AllocatorProcess>::reviveOffers(
template <typename AllocatorProcess>
inline void MesosAllocator<AllocatorProcess>::updateQuota(
const std::string& role,
- const Quota2& quota)
+ const Quota& quota)
{
process::dispatch(
process,
diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index c05b351..26aad67 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -254,7 +254,7 @@ void HierarchicalAllocatorProcess::initialize(
void HierarchicalAllocatorProcess::recover(
const int _expectedAgentCount,
- const hashmap<string, Quota2>& quotas)
+ const hashmap<string, Quota>& quotas)
{
// Recovery should start before actual allocation starts.
CHECK(initialized);
@@ -278,7 +278,7 @@ void HierarchicalAllocatorProcess::recover(
return;
}
- foreachpair (const string& role, const Quota2& quota, quotas) {
+ foreachpair (const string& role, const Quota& quota, quotas) {
updateQuota(role, quota);
}
@@ -1399,7 +1399,7 @@ void HierarchicalAllocatorProcess::reviveOffers(
void HierarchicalAllocatorProcess::updateQuota(
const string& role,
- const Quota2& quota)
+ const Quota& quota)
{
CHECK(initialized);
@@ -2503,7 +2503,7 @@ bool HierarchicalAllocatorProcess::isFrameworkTrackedUnderRole(
}
-const Quota2& HierarchicalAllocatorProcess::getQuota(const string& role) const
+const Quota& HierarchicalAllocatorProcess::getQuota(const string& role) const
{
auto it = roles.find(role);
diff --git a/src/master/allocator/mesos/hierarchical.hpp b/src/master/allocator/mesos/hierarchical.hpp
index 8468a88..7e97652 100644
--- a/src/master/allocator/mesos/hierarchical.hpp
+++ b/src/master/allocator/mesos/hierarchical.hpp
@@ -122,7 +122,7 @@ struct Role
// Configured guaranteed resource quantities and resource limits for
// this role. By default, a role has no guarantee and no limit.
- Quota2 quota;
+ Quota quota;
bool isEmpty() const
{
@@ -326,7 +326,7 @@ public:
void recover(
const int _expectedAgentCount,
- const hashmap<std::string, Quota2>& quotas) override;
+ const hashmap<std::string, Quota>& quotas) override;
void addFramework(
const FrameworkID& frameworkId,
@@ -427,7 +427,7 @@ public:
void updateQuota(
const std::string& role,
- const Quota2& quota) override;
+ const Quota& quota) override;
void updateWeights(
const std::vector<WeightInfo>& weightInfos) override;
@@ -622,7 +622,7 @@ private:
const FrameworkID& frameworkId,
const std::string& role) const;
- const Quota2& getQuota(const std::string& role) const;
+ const Quota& getQuota(const std::string& role) const;
void trackFrameworkUnderRole(
const FrameworkID& frameworkId,
diff --git a/src/master/allocator/mesos/metrics.cpp b/src/master/allocator/mesos/metrics.cpp
index 17ca99e..2d72757 100644
--- a/src/master/allocator/mesos/metrics.cpp
+++ b/src/master/allocator/mesos/metrics.cpp
@@ -130,7 +130,7 @@ Metrics::~Metrics()
// TODO(mzhu): This currently only updates quota guarantees.
// Add metrics for quota limits as well.
-void Metrics::updateQuota(const string& role, const Quota2& quota)
+void Metrics::updateQuota(const string& role, const Quota& quota)
{
// This is the "remove" case where the role's quota
// is set to the default.
diff --git a/src/master/allocator/mesos/metrics.hpp b/src/master/allocator/mesos/metrics.hpp
index e9174a1..fa2a5dc 100644
--- a/src/master/allocator/mesos/metrics.hpp
+++ b/src/master/allocator/mesos/metrics.hpp
@@ -48,7 +48,7 @@ struct Metrics
~Metrics();
- void updateQuota(const std::string& role, const Quota2& quota);
+ void updateQuota(const std::string& role, const Quota& quota);
void addRole(const std::string& role);
void removeRole(const std::string& role);
diff --git a/src/master/constants.hpp b/src/master/constants.hpp
index 8502240..26afa35 100644
--- a/src/master/constants.hpp
+++ b/src/master/constants.hpp
@@ -174,7 +174,7 @@ const Version MINIMUM_AGENT_VERSION = Version(1, 0, 0);
std::vector<MasterInfo::Capability> MASTER_CAPABILITIES();
// A role's default quota: no guarantees and no limits.
-const Quota2 DEFAULT_QUOTA;
+const Quota DEFAULT_QUOTA;
} // namespace master {
} // namespace internal {
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 163d774..826362d 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -1730,7 +1730,7 @@ Future<Nothing> Master::_recover(const Registry& registry)
// Save the quotas for each role.
foreach (const Registry::Quota& quota, registry.quotas()) {
- quotas[quota.info().role()] = Quota2{quota.info()};
+ quotas[quota.info().role()] = Quota{quota.info()};
}
// We notify the allocator via the `recover()` call. This has to be
diff --git a/src/master/master.hpp b/src/master/master.hpp
index c966a93..7acaa82 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -1243,7 +1243,7 @@ private:
// as well as reservations (both static and dynamic ones).
static Option<Error> overcommitCheck(
const std::vector<Resources>& agents,
- const hashmap<std::string, Quota2>& quotas,
+ const hashmap<std::string, Quota>& quotas,
const mesos::quota::QuotaInfo& request);
// We always want to rescind offers after the capacity heuristic. The
@@ -2239,7 +2239,7 @@ private:
// Configured quota for each role, if any. We store quotas by role
// because we set them at the role level.
- hashmap<std::string, Quota2> quotas;
+ hashmap<std::string, Quota> quotas;
// Authenticator names as supplied via flags.
std::vector<std::string> authenticatorNames;
diff --git a/src/master/quota.cpp b/src/master/quota.cpp
index 4f2a59c..a7ee845 100644
--- a/src/master/quota.cpp
+++ b/src/master/quota.cpp
@@ -239,14 +239,14 @@ Option<Error> validate(const QuotaConfig& config)
} // namespace master {
} // namespace internal {
-Quota2::Quota2(const QuotaConfig& config)
+Quota::Quota(const QuotaConfig& config)
{
guarantees = ResourceQuantities(config.guarantees());
limits = ResourceLimits(config.limits());
}
-Quota2::Quota2(const QuotaInfo& info)
+Quota::Quota(const QuotaInfo& info)
{
guarantees = ResourceQuantities::fromScalarResources(info.guarantee());
@@ -261,7 +261,7 @@ Quota2::Quota2(const QuotaInfo& info)
}
-Quota2::Quota2(const QuotaRequest& request)
+Quota::Quota(const QuotaRequest& request)
{
guarantees = ResourceQuantities::fromScalarResources(request.guarantee());
@@ -276,13 +276,13 @@ Quota2::Quota2(const QuotaRequest& request)
}
-bool Quota2::operator==(const Quota2& that) const
+bool Quota::operator==(const Quota& that) const
{
return guarantees == that.guarantees && limits == that.limits;
}
-bool Quota2::operator!=(const Quota2& that) const
+bool Quota::operator!=(const Quota& that) const
{
return guarantees != that.guarantees || limits != that.limits;
}
diff --git a/src/master/quota_handler.cpp b/src/master/quota_handler.cpp
index b5d2965..476e87e 100644
--- a/src/master/quota_handler.cpp
+++ b/src/master/quota_handler.cpp
@@ -91,15 +91,15 @@ namespace master {
class QuotaTree
{
public:
- QuotaTree(const hashmap<string, Quota2>& quotas)
+ QuotaTree(const hashmap<string, Quota>& quotas)
: root(new Node(""))
{
- foreachpair (const string& role, const Quota2& quota, quotas) {
+ foreachpair (const string& role, const Quota& quota, quotas) {
insert(role, quota);
}
}
- void insert(const string& role, const Quota2& quota)
+ void insert(const string& role, const Quota& quota)
{
// Create the path from root->leaf in the tree. Any missing nodes
// are created implicitly.
@@ -187,7 +187,7 @@ private:
}
const string name;
- Quota2 quota;
+ Quota quota;
hashmap<string, unique_ptr<Node>> children;
};
@@ -197,19 +197,19 @@ private:
Option<Error> Master::QuotaHandler::overcommitCheck(
const vector<Resources>& agents,
- const hashmap<string, Quota2>& quotas,
+ const hashmap<string, Quota>& quotas,
const QuotaInfo& request)
{
ResourceQuantities totalGuarantees = [&]() {
QuotaTree quotaTree({});
- foreachpair (const string& role, const Quota2& quota, quotas) {
+ foreachpair (const string& role, const Quota& quota, quotas) {
if (role != request.role()) {
quotaTree.insert(role, quota);
}
}
- quotaTree.insert(request.role(), Quota2{request});
+ quotaTree.insert(request.role(), Quota{request});
// Hard CHECK since this is already validated earlier
// during request validation.
@@ -370,7 +370,7 @@ Future<QuotaStatus> Master::QuotaHandler::_status(
vector<QuotaInfo> quotaInfos;
quotaInfos.reserve(master->quotas.size());
- foreachpair (const string& role, const Quota2& quota, master->quotas) {
+ foreachpair (const string& role, const Quota& quota, master->quotas) {
quotaInfos.push_back([&role, "a]() {
// Construct the legacy `QuotaInfo`.
//
@@ -564,13 +564,13 @@ Future<http::Response> Master::QuotaHandler::_set(
{
QuotaTree quotaTree({});
- foreachpair (const string& role, const Quota2& quota, master->quotas) {
+ foreachpair (const string& role, const Quota& quota, master->quotas) {
if (role != quotaInfo.role()) {
quotaTree.insert(role, quota);
}
}
- quotaTree.insert(quotaInfo.role(), Quota2{quotaInfo});
+ quotaTree.insert(quotaInfo.role(), Quota{quotaInfo});
Option<Error> error = quotaTree.validate();
if (error.isSome()) {
@@ -648,7 +648,7 @@ Future<http::Response> Master::QuotaHandler::__set(
}
}
- Quota2 quota = Quota2{quotaInfo};
+ Quota quota = Quota{quotaInfo};
// Populate master's quota-related local state. We do this before updating
// the registry in order to make sure that we are not already trying to
@@ -732,7 +732,7 @@ Future<http::Response> Master::QuotaHandler::remove(
"': Role '" + role + "' has no quota set");
}
- hashmap<string, Quota2> quotaMap = master->quotas;
+ hashmap<string, Quota> quotaMap = master->quotas;
// Validate that removing the quota for `role` does not violate the
// hierarchical relationship between quotas.
diff --git a/src/master/readonly_handler.cpp b/src/master/readonly_handler.cpp
index aa5be2c..0d1e3dc 100644
--- a/src/master/readonly_handler.cpp
+++ b/src/master/readonly_handler.cpp
@@ -724,7 +724,7 @@ process::http::Response Master::ReadOnlyHandler::roles(
//
// - We name the field using singular `guarantee` and `limit`
// which is different from the plural used in `QuotaConfig`.
- const Quota2& quota = master->quotas.at(name);
+ const Quota& quota = master->quotas.at(name);
writer->field("quota", [&](JSON::ObjectWriter* writer) {
writer->field("role", name);
writer->field("guarantee", quota.guarantees);
diff --git a/src/tests/allocator.cpp b/src/tests/allocator.cpp
index ccdf352..2a04fed 100644
--- a/src/tests/allocator.cpp
+++ b/src/tests/allocator.cpp
@@ -26,9 +26,9 @@ namespace tests {
// This is a legacy helper where we take in a resource string
// and use that to set both quota guarantees and limits.
-Quota2 createQuota(const string& role, const string& resources)
+Quota createQuota(const string& role, const string& resources)
{
- Quota2 quota;
+ Quota quota;
quota.guarantees = CHECK_NOTERROR(ResourceQuantities::fromString(resources));
quota.limits = CHECK_NOTERROR(ResourceLimits::fromString(resources));
diff --git a/src/tests/allocator.hpp b/src/tests/allocator.hpp
index 1ca85c5..346b822 100644
--- a/src/tests/allocator.hpp
+++ b/src/tests/allocator.hpp
@@ -41,7 +41,7 @@ namespace tests {
// Allocator test helpers.
-Quota2 createQuota(const std::string& role, const std::string& resources);
+Quota createQuota(const std::string& role, const std::string& resources);
WeightInfo createWeightInfo(const std::string& role, double weight);
@@ -400,7 +400,7 @@ public:
MOCK_METHOD2(recover, void(
const int expectedAgentCount,
- const hashmap<std::string, Quota2>&));
+ const hashmap<std::string, Quota>&));
MOCK_METHOD5(addFramework, void(
const FrameworkID&,
@@ -500,7 +500,7 @@ public:
MOCK_METHOD2(updateQuota, void(
const std::string&,
- const Quota2&));
+ const Quota&));
MOCK_METHOD1(updateWeights, void(
const std::vector<WeightInfo>&));
diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp
index e82966a..9ebeeb6 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -1303,7 +1303,7 @@ TEST_P(HierarchicalAllocatorTestWithReservations, ReservationUnallocated)
Resources reserved = Resources(agent1.resources()).reserved(QUOTA_ROLE);
// Set a quota for 1x agent resources.
- const Quota2 quota = createQuota(QUOTA_ROLE, "cpus:1;mem:1024");
+ const Quota quota = createQuota(QUOTA_ROLE, "cpus:1;mem:1024");
allocator->updateQuota(QUOTA_ROLE, quota);
// Create `framework1` and set quota for its role.
@@ -1382,7 +1382,7 @@ TEST_P(HierarchicalAllocatorTestWithReservations, ReservationAllocated)
Resources reserved = Resources(agent1.resources()).reserved(QUOTA_ROLE);
// Set a quota for 2x agent resources.
- const Quota2 quota = createQuota(QUOTA_ROLE, "cpus:2;mem:2048");
+ const Quota quota = createQuota(QUOTA_ROLE, "cpus:2;mem:2048");
allocator->updateQuota(QUOTA_ROLE, quota);
// Create `framework1` and set quota for its role.
@@ -1473,7 +1473,7 @@ TEST_P(HierarchicalAllocatorTestWithReservations,
agent1.resources(),
{});
- const Quota2 quota = createQuota(QUOTA_ROLE, "cpus:2;mem:2048");
+ const Quota quota = createQuota(QUOTA_ROLE, "cpus:2;mem:2048");
allocator->updateQuota(QUOTA_ROLE, quota);
// Create `framework1` and set quota to half the size of agent1' resources
@@ -1547,7 +1547,7 @@ TEST_P(HierarchicalAllocatorTestWithReservations,
initialize();
- const Quota2 quota = createQuota(QUOTA_ROLE, "cpus:3;mem:2048;disk:100");
+ const Quota quota = createQuota(QUOTA_ROLE, "cpus:3;mem:2048;disk:100");
allocator->updateQuota(QUOTA_ROLE, quota);
Resource::ReservationInfo reservation;
@@ -1693,7 +1693,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaAccountingReserveAllocatedResources)
// Create `framework` and set quota for its role.
- const Quota2 quota = createQuota(QUOTA_ROLE, "cpus:10;mem:1024");
+ const Quota quota = createQuota(QUOTA_ROLE, "cpus:10;mem:1024");
allocator->updateQuota(QUOTA_ROLE, quota);
FrameworkInfo framework = createFrameworkInfo({QUOTA_ROLE});
@@ -1758,7 +1758,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaAccountingUnreserveAllocatedResources)
// Create `framework` and set quota for its role.
- const Quota2 quota = createQuota("quota-role", "cpus:1;mem:1024");
+ const Quota quota = createQuota("quota-role", "cpus:1;mem:1024");
allocator->updateQuota("quota-role", quota);
FrameworkInfo framework = createFrameworkInfo({"quota-role"});
@@ -1909,11 +1909,11 @@ TEST_P(HierarchicalAllocatorTestWithReservations,
const string QUOTA_ROLE_NO_RESERVATION{"quota-role-no-reservation"};
const string NON_QUOTA_ROLE{"non-quota-role"};
- const Quota2 quota1 =
+ const Quota quota1 =
createQuota(QUOTA_ROLE_W_RESERVATION, "cpus:1;mem:1024");
allocator->updateQuota(QUOTA_ROLE_W_RESERVATION, quota1);
- const Quota2 quota2 =
+ const Quota quota2 =
createQuota(QUOTA_ROLE_NO_RESERVATION, "cpus:1;mem:1024");
allocator->updateQuota(QUOTA_ROLE_NO_RESERVATION, quota2);
@@ -3434,7 +3434,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaProvidesGuarantee)
FrameworkInfo framework1 = createFrameworkInfo({QUOTA_ROLE});
allocator->addFramework(framework1.id(), framework1, {}, true, {});
- const Quota2 quota = createQuota(QUOTA_ROLE, "cpus:2;mem:1024");
+ const Quota quota = createQuota(QUOTA_ROLE, "cpus:2;mem:1024");
allocator->updateQuota(QUOTA_ROLE, quota);
// Create `framework2` in a non-quota'ed role.
@@ -3558,7 +3558,7 @@ TEST_F(HierarchicalAllocatorTest, RemoveQuota)
initialize();
- const Quota2 quota = createQuota(QUOTA_ROLE, "cpus:2;mem:1024");
+ const Quota quota = createQuota(QUOTA_ROLE, "cpus:2;mem:1024");
allocator->updateQuota(QUOTA_ROLE, quota);
FrameworkInfo framework1 = createFrameworkInfo({QUOTA_ROLE});
@@ -3662,7 +3662,7 @@ TEST_F(HierarchicalAllocatorTest, MultipleFrameworksInRoleWithQuota)
FrameworkInfo framework1a = createFrameworkInfo({QUOTA_ROLE});
allocator->addFramework(framework1a.id(), framework1a, {}, true, {});
- const Quota2 quota = createQuota(QUOTA_ROLE, "cpus:4;mem:2048");
+ const Quota quota = createQuota(QUOTA_ROLE, "cpus:4;mem:2048");
allocator->updateQuota(QUOTA_ROLE, quota);
// Create `framework2` in a non-quota'ed role.
@@ -3799,7 +3799,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaAllocationGranularity)
// Set quota to be less than the agent resources.
const string quotaResourcesString = "cpus:0.5;mem:200";
- const Quota2 quota = createQuota(QUOTA_ROLE, quotaResourcesString);
+ const Quota quota = createQuota(QUOTA_ROLE, quotaResourcesString);
allocator->updateQuota(QUOTA_ROLE, quota);
SlaveInfo agent = createSlaveInfo("cpus:1;mem:512;disk:0");
@@ -3856,7 +3856,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaAllocationGranularityUnchoppableResource)
const string QUOTA_ROLE{"quota-role"};
const string quotaResourcesString = "cpus:2;mem:2048;disk:150";
- const Quota2 quota = createQuota(QUOTA_ROLE, quotaResourcesString);
+ const Quota quota = createQuota(QUOTA_ROLE, quotaResourcesString);
allocator->updateQuota(QUOTA_ROLE, quota);
// Create 100 disk resource of type MOUNT.
@@ -3963,7 +3963,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaAllocationMultipleDisk)
const string QUOTA_ROLE{"quota-role"};
- const Quota2 quota = createQuota(QUOTA_ROLE, "cpus:1;mem:512;disk:100");
+ const Quota quota = createQuota(QUOTA_ROLE, "cpus:1;mem:512;disk:100");
allocator->updateQuota(QUOTA_ROLE, quota);
// Create 50 disk resource of type `MOUNT`.
@@ -4015,7 +4015,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaRoleAllocateNonQuotaResource)
const string QUOTA_ROLE_1{"quota-role-1"};
const string quotaResourcesString1 = "cpus:2";
- const Quota2 quota1 = createQuota(QUOTA_ROLE_1, quotaResourcesString1);
+ const Quota quota1 = createQuota(QUOTA_ROLE_1, quotaResourcesString1);
allocator->updateQuota(QUOTA_ROLE_1, quota1);
SlaveInfo agent1 = createSlaveInfo("cpus:1;mem:1024;ports:[31000-32000]");
@@ -4053,7 +4053,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaRoleAllocateNonQuotaResource)
const string QUOTA_ROLE_2{"quota-role-2"};
const string quotaResourcesString2 = "mem:1024";
- const Quota2 quota2 = createQuota(QUOTA_ROLE_2, quotaResourcesString2);
+ const Quota quota2 = createQuota(QUOTA_ROLE_2, quotaResourcesString2);
allocator->updateQuota(QUOTA_ROLE_2, quota2);
// Add `agent2` with identical resources.
@@ -4135,7 +4135,7 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(HierarchicalAllocatorTest, DRFWithQuota)
initialize();
const string quotaResourcesString = "cpus:0.25;mem:128";
- const Quota2 quota = createQuota(QUOTA_ROLE, quotaResourcesString);
+ const Quota quota = createQuota(QUOTA_ROLE, quotaResourcesString);
allocator->updateQuota(QUOTA_ROLE, quota);
FrameworkInfo framework1 = createFrameworkInfo({QUOTA_ROLE});
@@ -4350,7 +4350,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaAgainstStarvation)
filter0s);
// We set quota for the "starving" `QUOTA_ROLE` role.
- const Quota2 quota = createQuota(QUOTA_ROLE, "cpus:2;mem:1024");
+ const Quota quota = createQuota(QUOTA_ROLE, "cpus:2;mem:1024");
allocator->updateQuota(QUOTA_ROLE, quota);
// Since `QUOTA_ROLE` is under quota, `agent2`'s resources will
@@ -4394,7 +4394,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaAbsentFrameworkWholeAgent)
// Set quota for the quota'ed role. This role isn't registered with
// the allocator yet.
- const Quota2 quota = createQuota(QUOTA_ROLE, "cpus:2;mem:1024");
+ const Quota quota = createQuota(QUOTA_ROLE, "cpus:2;mem:1024");
allocator->updateQuota(QUOTA_ROLE, quota);
// Add `framework` in the non-quota'ed role.
@@ -4486,10 +4486,10 @@ TEST_F(HierarchicalAllocatorTest, MultiQuotaAbsentFrameworks)
{});
// Set quota for both roles.
- const Quota2 quota1 = createQuota(QUOTA_ROLE1, "cpus:1;mem:1024");
+ const Quota quota1 = createQuota(QUOTA_ROLE1, "cpus:1;mem:1024");
allocator->updateQuota(QUOTA_ROLE1, quota1);
- const Quota2 quota2 = createQuota(QUOTA_ROLE2, "cpus:2;mem:2048");
+ const Quota quota2 = createQuota(QUOTA_ROLE2, "cpus:2;mem:2048");
allocator->updateQuota(QUOTA_ROLE2, quota2);
// Add a framework in the `QUOTA_ROLE2` role.
@@ -4526,11 +4526,11 @@ TEST_F(HierarchicalAllocatorTest, MultiQuotaWithFrameworks)
// Mem Quota for `QUOTA_ROLE1` is 10 times smaller than for `QUOTA_ROLE2`.
const string quotaResourcesString1 = "cpus:1;mem:200";
- const Quota2 quota1 = createQuota(QUOTA_ROLE1, quotaResourcesString1);
+ const Quota quota1 = createQuota(QUOTA_ROLE1, quotaResourcesString1);
allocator->updateQuota(QUOTA_ROLE1, quota1);
const string quotaResourcesString2 = "cpus:2;mem:2000";
- const Quota2 quota2 = createQuota(QUOTA_ROLE2, quotaResourcesString2);
+ const Quota quota2 = createQuota(QUOTA_ROLE2, quotaResourcesString2);
allocator->updateQuota(QUOTA_ROLE2, quota2);
// Add `framework1` in the `QUOTA_ROLE1` role.
@@ -4616,7 +4616,7 @@ TEST_F(HierarchicalAllocatorTest, ReservationWithinQuota)
initialize();
- const Quota2 quota = createQuota(QUOTA_ROLE, "cpus:2;mem:256");
+ const Quota quota = createQuota(QUOTA_ROLE, "cpus:2;mem:256");
allocator->updateQuota(QUOTA_ROLE, quota);
FrameworkInfo framework1 = createFrameworkInfo({QUOTA_ROLE});
@@ -4727,7 +4727,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaSetAsideReservedResources)
allocator->addFramework(framework1.id(), framework1, {}, true, {});
const string quotaResourcesString = "cpus:4;mem:512";
- const Quota2 quota = createQuota(QUOTA_ROLE, quotaResourcesString);
+ const Quota quota = createQuota(QUOTA_ROLE, quotaResourcesString);
allocator->updateQuota(QUOTA_ROLE, quota);
// `framework1` will be offered resources at `agent1` up to its quota limit
@@ -5955,7 +5955,7 @@ TEST_F(HierarchicalAllocatorTest, DisproportionateQuotaVsAllocation)
const string agentResources = "cpus:2;mem:1024";
const string quotaResources = "cpus:4;mem:1024";
- Quota2 quota = createQuota(QUOTA_ROLE, quotaResources);
+ Quota quota = createQuota(QUOTA_ROLE, quotaResources);
allocator->updateQuota(QUOTA_ROLE, quota);
// Register `framework` under `QUOTA_ROLE`.
@@ -6079,7 +6079,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaWithAncestorReservations)
const string PARENT_ROLE{"a"};
const string CHILD_ROLE{"a/b"};
- Quota2 quota = createQuota(QUOTA_ROLE, "cpus:1;mem:1024");
+ Quota quota = createQuota(QUOTA_ROLE, "cpus:1;mem:1024");
allocator->updateQuota(QUOTA_ROLE, quota);
// This agent is reserved for the parent role `a`.
@@ -6188,7 +6188,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaWithNestedRoleReservation)
const string PARENT_ROLE{"a"};
const string CHILD_ROLE{"a/b"};
- Quota2 quota = createQuota(PARENT_ROLE, "cpus:2;mem:200");
+ Quota quota = createQuota(PARENT_ROLE, "cpus:2;mem:200");
allocator->updateQuota(PARENT_ROLE, quota);
// This agent is reserved for the child role "a/b".
@@ -6281,7 +6281,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaWithNestedRoleAllocation)
AWAIT_EXPECT_EQ(expected, allocations.get());
- Quota2 quota = createQuota(PARENT_ROLE, "cpus:1;mem:1024");
+ Quota quota = createQuota(PARENT_ROLE, "cpus:1;mem:1024");
allocator->updateQuota(PARENT_ROLE, quota);
// --- TEST ---
@@ -6373,7 +6373,7 @@ TEST_F(HierarchicalAllocatorTest, QuotaHeadroomWithNestedRoleAllocation)
const string QUOTA_ROLE{"quota-role"};
- Quota2 quota = createQuota(QUOTA_ROLE, "cpus:1;mem:100");
+ Quota quota = createQuota(QUOTA_ROLE, "cpus:1;mem:100");
allocator->updateQuota(QUOTA_ROLE, quota);
SlaveInfo agent3 = createSlaveInfo("cpus:1;mem:100");
@@ -6428,7 +6428,7 @@ TEST_F(HierarchicalAllocatorTest, DISABLED_NestedRoleQuota)
FrameworkInfo framework1 = createFrameworkInfo({PARENT_ROLE});
allocator->addFramework(framework1.id(), framework1, {}, true, {});
- const Quota2 parentQuota = createQuota(PARENT_ROLE, "cpus:2;mem:1024");
+ const Quota parentQuota = createQuota(PARENT_ROLE, "cpus:2;mem:1024");
allocator->updateQuota(PARENT_ROLE, parentQuota);
SlaveInfo agent = createSlaveInfo("cpus:1;mem:512");
@@ -6478,7 +6478,7 @@ TEST_F(HierarchicalAllocatorTest, DISABLED_NestedRoleQuota)
EXPECT_TRUE(allocation.isPending());
// Set quota for `CHILD_ROLE2`.
- const Quota2 childQuota = createQuota(CHILD_ROLE2, "cpus:1;mem:512");
+ const Quota childQuota = createQuota(CHILD_ROLE2, "cpus:1;mem:512");
allocator->updateQuota(CHILD_ROLE2, childQuota);
// Create `framework3` in CHILD_ROLE2, which is a child role of
@@ -6516,7 +6516,7 @@ TEST_F(HierarchicalAllocatorTest, DISABLED_NestedRoleQuotaAllocateToParent)
const string CHILD_ROLE = "a/b/c";
// Set quota for parent role.
- const Quota2 parentQuota = createQuota(PARENT_ROLE, "cpus:4;mem:2048");
+ const Quota parentQuota = createQuota(PARENT_ROLE, "cpus:4;mem:2048");
allocator->updateQuota(PARENT_ROLE, parentQuota);
// Create `framework1` in the parent role.
@@ -6545,7 +6545,7 @@ TEST_F(HierarchicalAllocatorTest, DISABLED_NestedRoleQuotaAllocateToParent)
FrameworkInfo framework2 = createFrameworkInfo({CHILD_ROLE});
allocator->addFramework(framework2.id(), framework2, {}, true, {});
- const Quota2 childQuota = createQuota(CHILD_ROLE, "cpus:1;mem:512");
+ const Quota childQuota = createQuota(CHILD_ROLE, "cpus:1;mem:512");
allocator->updateQuota(CHILD_ROLE, childQuota);
SlaveInfo agent2 = createSlaveInfo("cpus:1;mem:512");
@@ -6614,7 +6614,7 @@ TEST_F(HierarchicalAllocatorTest, DISABLED_NestedQuotaAccounting)
allocator->addFramework(framework1.id(), framework1, {}, true, {});
// Set quota for parent role.
- const Quota2 parentQuota = createQuota(PARENT_ROLE, "cpus:3;mem:300");
+ const Quota parentQuota = createQuota(PARENT_ROLE, "cpus:3;mem:300");
allocator->updateQuota(PARENT_ROLE, parentQuota);
// Create `framework2` in the parent role.
@@ -6640,7 +6640,7 @@ TEST_F(HierarchicalAllocatorTest, DISABLED_NestedQuotaAccounting)
}
// Set quota for child role.
- const Quota2 childQuota = createQuota(CHILD_ROLE, "cpus:1;mem:100");
+ const Quota childQuota = createQuota(CHILD_ROLE, "cpus:1;mem:100");
allocator->updateQuota(CHILD_ROLE, childQuota);
// Create `framework3` in the child role.
@@ -6724,7 +6724,7 @@ TEST_P(HierarchicalAllocatorTestWithParam, AllocateSharedResources)
if (GetParam()) {
// Assign a quota.
- const Quota2 quota = createQuota("role1", "cpus:8;mem:2048;disk:4096");
+ const Quota quota = createQuota("role1", "cpus:8;mem:2048;disk:4096");
allocator->updateQuota("role1", quota);
}
diff --git a/src/tests/master_quota_tests.cpp b/src/tests/master_quota_tests.cpp
index 9b4cde1..4b805e9 100644
--- a/src/tests/master_quota_tests.cpp
+++ b/src/tests/master_quota_tests.cpp
@@ -839,7 +839,7 @@ TEST_F(MasterQuotaTest, AvailableResourcesSingleAgent)
EXPECT_TRUE(agentTotalResources->contains(quotaResources));
// Send a quota request for the specified role.
- Future<Quota2> receivedQuotaRequest;
+ Future<Quota> receivedQuotaRequest;
EXPECT_CALL(allocator, updateQuota(Eq(ROLE1), _))
.WillOnce(DoAll(InvokeUpdateQuota(&allocator),
FutureArg<1>(&receivedQuotaRequest)));
@@ -894,7 +894,7 @@ TEST_F(MasterQuotaTest, AvailableResourcesSingleReservedAgent)
Resources quotaResources = Resources::parse("cpus:1;mem:512").get();
// Send a quota request for the specified role.
- Future<Quota2> receivedQuotaRequest;
+ Future<Quota> receivedQuotaRequest;
EXPECT_CALL(allocator, updateQuota(Eq(ROLE1), _))
.WillOnce(DoAll(InvokeUpdateQuota(&allocator),
FutureArg<1>(&receivedQuotaRequest)));
@@ -961,7 +961,7 @@ TEST_F(MasterQuotaTest, AvailableResourcesSingleDisconnectedAgent)
EXPECT_TRUE(agentTotalResources->contains(quotaResources));
// Send a quota request for the specified role.
- Future<Quota2> receivedQuotaRequest;
+ Future<Quota> receivedQuotaRequest;
EXPECT_CALL(allocator, updateQuota(Eq(ROLE1), _))
.WillOnce(DoAll(InvokeUpdateQuota(&allocator),
FutureArg<1>(&receivedQuotaRequest)));
@@ -1030,7 +1030,7 @@ TEST_F(MasterQuotaTest, AvailableResourcesMultipleAgents)
});
// Send a quota request for the specified role.
- Future<Quota2> receivedQuotaRequest;
+ Future<Quota> receivedQuotaRequest;
EXPECT_CALL(allocator, updateQuota(Eq(ROLE1), _))
.WillOnce(DoAll(InvokeUpdateQuota(&allocator),
FutureArg<1>(&receivedQuotaRequest)));
@@ -1190,7 +1190,7 @@ TEST_F(MasterQuotaTest, AvailableResourcesAfterRescinding)
.WillRepeatedly(Return());
// Send a quota request for the specified role.
- Future<Quota2> receivedQuotaRequest;
+ Future<Quota> receivedQuotaRequest;
EXPECT_CALL(allocator, updateQuota(Eq(ROLE2), _))
.WillOnce(DoAll(InvokeUpdateQuota(&allocator),
FutureArg<1>(&receivedQuotaRequest)));
@@ -1348,7 +1348,7 @@ TEST_F(MasterQuotaTest, NoAuthenticationNoAuthorization)
{
Resources quotaResources = Resources::parse("cpus:1;mem:512").get();
- Future<Quota2> receivedSetRequest;
+ Future<Quota> receivedSetRequest;
EXPECT_CALL(allocator, updateQuota(Eq(ROLE1), _))
.WillOnce(DoAll(InvokeUpdateQuota(&allocator),
FutureArg<1>(&receivedSetRequest)));
@@ -1490,7 +1490,7 @@ TEST_F(MasterQuotaTest, AuthorizeGetUpdateQuotaRequests)
// request below to override the capacity heuristic check.
Resources quotaResources = Resources::parse("cpus:1;mem:512").get();
- Future<Quota2> quota;
+ Future<Quota> quota;
EXPECT_CALL(allocator, updateQuota(Eq(ROLE1), _))
.WillOnce(DoAll(InvokeUpdateQuota(&allocator),
FutureArg<1>("a)));