Reordered DRFSorter member function. Ensure that member function appear in the same order in the header file as in the implementation file.
Review: https://reviews.apache.org/r/57528 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/bbe2c6c6 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/bbe2c6c6 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/bbe2c6c6 Branch: refs/heads/master Commit: bbe2c6c65647ddbe91608d370ea27de3ec50740a Parents: b7f70ca Author: Neil Conway <[email protected]> Authored: Fri Mar 10 20:19:27 2017 -0500 Committer: Neil Conway <[email protected]> Committed: Wed Apr 26 14:01:57 2017 -0400 ---------------------------------------------------------------------- src/master/allocator/sorter/drf/sorter.cpp | 76 ++++++++++++------------- 1 file changed, 38 insertions(+), 38 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/bbe2c6c6/src/master/allocator/sorter/drf/sorter.cpp ---------------------------------------------------------------------- diff --git a/src/master/allocator/sorter/drf/sorter.cpp b/src/master/allocator/sorter/drf/sorter.cpp index d2952b8..85dbff1 100644 --- a/src/master/allocator/sorter/drf/sorter.cpp +++ b/src/master/allocator/sorter/drf/sorter.cpp @@ -228,6 +228,44 @@ void DRFSorter::update( } +void DRFSorter::unallocated( + const string& name, + const SlaveID& slaveId, + const Resources& resources) +{ + CHECK(contains(name)); + CHECK(allocations.at(name).resources.contains(slaveId)); + CHECK(allocations.at(name).resources.at(slaveId).contains(resources)); + + allocations[name].resources[slaveId] -= resources; + + // Remove shared resources from the allocated quantities when there + // are no instances of same resources left in the allocation. + const Resources absentShared = resources.shared() + .filter([this, name, slaveId](const Resource& resource) { + return !allocations[name].resources[slaveId].contains(resource); + }); + + const Resources scalarQuantities = + (resources.nonShared() + absentShared).createStrippedScalarQuantity(); + + foreach (const Resource& resource, scalarQuantities) { + allocations[name].totals[resource.name()] -= resource.scalar(); + } + + CHECK(allocations[name].scalarQuantities.contains(scalarQuantities)); + allocations[name].scalarQuantities -= scalarQuantities; + + if (allocations[name].resources[slaveId].empty()) { + allocations[name].resources.erase(slaveId); + } + + if (!dirty) { + updateShare(name); + } +} + + const hashmap<SlaveID, Resources>& DRFSorter::allocation( const string& name) const { @@ -286,44 +324,6 @@ const Resources& DRFSorter::totalScalarQuantities() const } -void DRFSorter::unallocated( - const string& name, - const SlaveID& slaveId, - const Resources& resources) -{ - CHECK(contains(name)); - CHECK(allocations.at(name).resources.contains(slaveId)); - CHECK(allocations.at(name).resources.at(slaveId).contains(resources)); - - allocations[name].resources[slaveId] -= resources; - - // Remove shared resources from the allocated quantities when there - // are no instances of same resources left in the allocation. - const Resources absentShared = resources.shared() - .filter([this, name, slaveId](const Resource& resource) { - return !allocations[name].resources[slaveId].contains(resource); - }); - - const Resources scalarQuantities = - (resources.nonShared() + absentShared).createStrippedScalarQuantity(); - - foreach (const Resource& resource, scalarQuantities) { - allocations[name].totals[resource.name()] -= resource.scalar(); - } - - CHECK(allocations[name].scalarQuantities.contains(scalarQuantities)); - allocations[name].scalarQuantities -= scalarQuantities; - - if (allocations[name].resources[slaveId].empty()) { - allocations[name].resources.erase(slaveId); - } - - if (!dirty) { - updateShare(name); - } -} - - void DRFSorter::add(const SlaveID& slaveId, const Resources& resources) { if (!resources.empty()) {
