mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jiang Yan Xu <...@jxu.me>
Subject Re: Review Request 51999: Refactor parsing of resources.
Date Wed, 05 Oct 2016 18:06:33 GMT

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


Fix it, then Ship it!




Overall LGTM!


include/mesos/resources.hpp (line 157)
<https://reviews.apache.org/r/51999/#comment219943>

    "If that fails" gave me the wrong idea of the condition under which the method would then
call `fromSimpleString()` (so I suggested `fromJSONString(text, role)`).
    
    We are basically just replying on the input type and not "failures" to choose the parsing
mechanism so would the following be more clear?
    
    ````
    Parses Resources from text in the form of a JSON array or as a simple string in the form
of "name(role):value;name:value;...". i.e, this
    method calls `fromJSONArray()` or `fromSimpleString()` and validates the resulting `vector<Resource>`
before converting it to a `Resources` object.
    ```
    
    The last part of the paragraph may be implied but I think it makes it more clear.



include/mesos/resources.hpp (line 158)
<https://reviews.apache.org/r/51999/#comment219649>

    s/i.e,/i.e.,/



include/mesos/resources.hpp (line 159)
<https://reviews.apache.org/r/51999/#comment219942>

    s/fromJSONArray/fromJSON/ 
    
    See the comment at the method declaration below.



include/mesos/resources.hpp (line 180)
<https://reviews.apache.org/r/51999/#comment219948>

    Should we add a usage note?
    
    ```
    NOTE: The `Resource` objects in the result vector may not be semantically valid (i.e.,
they may not pass `Resources::validate()`). This is to allow additional handling of the parsing
results in certain cases.
    ```



include/mesos/resources.hpp (line 186)
<https://reviews.apache.org/r/51999/#comment219650>

    s/fromJSONArray/fromJSON/
    
    There should be no ambiguity and we gained brevity. 
    
    The info about the argument being `JSON::Array` is already baked into the method signture
so we don't have to say it again.



include/mesos/resources.hpp (line 197)
<https://reviews.apache.org/r/51999/#comment219949>

    Should we add a usage note?
    
    ```
    NOTE: The `Resource` objects in the result vector may not be semantically valid (i.e.,
they may not pass `Resources::validate()`). This is to allow additional handling of the parsing
results in certain cases.
    ```



src/common/resources.cpp (lines 532 - 550)
<https://reviews.apache.org/r/51999/#comment219956>

    Would the following be simpler?
    
    ```
    Try<vector<Resource>> _result = resourcesJSON.isSome()
      ? fromJSONArray(resourcesJSON.get(), defaultRole),
      : fromSimpleString(text, defaultRole);
    
    if (_result.isError()) {
      return Error(_result.error());
    }
    
    resources = _result.get();
    ```
    
    Also s/resourcesJSON/json/? (because it literally just checks whether it's valid JSON
and it
    is shorter)



src/common/resources.cpp (line 598)
<https://reviews.apache.org/r/51999/#comment219957>

    ```
    // However, those checks are done at the respective call sites. 
    ```
    
    I suggested above that we move this over to be a usage note for this method. If we do
that then here the implementation really doesn't care about it one way or the other (as a
lower level parsing function) so we can kill it.



src/common/resources.cpp (lines 646 - 647)
<https://reviews.apache.org/r/51999/#comment219959>

    Ditto.


- Jiang Yan Xu


On Oct. 3, 2016, 4:46 p.m., Anindya Sinha wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/51999/
> -----------------------------------------------------------
> 
> (Updated Oct. 3, 2016, 4:46 p.m.)
> 
> 
> Review request for mesos and Jiang Yan Xu.
> 
> 
> Bugs: MESOS-6062
>     https://issues.apache.org/jira/browse/MESOS-6062
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Refactored `Resources::parse()` into 2 separate static functions:
> 1. Resources::fromJSONString() to parse JSON representation of
>    resources.
> 2. Resources::fromSimpleString() to parse text representation of
>    resources.
> 
> Since these 2 new functions return a `Try<vector<Resource>>`, the
> existing `Resources::parse()` implicitly converts that to a
> `Resources` object. This refactor is done to retrieve all resources
> (include empty resources) required for auto detection of root
> and MOUNT disks.
> 
> 
> Diffs
> -----
> 
>   include/mesos/resources.hpp 3ef8cacee529addc745b4aeb6398d7606c61b749 
>   include/mesos/v1/resources.hpp ef56b4960b103a3efd916fab64796aa334ba44c6 
>   src/common/resources.cpp 0774ff0669e831494d5b12b88e19dfa0a4a3f757 
>   src/tests/resources_tests.cpp 3e493007d6d1d8194d07035aaa1cde28dedf2b5a 
>   src/v1/resources.cpp 62a644ebbd13cfc0862bd118ba16c43e0f6aaf90 
> 
> Diff: https://reviews.apache.org/r/51999/diff/
> 
> 
> Testing
> -------
> 
> All tests passed.
> 
> 
> Thanks,
> 
> Anindya Sinha
> 
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message