-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/57167/#review168318
-----------------------------------------------------------




src/master/quota_handler.cpp
Lines 70 (patched)
<https://reviews.apache.org/r/57167/#comment240536>

    What do you think of introducing a `QuotaTree` with which we can 
encapsulate all this stuff?
    
    Something like:
    
    ```cpp
    class QuotaTree {
      QuotaTree() = default;
    
      Try<Nothing> insert(const string& role, const Quota& quota) const {
        // basically the body of `foreachpair` in `buildQuotaTree` + validation.
      }
      
      Resources total() const;
    
      private:
      
      class Node { ... };
      
      unique_ptr<Node> root;
    };
    
    Try<QuotaTree> buildQuotaTree(const hashmap<string, Quota>& quotas)
    {
      QuotaTree result;
    
      foreachpair (cons string& role, const Quota& quota, quotas) {
        Try<Nothing> insert = result.insert(role, quota);
        if (insert.isError()) {
          return Error("Failed to build quota tree" + insert.error());
        }
      }
    
      return result;
    }
    ```
    
    This way we could also keep a running `quotaTree` rather than a `quotaMap` 
and rebuilding the `quotaTree` when we need it. Perhaps a minor point. Even if 
we want to simply keep what we have in this patch, I think having a:
    
    ```cpp
    class QuotaTree {
      QuotaTree(const hashmap<string, Quota>&);
      Option<Error> validate() const;
      Resources total() const;
      
      // private stuff...
    };
    ```
    
    could simplify the usage a little bit.



src/master/quota_handler.cpp
Lines 78 (patched)
<https://reviews.apache.org/r/57167/#comment240532>

    The general pattern for `validate` I think is to return an `Option<Error>`. 
In this case, we could more accurately report what/where the invalid 
relationship is within the tree.



src/master/quota_handler.cpp
Lines 87-89 (patched)
<https://reviews.apache.org/r/57167/#comment240533>

    We can just use the `Resources` implicit constructor here.
    ```cpp
    childResources += child->quota.info.guarantee()
    ```



src/master/quota_handler.cpp
Lines 92-95 (patched)
<https://reviews.apache.org/r/57167/#comment240534>

    Ditto.
    ```cpp
    selfResources = quota.info.guarantee()
    ```



src/master/quota_handler.cpp
Lines 102 (patched)
<https://reviews.apache.org/r/57167/#comment240535>

    Is `quotas` meant to be taken by value here?


- Michael Park


On Feb. 28, 2017, 12:23 p.m., Neil Conway wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/57167/
> -----------------------------------------------------------
> 
> (Updated Feb. 28, 2017, 12:23 p.m.)
> 
> 
> Review request for mesos and Michael Park.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> The quota'd resources for a nested role are "included" within the
> quota'd resources for that role's parent. Hence, the quota of a node
> must always be greater than or equal to the sum of the quota'd resources
> of that role's children.
> 
> When creating and removing quota, we must ensure that this invariant is
> not violated.
> 
> When computing the cluster capacity heuristic, we must ensure that we do
> not "double-count" quota'd resources: e.g., if the cluster has a total
> capacity of 100 cpus, role "x" has a quota guarantee of 60 CPUs, and
> role "x/y" has a quota guarantee of 55 CPUs, this does NOT violate the
> cluster capacity heuristic.
> 
> 
> Diffs
> -----
> 
>   src/master/quota_handler.cpp 3ad28e4a9363a877d0610b529a6c17fb30ece37a 
>   src/tests/hierarchical_allocator_tests.cpp 
> cdf1f15b7802439b28405ca8f6634ce83e886630 
>   src/tests/master_quota_tests.cpp 91219d6693fdd119ed3b0bf734eaa55da9c58b0a 
> 
> 
> Diff: https://reviews.apache.org/r/57167/diff/1/
> 
> 
> Testing
> -------
> 
> `make check`
> 
> 
> Thanks,
> 
> Neil Conway
> 
>

Reply via email to