Return-Path: X-Original-To: apmail-hadoop-yarn-issues-archive@minotaur.apache.org Delivered-To: apmail-hadoop-yarn-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5D6D818BC9 for ; Thu, 9 Jul 2015 06:46:05 +0000 (UTC) Received: (qmail 80864 invoked by uid 500); 9 Jul 2015 06:46:05 -0000 Delivered-To: apmail-hadoop-yarn-issues-archive@hadoop.apache.org Received: (qmail 80820 invoked by uid 500); 9 Jul 2015 06:46:05 -0000 Mailing-List: contact yarn-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: yarn-issues@hadoop.apache.org Delivered-To: mailing list yarn-issues@hadoop.apache.org Received: (qmail 80804 invoked by uid 99); 9 Jul 2015 06:46:05 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jul 2015 06:46:05 +0000 Date: Thu, 9 Jul 2015 06:46:05 +0000 (UTC) From: "Li Lu (JIRA)" To: yarn-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (YARN-3836) add equals and hashCode to TimelineEntity and other classes in the data model MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ 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.002.patch Hi [~sjlee0], thanks for the prompt feedback! I updated the patch according to your comments. Specifically: bq. What I would prefer is to override equals() and hashCode() for Identifier instead, and have simple equals() and hashCode() implementations for TimelineEntity that mostly delegate to Identifier. The rationale is that Identifier can be useful as keys to collections in its own right, and thus should override those methods. That's a nice suggestion! Fixed. bq. One related question for your use case of putting entities into a map: I notice that you're using the TimelineEntity instances directly as keys to maps. Wouldn't it be better to use their Identifier instances as keys instead? Identifier instances are easier and cheaper to construct and compare. I think I used an inappropriate example here. I meant to say HashSet but not HashMap. bq. We should make isValid() a proper javadoc hyperlink Fixed. bq. Since we're checking the entity type and the id, wouldn't it be sufficient to check whether the object is an instance of TimelineEntity? I agree. Fixed all related ones. > 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, YARN-3836-YARN-2928.002.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)