[ 
https://issues.apache.org/jira/browse/YARN-3836?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14594413#comment-14594413
 ] 

Joep Rottinghuis commented on YARN-3836:
----------------------------------------

[~vrushalic] when you're tackling TimelineEntity anyway, it may be good to add 
a few items to javadoc:
a) The class itself should explain that it is not threadsafe and should be used 
in the context of a single thread only
b) Methods such as getIdentifier(), setIdentifier(), getConfigs(), getInfo() 
leak their internal implementation. They either take or return mutable objects 
that when modified mess up the state of the the TimelineEntity. Given the 
performance implications of making copies for safety, it is probably reasonable 
to stay as-is, but we should add warnings that callers are not to mess with the 
given or returned collections and Identifier object (nor to re-use them for 
other any other purposes) or else the internal state of TimelineEntity will be 
messed up.

When looking at the defaults, the members eagerly initialize with collections, 
but setters do not verify nulls. Given the lack of javadoc, the api is not 
clear whether nulls should be not allowed for setters and should not be 
expected for getters, or if nulls will be possible.
We'll probably have to check with the Jackson/Jaxb code if it can properly 
handle nulls or not.

Either we allow nulls or not. Currently HBaseTimelineWriter does not handle 
nulls. If we don't allow them, I think there should be a null check in the 
setters. If we do (will be best for performance I think) then clients need to 
do null checks. Either way we should document which one it is imho.

> add equals and hashCode to TimelineEntity and other classes in the data model
> -----------------------------------------------------------------------------
>
>                 Key: YARN-3836
>                 URL: https://issues.apache.org/jira/browse/YARN-3836
>             Project: Hadoop YARN
>          Issue Type: Sub-task
>          Components: timelineserver
>    Affects Versions: YARN-2928
>            Reporter: Sangjin Lee
>            Assignee: Vrushali C
>
> Classes in the data model API (e.g. {{TimelineEntity}}, 
> {{TimelineEntity.Identifer}}, etc.) do not override {{equals()}} or 
> {{hashCode()}}. This can cause problems when these objects are used in a 
> collection such as a {{HashSet}}. We should implement these methods wherever 
> appropriate.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to