> On Sept. 20, 2016, 5 p.m., Jiang Yan Xu wrote:
> > include/mesos/resources.hpp, lines 60-64
> > <https://reviews.apache.org/r/51999/diff/2/?file=1504205#file1504205line60>
> >
> >     We can get rid of this forward declaration if we can get rid of the 
> > internal convertJSON.

Based on the refactor, we are keeping `convertJSON()`.


> On Sept. 20, 2016, 5 p.m., Jiang Yan Xu wrote:
> > include/mesos/resources.hpp, line 201
> > <https://reviews.apache.org/r/51999/diff/2/?file=1504205#file1504205line201>
> >
> >     This is too similar to 
> >     
> >     ```
> >     static Try<Resources> parse(
> >           const std::string& text,
> >           const std::string& defaultRole = "*");
> >     ```
> >     
> >     I was originally suggesting moving over convertJSON but I guess it's 
> > more suitable here in the following form:
> >     
> >     ```
> >     Try<vector<Resource>> fromJSONString(
> >         const std::string& text,
> >         const std::string& defaultRole)
> >     ```
> >     
> >     Similarly for simple flat strings:
> >     
> >     ```
> >     Try<vector<Resource>> fromSimpleString(
> >         const std::string& text,
> >         const std::string& defaultRole)
> >     ```
> >     
> >     When we have both, then 
> >     
> >     ```
> >     static Try<Resources> parse(
> >         const std::string& text,
> >         const std::string& defaultRole = "*");
> >     ```
> >     
> >     becomes a mere convenience method that calls the above two methods in 
> > sequence. The convenience method can be simply documented as:
> >     
> >     ```
> >       /** 
> >        * Returns Resources from an input string.
> >        *
> >        * Parses Resources from text in the form of a JSON array (see
> >        * `fromJSONString()`). If that fails, parses text in the simple 
> >        * string form (see `fromSimpleString()`).
> >        */
> >     ```
> >     
> >     How does it sound?

Well, we can do this in a couple of ways. The current approach was to use 
`Resources::parseText()` [or we could call it `Resources::parse()` with an 
additional parameter to include or not include empty resources], which 
`Resources::parse()` would call to implicitly convert to `Resources` from 
`vecor<Resource>`, whereas in `Containerizer::resources()`, we would call 
`Resources::parseText()` or `Resources::parse()` with the additional parameter.
Another option we discussed is to expose another `Resources::parse()` that 
returns `vecor<Resource>` in a separate namespace which probably is cleaner but 
would require refactor in other call sites.
For now, we would follow the approach specified above.


- Anindya


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/51999/#review149624
-----------------------------------------------------------


On Sept. 19, 2016, 10:42 p.m., Anindya Sinha wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/51999/
> -----------------------------------------------------------
> 
> (Updated Sept. 19, 2016, 10:42 p.m.)
> 
> 
> Review request for mesos and Jiang Yan Xu.
> 
> 
> Bugs: MESOS-6062
>     https://issues.apache.org/jira/browse/MESOS-6062
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> During parsing of resources in the startup flags of mesos agent, all
> the valid resources (including empty resources) are accumulated in a
> vector of Resource protobufs.
> 
> 
> Diffs
> -----
> 
>   include/mesos/resources.hpp 3ef8cacee529addc745b4aeb6398d7606c61b749 
>   include/mesos/v1/resources.hpp ef56b4960b103a3efd916fab64796aa334ba44c6 
>   src/common/resources.cpp 4602bff22ec7ff77f069056085ad92bfa04595f3 
>   src/slave/containerizer/containerizer.cpp 
> d46882baa904fd439bffb23c324828b777228f1c 
>   src/tests/resources_tests.cpp 3e493007d6d1d8194d07035aaa1cde28dedf2b5a 
>   src/v1/resources.cpp 7c4db44d4c31a8295cc16b0ce1ef5adf314e6ac6 
> 
> Diff: https://reviews.apache.org/r/51999/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Anindya Sinha
> 
>

Reply via email to