----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/32140/#review79410 -----------------------------------------------------------
src/common/resources.cpp <https://reviews.apache.org/r/32140/#comment128732> I probably would split the logic like below so that it's more modular. Also, I think the current semantics for DiskInfo matching is a little weired (my fault) and I don't think we have a use case for now. So let's make it consistent with the ReservationInfo check (and remove the NOTE). You probably need to adjust some ResourcesTest. ``` if (left.name() != right.name() || left.type() != right.type() || left.role() != right.role()) { return false; } // Check if ReservationInfo matches. if (left.has_reservation() != right.has_reservation()) { return false; } if (left.has_reservation() && left.reservation() != right.reservation())) { return false; } // Check if DiskInfo matches. if (left.has_disk() != right.has_disk()) { return false; } if (left.has_disk() && left.disk() != right.disk()) { return false; } ``` src/common/resources.cpp <https://reviews.apache.org/r/32140/#comment128738> Ditto on modularity. ``` if (left.name() != right.name() || left.type() != right.type() || left.role() != right.role()) { return false; } // Check ReservationInfo. if (left.has_reservation() != right.has_reservation()) { return false; } if (left.has_reservation() && left.reservation() != right.reservation()) { return false; } // Check DiskInfo. if (left.has_disk() != right.has_disk()) { return false; } if (left.has_disk() && left.disk() != right.disk()) { return false; } // TODO(jieyu): Even if two .... if (left.has_disk() && left.disk().has_persistence()) { return false; } return true; ``` src/common/resources.cpp <https://reviews.apache.org/r/32140/#comment128753> Ditto on modularity. ``` if (left.name() != right.name() || left.type() != right.type() || left.role() != right.role()) { return false; } // Check ReservationInfo. if (left.has_reservation() != right.has_reservation()) { return false; } if (left.has_reservation() && left.reservation() != right.reservation()) { return false; } // Check DiskInfo. if (left.has_disk() != right.has_disk()) { return false; } if (left.has_disk() && left.disk() != right.disk()) { return false; } if (left.has_disk() && left.disk().has_persistence() && left != right) { return false; } return true; ``` src/common/resources.cpp <https://reviews.apache.org/r/32140/#comment128760> The semantics of this function becomes a little weired now. For example, for a resource that has `role == "*"` and has reservation set, `isReserved(resource, "*")` is going to return `true`? Given that 'resource' is invalid, we should return a `false` in that case? - Jie Yu On April 7, 2015, 9:56 p.m., Michael Park wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/32140/ > ----------------------------------------------------------- > > (Updated April 7, 2015, 9:56 p.m.) > > > Review request for mesos, Alexander Rukletsov, Ben Mahler, and Jie Yu. > > > Bugs: MESOS-2476 > https://issues.apache.org/jira/browse/MESOS-2476 > > > Repository: mesos > > > Description > ------- > > `Resource::ReservationInfo` was introduced in > [r32139](https://reviews.apache.org/r/32139). We need to consider it in our > `Resources` class implementation. > > ### `Resources::flatten` > > `flatten` is used as the utility function to cross reservation boundaries > without affecting the given resources. Since the reservation is now specified > by the (`role`, `reservation`) pair, `flatten` needs to consider > `ReservationInfo` as well. > > ### `Resources::validate` > > If `role == "*"`, then `reservation` field must not be set. > > ### `Resources` comparators > > `operator==`, `addable` and `substractable` need to test for > `ReservationInfo` as well. > > > Diffs > ----- > > include/mesos/resources.hpp 56affd45e1e71e96ff5778b43271f81b9b9a9e4d > src/common/resources.cpp 2c99b6884d7296099e19e2e3182cbe11b5e1e059 > src/tests/mesos.hpp 0e98572a62ae05437bd2bc800c370ad1a0c43751 > src/tests/resources_tests.cpp 7e0ad98c3366f647f190363a0e6b576dbfc7d415 > > Diff: https://reviews.apache.org/r/32140/diff/ > > > Testing > ------- > > make check > > > Thanks, > > Michael Park > >
