From c7f5167845ce52b060d4f1037ed2ddee5cfa3e4e Mon Sep 17 00:00:00 2001 From: Todd Lipcon Date: Mon, 5 Dec 2011 06:37:46 +0000 Subject: [PATCH] HDFS-2624. ConfiguredFailoverProxyProvider doesn't correctly stop ProtocolTranslators. Contributed by Todd Lipcon. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-1623@1210341 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt | 2 ++ .../src/main/java/org/apache/hadoop/hdfs/DFSClient.java | 3 ++- .../namenode/ha/ConfiguredFailoverProxyProvider.java | 7 ++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt index d5f4d0d7f79..5de1611b329 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt @@ -41,3 +41,5 @@ HDFS-2612. Handle refreshNameNodes in federated HA clusters (todd) HDFS-2623. Add test case for hot standby capability (todd) HDFS-2626. BPOfferService.verifyAndSetNamespaceInfo needs to be synchronized (todd) + +HDFS-2624. ConfiguredFailoverProxyProvider doesn't correctly stop ProtocolTranslators (todd) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java index 9f444155262..c0533eed1e3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java @@ -439,8 +439,9 @@ public class DFSClient implements java.io.Closeable { // fall through - lets try the stopProxy LOG.warn("Exception closing namenode, stopping the proxy"); } + } else { + RPC.stopProxy(namenode); } - RPC.stopProxy(namenode); } /** Abort and release resources held. Ignore all errors. */ diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/ConfiguredFailoverProxyProvider.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/ConfiguredFailoverProxyProvider.java index 483d9eb6230..8239c5e03b0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/ConfiguredFailoverProxyProvider.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/ConfiguredFailoverProxyProvider.java @@ -17,6 +17,7 @@ */ package org.apache.hadoop.hdfs.server.namenode.ha; +import java.io.Closeable; import java.io.IOException; import java.net.InetSocketAddress; import java.util.ArrayList; @@ -126,7 +127,11 @@ public class ConfiguredFailoverProxyProvider implements FailoverProxyProvider, public synchronized void close() throws IOException { for (AddressRpcProxyPair proxy : proxies) { if (proxy.namenode != null) { - RPC.stopProxy(proxy.namenode); + if (proxy.namenode instanceof Closeable) { + ((Closeable)proxy.namenode).close(); + } else { + RPC.stopProxy(proxy.namenode); + } } } }