Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E834418D02 for ; Wed, 30 Dec 2015 06:56:27 +0000 (UTC) Received: (qmail 35186 invoked by uid 500); 30 Dec 2015 06:56:27 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 34961 invoked by uid 500); 30 Dec 2015 06:56:27 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 33681 invoked by uid 99); 30 Dec 2015 06:56:27 -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; Wed, 30 Dec 2015 06:56:27 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D581DE0BC6; Wed, 30 Dec 2015 06:56:26 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: asuresh@apache.org To: common-commits@hadoop.apache.org Date: Wed, 30 Dec 2015 06:56:48 -0000 Message-Id: In-Reply-To: <25a070b3ad694fcfa3f54d39d65ed6f4@git.apache.org> References: <25a070b3ad694fcfa3f54d39d65ed6f4@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [23/27] hadoop git commit: HDFS-7553. fix the TestDFSUpgradeWithHA due to BindException. Contributed by Xiao Chen. HDFS-7553. fix the TestDFSUpgradeWithHA due to BindException. Contributed by Xiao Chen. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/99cf2ece Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/99cf2ece Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/99cf2ece Branch: refs/heads/yarn-2877 Commit: 99cf2ecee9c19231dea3620c053b2d8d71812fd6 Parents: 2a59d01 Author: cnauroth Authored: Tue Dec 29 10:56:59 2015 -0800 Committer: cnauroth Committed: Tue Dec 29 10:56:59 2015 -0800 ---------------------------------------------------------------------- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 ++ .../hadoop/hdfs/server/namenode/NameNode.java | 16 ++++++++++ .../server/namenode/NameNodeHttpServer.java | 9 ++++++ .../org/apache/hadoop/hdfs/MiniDFSCluster.java | 33 +++++++++++--------- .../hdfs/server/namenode/TestStartup.java | 2 ++ 5 files changed, 48 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/99cf2ece/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index d5f51ff..9da92b2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -2547,6 +2547,9 @@ Release 2.8.0 - UNRELEASED HDFS-9458. TestBackupNode always binds to port 50070, which can cause bind failures. (Xiao Chen via cnauroth) + HDFS-7553. fix the TestDFSUpgradeWithHA due to BindException. + (Xiao Chen via cnauroth) + Release 2.7.3 - UNRELEASED INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/99cf2ece/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java index acb4069..97c8b26 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java @@ -1022,6 +1022,22 @@ public class NameNode implements NameNodeStatusMXBean { } /** + * @return NameNodeHttpServer, used by unit tests to ensure a full shutdown, + * so that no bind exception is thrown during restart. + */ + @VisibleForTesting + public void joinHttpServer() { + if (httpServer != null) { + try { + httpServer.join(); + } catch (InterruptedException e) { + LOG.info("Caught InterruptedException joining NameNodeHttpServer", e); + Thread.currentThread().interrupt(); + } + } + } + + /** * Verify that configured directories exist, then * Interactively confirm that formatting is desired * for each existing directory and format them. http://git-wip-us.apache.org/repos/asf/hadoop/blob/99cf2ece/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeHttpServer.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeHttpServer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeHttpServer.java index 6bd9868..8f112bd 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeHttpServer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeHttpServer.java @@ -194,6 +194,15 @@ public class NameNodeHttpServer { return params; } + /** + * Joins the httpserver. + */ + public void join() throws InterruptedException { + if (httpServer != null) { + httpServer.join(); + } + } + void stop() throws Exception { if (httpServer != null) { httpServer.stop(); http://git-wip-us.apache.org/repos/asf/hadoop/blob/99cf2ece/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java index 3e25177..63561fe 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java @@ -1908,12 +1908,7 @@ public class MiniDFSCluster { shutdownDataNodes(); for (NameNodeInfo nnInfo : namenodes.values()) { if (nnInfo == null) continue; - NameNode nameNode = nnInfo.nameNode; - if (nameNode != null) { - nameNode.stop(); - nameNode.join(); - nameNode = null; - } + stopAndJoinNameNode(nnInfo.nameNode); } ShutdownHookManager.get().clearShutdownHooks(); if (base_dir != null) { @@ -1953,17 +1948,25 @@ public class MiniDFSCluster { */ public synchronized void shutdownNameNode(int nnIndex) { NameNodeInfo info = getNN(nnIndex); - NameNode nn = info.nameNode; - if (nn != null) { - LOG.info("Shutting down the namenode"); - nn.stop(); - nn.join(); - info.nnId = null; - info.nameNode = null; - info.nameserviceId = null; + stopAndJoinNameNode(info.nameNode); + info.nnId = null; + info.nameNode = null; + info.nameserviceId = null; + } + + /** + * Fully stop the NameNode by stop and join. + */ + private void stopAndJoinNameNode(NameNode nn) { + if (nn == null) { + return; } + LOG.info("Shutting down the namenode"); + nn.stop(); + nn.join(); + nn.joinHttpServer(); } - + /** * Restart all namenodes. */ http://git-wip-us.apache.org/repos/asf/hadoop/blob/99cf2ece/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStartup.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStartup.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStartup.java index 20dda37..860a2c9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStartup.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStartup.java @@ -444,6 +444,7 @@ public class TestStartup { nnRpc.saveNamespace(0, 0); namenode.stop(); namenode.join(); + namenode.joinHttpServer(); // compress image using default codec LOG.info("Read an uncomressed image and store it compressed using default codec."); @@ -474,6 +475,7 @@ public class TestStartup { nnRpc.saveNamespace(0, 0); namenode.stop(); namenode.join(); + namenode.joinHttpServer(); } @Test