[
https://issues.apache.org/jira/browse/YARN-3836?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Li Lu updated YARN-3836:
------------------------
Attachment: YARN-3836-YARN-2928.001.patch
In this patch I added equals and hashCode methods to timeline entity and
related classes, and added some javadoc describing issues raised by
[~jrottinghuis]. There are two things that I think worth a discussion here:
# Possible definitions of equivalence: had some offline discussion with
[~zjshen] and we thought it would be fine to say two timeline entities are
equal if their type and id are equal. As raised in this JIRA, oftentimes we'd
like to put timeline entities in a hashmap (e.g. for aggregations). Our current
design is sufficient to support use cases like: {{aggregatedEntity =
map.get(incomingEntity); aggregatedEntity.aggregate(incomingEntity); }}. Of
course user can always implement a deep comparison afterwards.
# Checking the validity of objects: due to the requirements of the restful
interface, we have to expose default constructors. However, this will cause
several member variables of an timeline data object to be nulls, which is quite
error pruning. I'm adding the isValid method to assist users to check if an
object is valid (with all required fields set).
> 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: Li Lu
> Attachments: YARN-3836-YARN-2928.001.patch
>
>
> 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)