Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 17244200CFA for ; Fri, 28 Jul 2017 01:48:43 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1265816B900; Thu, 27 Jul 2017 23:48:43 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5AF6416B492 for ; Fri, 28 Jul 2017 01:48:42 +0200 (CEST) Received: (qmail 89024 invoked by uid 500); 27 Jul 2017 23:48:34 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 88003 invoked by uid 99); 27 Jul 2017 23:48:33 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Jul 2017 23:48:33 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AEE30F3318; Thu, 27 Jul 2017 23:48:32 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aengineer@apache.org To: common-commits@hadoop.apache.org Date: Thu, 27 Jul 2017 23:48:53 -0000 Message-Id: In-Reply-To: <39b717879f5b448f8772d14f4311e814@git.apache.org> References: <39b717879f5b448f8772d14f4311e814@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [22/34] hadoop git commit: HDFS-12143. Improve performance of getting and removing inode features. Contributed by Daryn Sharp. archived-at: Thu, 27 Jul 2017 23:48:43 -0000 HDFS-12143. Improve performance of getting and removing inode features. Contributed by Daryn Sharp. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/1a79dcfc Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/1a79dcfc Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/1a79dcfc Branch: refs/heads/HDFS-7240 Commit: 1a79dcfc457969d6a6c08ffffe4152fd7638e48a Parents: cca51e9 Author: Kihwal Lee Authored: Tue Jul 25 10:28:57 2017 -0500 Committer: Kihwal Lee Committed: Tue Jul 25 10:28:57 2017 -0500 ---------------------------------------------------------------------- .../namenode/INodeWithAdditionalFields.java | 24 ++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/1a79dcfc/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeWithAdditionalFields.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeWithAdditionalFields.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeWithAdditionalFields.java index fe58577..9adcc3e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeWithAdditionalFields.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeWithAdditionalFields.java @@ -283,12 +283,14 @@ public abstract class INodeWithAdditionalFields extends INode protected void removeFeature(Feature f) { int size = features.length; - Preconditions.checkState(size > 0, "Feature " - + f.getClass().getSimpleName() + " not found."); + if (size == 0) { + throwFeatureNotFoundException(f); + } if (size == 1) { - Preconditions.checkState(features[0] == f, "Feature " - + f.getClass().getSimpleName() + " not found."); + if (features[0] != f) { + throwFeatureNotFoundException(f); + } features = EMPTY_FEATURE; return; } @@ -307,14 +309,22 @@ public abstract class INodeWithAdditionalFields extends INode } } - Preconditions.checkState(!overflow && j == size - 1, "Feature " - + f.getClass().getSimpleName() + " not found."); + if (overflow || j != size - 1) { + throwFeatureNotFoundException(f); + } features = arr; } + private void throwFeatureNotFoundException(Feature f) { + throw new IllegalStateException( + "Feature " + f.getClass().getSimpleName() + " not found."); + } + protected T getFeature(Class clazz) { Preconditions.checkArgument(clazz != null); - for (Feature f : features) { + final int size = features.length; + for (int i=0; i < size; i++) { + Feature f = features[i]; if (clazz.isAssignableFrom(f.getClass())) { @SuppressWarnings("unchecked") T ret = (T) f; --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org