> On March 16, 2018, 7:26 p.m., Benjamin Mahler wrote: > > src/master/allocator/mesos/hierarchical.cpp > > Lines 1577-1590 (patched) > > <https://reviews.apache.org/r/66044/diff/1/?file=1974909#file1974909line1577> > > > > This function seems rather specific to the usage in this code, which > > makes it not very easy to intuit its behavior. How about: > > > > ``` > > // Returns the result of shrinking the provided resources down to the > > // target scalar quantities. If a resource does not have a target > > // quantity provided, it will not be shrunk. > > // > > // Note that some resources are indivisible (e.g. MOUNT volume) and > > // may be excluded in entirety in order to acheive the target size. > > // > > // Note also that there may be more than 1 result that satisfies > > // the target sizes (e.g. need to exclude 1 of 2 disks); this function > > // will make a random choice in these cases. > > auto shrinkResources = []( > > const Resources& resources, > > hashmap<string, Value::Scalar> targetQuantities) { > > ... > > }; > > ``` > > > > Then the caller can omit resources if it wants to acheive a default > > target size of 0 (i.e. `filterNonExistScalar`): > > > > ``` > > Resources allocation = shrinkResources(allocation, targetQuantities); > > > > allocation = allocation.filter([](const Resource& r) { > > return targetQuantites.contains(r.name()); > > }); > > ```
Great point! Thanks! - Meng ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/66044/#review199288 ----------------------------------------------------------- On March 19, 2018, 4:48 p.m., Meng Zhu wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/66044/ > ----------------------------------------------------------- > > (Updated March 19, 2018, 4:48 p.m.) > > > Review request for mesos, Benjamin Mahler, Kapil Arya, Joseph Wu, Michael > Park, and Till Toenshoff. > > > Repository: mesos > > > Description > ------- > > Introduced a `shrinkResources()` lambda in allocator > so that the same resource chopping logic can be re-used > in the future, in particular, when introducing the quota > limit. > > > Diffs > ----- > > src/master/allocator/mesos/hierarchical.cpp > 32e88952101d8dbbae9728478b1f5663bf46c3bb > > > Diff: https://reviews.apache.org/r/66044/diff/2/ > > > Testing > ------- > > make check > > > Thanks, > > Meng Zhu > >
