> On July 8, 2016, 4:30 p.m., Jiang Yan Xu wrote: > > src/tests/resources_tests.cpp, line 2563 > > <https://reviews.apache.org/r/45959/diff/5/?file=1416571#file1416571line2563> > > > > I suggest we don't reuse variables, perhaps even use `const`. > > > > ``` > > const Resources sum = r1 + r2; > > const Resources diff = r1 - r2; > > ``` > > > > In the following lines it becomes unclear what each variable means at a > > given moment anymore...
Not reusing the variable, but did not move to `const Resources` to be in sync with the existing tests. > On July 8, 2016, 4:30 p.m., Jiang Yan Xu wrote: > > src/tests/resources_tests.cpp, line 2599 > > <https://reviews.apache.org/r/45959/diff/5/?file=1416571#file1416571line2599> > > > > How about subtractions and contains? Seems like > > ScalarNonEqualSharedResources and ScalarSharedNonSharedOperations should be > > pretty much the same with the only difference being `isShared = true` in > > one `createDiskResource` call? I kept the tests separate since `ScalarSharedNonEqualSharedOperations` tests shared count for shared resources when the scalar representation of shared resources vary (such as in disk size). `ScalarSharedNonSharedOperations` is about adding/subtracting 2 persistent volumes which are same in all aspects except their sharedness. - Anindya ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/45959/#review141176 ----------------------------------------------------------- On June 13, 2016, 7:18 a.m., Anindya Sinha wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/45959/ > ----------------------------------------------------------- > > (Updated June 13, 2016, 7:18 a.m.) > > > Review request for mesos, Benjamin Mahler, Joris Van Remoortere, and Jiang > Yan Xu. > > > Bugs: MESOS-4892 > https://issues.apache.org/jira/browse/MESOS-4892 > > > Repository: mesos > > > Description > ------- > > A new class Resource_ is added that allows 'Resources' to group > identical shared resource objects together into a single 'Resource_' > object and tracked by its shared count. Non-shared resource objects > are not grouped. > > For resource addition and subtraction, the shared count is adjusted for > shared resources as follows: > a) Addition: If shared resource is absent from original, then the > resource is added initialized with a consumer count of 1. Otherwise, > the share count for the shared resource is incremented. > b) Subtraction: If shared resource's share count is already 1, then > the shared resource is removed from the original. Otherwise, its > consumer count is decremented. > > Note that v1 changes for shared resources are in the next commit. > > > Diffs > ----- > > include/mesos/resources.hpp a557e97c65194d4aad879fb88d8edefd1c95b8d8 > src/common/resources.cpp f6ff92b591c15bc8e93fd85e1896349c3a7bb968 > src/master/validation.cpp 7b9c2281b2ab1295211f0dd385cd77947fbd63be > src/tests/mesos.hpp e9361a65eb31cced99e9ed32fd18a65d1bda26e3 > src/tests/resources_tests.cpp dc12bd8f1e2da6972bc8aed598811c55d664036e > > Diff: https://reviews.apache.org/r/45959/diff/ > > > Testing > ------- > > New tests added to demonstrate arithmetic operations for shared resources > with consumer counts. > Tests successful. > > > Thanks, > > Anindya Sinha > >
