From 156b92e36bb04252a1c3ee7b334809021d963254 Mon Sep 17 00:00:00 2001 From: Benoy Antony Date: Fri, 14 Oct 2016 10:26:39 -0700 Subject: [PATCH] HDFS-10735 Distcp using webhdfs on secure HA clusters fails with StandbyException (cherry picked from commit 701c27a7762294e1a5fb2b3ac81f5534aa37f667) --- .../org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java index 92e6901c91e..7f9a02e5e2e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java @@ -90,6 +90,7 @@ import org.apache.hadoop.io.retry.RetryPolicies; import org.apache.hadoop.io.retry.RetryPolicy; import org.apache.hadoop.io.retry.RetryUtils; import org.apache.hadoop.ipc.RemoteException; +import org.apache.hadoop.ipc.StandbyException; import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.security.AccessControlException; import org.apache.hadoop.security.SecurityUtil; @@ -479,6 +480,13 @@ public class WebHdfsFileSystem extends FileSystem } IOException re = JsonUtilClient.toRemoteException(m); + + //check if exception is due to communication with a Standby name node + if (re.getMessage() != null && re.getMessage().endsWith( + StandbyException.class.getSimpleName())) { + LOG.trace("Detected StandbyException", re); + throw new IOException(re); + } // extract UGI-related exceptions and unwrap InvalidToken // the NN mangles these exceptions but the DN does not and may need // to re-fetch a token if either report the token is expired