mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anindya Sinha <anindya_si...@apple.com>
Subject Re: Review Request 52002: Added helper methods to determine types of disk resources.
Date Wed, 21 Sep 2016 19:54:07 GMT


> On Sept. 20, 2016, 10:29 p.m., Jiang Yan Xu wrote:
> > include/mesos/resources.hpp, lines 273-274
> > <https://reviews.apache.org/r/52002/diff/2/?file=1504213#file1504213line273>
> >
> >     Does it need to be a Try? i.e., if it's not a disk, it's not a root disk, right?
We have `validate()` to make sure resources are valid.

If `resource.name() != "disk"`, we can skip this resource altogether. But if this is a `disk`
but not a root disk (ie. `resource.has_disk()` is `true`), then we also check for `MOUNT`
or `PATH`. So by returning a `Try<bool>`, we are able to decide if we should continue
with this resource or not. Ofcourse, we can check for `resource.has_disk()` outside of these
functions but adding that check makes this function self-contained.


> On Sept. 20, 2016, 10:29 p.m., Jiang Yan Xu wrote:
> > include/mesos/resources.hpp, lines 276-278
> > <https://reviews.apache.org/r/52002/diff/2/?file=1504213#file1504213line276>
> >
> >     Would it be simpler to just have 
> >     
> >     ```
> >     static bool Resources::isMountDisk(const Resource& resource);
> >     static bool Resources::isPathDisk(const Resource& resource);
> >     ```
> >     
> >     ?
> >     
> >     We have already lost enumerability (or swtichability) given that the root disk
does not have a type. :)

I prefer this way so as to not add functions when we add more disk types, say for block devices.


> On Sept. 20, 2016, 10:29 p.m., Jiang Yan Xu wrote:
> > src/common/resources.cpp, line 920
> > <https://reviews.apache.org/r/52002/diff/2/?file=1504215#file1504215line920>
> >
> >     Not `!resource.has_disk()` but rather `!resource.disk().has_source()` right?
> >     
> >     See examples below.

I think `!resource.has_disk()` is fine. Why should a root disk have `Persistence` and/or `Volume`?
`Persistence` is to define characteristics of a persistent volume, where as `Volume` is how
the disk resource is mounted in a container.


> On Sept. 20, 2016, 10:29 p.m., Jiang Yan Xu wrote:
> > src/common/resources.cpp, lines 924-943
> > <https://reviews.apache.org/r/52002/diff/2/?file=1504215#file1504215line924>
> >
> >     It seems to be cleaner to implement the following instead:
> >     
> >     ```
> >     static bool Resources::isMountDisk(const Resource& resource)
> >     {
> >       return resource.has_disk() && 
> >              resource.disk().has_source() &&
> >              resource.disk().source().type() == Resource::DiskInfo::Source::MOUNT;
> >     }
> >     
> >     static bool Resources::isPathDisk(const Resource& resource)
> >     {
> >       return resource.has_disk() && 
> >              resource.disk().has_source() &&
> >              resource.disk().source().type() == Resource::DiskInfo::Source::PATH;
> >     }
> >     ```

See my response above. I think having a single function to encapsulate all source types is
fine.


- Anindya


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


On Sept. 21, 2016, 4:14 a.m., Anindya Sinha wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/52002/
> -----------------------------------------------------------
> 
> (Updated Sept. 21, 2016, 4:14 a.m.)
> 
> 
> Review request for mesos and Jiang Yan Xu.
> 
> 
> Bugs: MESOS-6062
>     https://issues.apache.org/jira/browse/MESOS-6062
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Added helper methods to determine types of disk resources.
> 
> 
> Diffs
> -----
> 
>   include/mesos/resources.hpp 3ef8cacee529addc745b4aeb6398d7606c61b749 
>   include/mesos/v1/resources.hpp ef56b4960b103a3efd916fab64796aa334ba44c6 
>   src/common/resources.cpp 4602bff22ec7ff77f069056085ad92bfa04595f3 
>   src/tests/resources_tests.cpp 3e493007d6d1d8194d07035aaa1cde28dedf2b5a 
>   src/v1/resources.cpp 7c4db44d4c31a8295cc16b0ce1ef5adf314e6ac6 
> 
> Diff: https://reviews.apache.org/r/52002/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Anindya Sinha
> 
>


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