> On April 18, 2016, 6:09 a.m., Jiang Yan Xu wrote:
> > include/mesos/resources.hpp, line 56
> > <https://reviews.apache.org/r/45959/diff/2/?file=1340688#file1340688line56>
> >
> > Let's use a `class` just like Resources. As a `Resource` wrapper eventually
most methods for single resource handling should be moved in `Resource_`. Even though in this
patch we should do the minimum amount of that just to make sure resource sharing semantics
work, a `class` should be a start.
Done, and moved this class within Resources.
> On April 18, 2016, 6:09 a.m., Jiang Yan Xu wrote:
> > include/mesos/resources.hpp, line 65
> > <https://reviews.apache.org/r/45959/diff/2/?file=1340688#file1340688line65>
> >
> > This check is too brutal. Plus we can just manage counters internally and do
not take it as an contructor argument. We always initiate the counter to be none or 1 based
on the `resource`.
> >
> > The counters shouldn't be updated directly and I don't think it should be even
be exposed. `Resource_` should define a set of arithmetic operators to update the counters.
> >
> > e.g.,
> > ```
> > Resource_& Resource_::operator+=(const Resource_& that);
> > ```
share Count is only updated within the class, and is not available to be passed in through
a public constructor/API.
> On April 18, 2016, 6:09 a.m., Jiang Yan Xu wrote:
> > include/mesos/resources.hpp, lines 348-353
> > <https://reviews.apache.org/r/45959/diff/2/?file=1340688#file1340688line348>
> >
> > We don't need them if we stick to the "let `Resource_` take care of its own
arithmetic" approach.
Removed getConsumerCount() and achieved similar semantics via the isInitState() api. We do
not expose shareCount via a public api now.
> On April 18, 2016, 6:09 a.m., Jiang Yan Xu wrote:
> > include/mesos/resources.hpp, line 477
> > <https://reviews.apache.org/r/45959/diff/2/?file=1340688#file1340688line477>
> >
> > If we don't need ordering (I don't think we do) then std::list is cheaper because
of vector's memory allocation.
We decided to keep this a vector to avoid memory allocation / deallocation on every add /
remove from vector.
vector does have a costly remove operation when done in the middle which was addressed by
swapping the entry to be deleted with the last entry and removing the last entry.
> On April 18, 2016, 6:09 a.m., Jiang Yan Xu wrote:
> > src/common/resources.cpp, lines 1259-1286
> > <https://reviews.apache.org/r/45959/diff/2/?file=1340691#file1340691line1259>
> >
> > No need for these.
Replaced getConsumerCount() with isInitResource() to achieve the intent without exposing share
count.
> On April 18, 2016, 6:09 a.m., Jiang Yan Xu wrote:
> > src/common/resources.cpp, lines 1259-1286
> > <https://reviews.apache.org/r/45959/diff/2/?file=1340691#file1340691line1259>
> >
> > No need for this.
Same comment as the last one. Killing this one.
> On April 18, 2016, 6:09 a.m., Jiang Yan Xu wrote:
> > src/common/resources.cpp, lines 1855-1857
> > <https://reviews.apache.org/r/45959/diff/2/?file=1340691#file1340691line1855>
> >
> > Don't add anything special for nonshared resource since it's optional.
This is not for non-shared resources. This was for shared resources when share count is None().
That case is also not possible so I removed this.
- Anindya
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/45959/#review128700
-----------------------------------------------------------
On April 29, 2016, 12:15 a.m., Anindya Sinha wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/45959/
> -----------------------------------------------------------
>
> (Updated April 29, 2016, 12:15 a.m.)
>
>
> Review request for mesos, Ben 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 Resoure_ is added to keep track of Resource and its
> consumer count. As a result, Resources maintains a single container
> for all resources.
>
> All resources have consumer counts that is tracked within Resources. For
> resource addition and subtraction, the consumer counts are adjusted for
> shared resources as follows:
> a) Addition: If shared resource is absent from original, then the
> resource is added with a consumer count of 0. Otherwise, the consumer
> count for the shared resource is incremented by 1.
> b) Subtraction: If shared resource's consumer count is already 0, then
> the shared resource is removed from the original. Otherwise, its
> consumer count is decremented by 1.
>
>
> Diffs
> -----
>
> include/mesos/resources.hpp a557e97c65194d4aad879fb88d8edefd1c95b8d8
> include/mesos/v1/resources.hpp a5ba8fec4c9c3643646308f75a4b28cefe0b3df3
> src/common/resources.cpp f6ff92b591c15bc8e93fd85e1896349c3a7bb968
> src/master/validation.cpp f458100d22ec1f9f10921c1c91b6931a5671e28f
> src/tests/mesos.hpp 0f6f541c5d2007a69ad5bd6e884235cd3c0c1be2
> src/tests/resources_tests.cpp dc12bd8f1e2da6972bc8aed598811c55d664036e
> src/v1/resources.cpp 8c3f2d1c1529915a59d47fe37bb3fc7a3267079a
>
> 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
>
>
|