This is an automated email from the ASF dual-hosted git repository.

stevel pushed a commit to branch branch-3.2
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-3.2 by this push:
     new 6c2500d  HADOOP-15662. Better exception handling of DNS errors.
6c2500d is described below

commit 6c2500d7caf879d00a4faccf10eebf87739103ac
Author: Da Zhou <da.z...@microsoft.com>
AuthorDate: Thu Jan 10 12:03:48 2019 +0000

    HADOOP-15662. Better exception handling of DNS errors.
    
    Contributed by Da Zhou.
    
    (cherry picked from commit 72112691421bedb66d887ba4e18d1b7d65a42f2c)
---
 .../fs/azurebfs/services/AbfsRestOperation.java    | 12 ++++++++++
 .../apache/hadoop/fs/azurebfs/ITestAbfsClient.java | 27 ++++++++++++++++++++--
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git 
a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsRestOperation.java
 
b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsRestOperation.java
index 9c60f7c..3761f4d 100644
--- 
a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsRestOperation.java
+++ 
b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsRestOperation.java
@@ -21,6 +21,7 @@ package org.apache.hadoop.fs.azurebfs.services;
 import java.io.IOException;
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.net.UnknownHostException;
 import java.util.List;
 
 import org.slf4j.Logger;
@@ -33,6 +34,8 @@ import 
org.apache.hadoop.fs.azurebfs.contracts.exceptions.InvalidAbfsRestOperati
 import org.apache.hadoop.fs.azurebfs.constants.HttpHeaderConfigurations;
 import org.apache.hadoop.fs.azurebfs.oauth2.AzureADAuthenticator.HttpException;
 
+import static 
org.apache.hadoop.fs.azurebfs.contracts.services.AzureServiceErrorCode.UNKNOWN;
+
 /**
  * The AbfsRestOperation for Rest AbfsClient.
  */
@@ -173,6 +176,15 @@ public class AbfsRestOperation {
           LOG.debug("HttpRequestFailure: " + method + "," + url, ex);
         }
       }
+
+      if (ex instanceof UnknownHostException) {
+        throw new AbfsRestOperationException(
+                UNKNOWN.getStatusCode(),
+                UNKNOWN.getErrorCode(),
+                String.format("Can not reach endpoint: %s, please check the 
account setting in configuration file", ex.getMessage()),
+                ex);
+      }
+
       if (!client.getRetryPolicy().shouldRetry(retryCount, -1)) {
         throw new InvalidAbfsRestOperationException(ex);
       }
diff --git 
a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAbfsClient.java
 
b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAbfsClient.java
index 0f231d8..ddc1dce 100644
--- 
a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAbfsClient.java
+++ 
b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAbfsClient.java
@@ -18,11 +18,19 @@
 
 package org.apache.hadoop.fs.azurebfs;
 
+import java.util.UUID;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.hadoop.fs.FileSystem;
 import 
org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsRestOperationException;
 import org.apache.hadoop.fs.azurebfs.services.AbfsClient;
 import org.apache.hadoop.fs.azurebfs.services.AbfsRestOperation;
-import org.junit.Assert;
-import org.junit.Test;
+
+import static 
org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY;
+import static 
org.apache.hadoop.fs.azurebfs.constants.TestConfigurationKeys.FS_AZURE_ACCOUNT_KEY;
+import static org.apache.hadoop.test.LambdaTestUtils.intercept;
 
 /**
  * Test continuation token which has equal sign.
@@ -46,4 +54,19 @@ public final class ITestAbfsClient extends 
AbstractAbfsIntegrationTest {
       Assert.assertEquals("InvalidQueryParameterValue", 
ex.getErrorCode().getErrorCode());
     }
   }
+
+  @Test
+  public void verifyUnknownHost() throws Exception {
+    AbfsConfiguration conf = this.getConfiguration();
+    String accountName = this.getAccountName();
+    String fakeAccountName = "fake" + UUID.randomUUID() + 
accountName.substring(accountName.indexOf("."));
+
+    String fsDefaultFS = conf.get(FS_DEFAULT_NAME_KEY);
+    conf.set(FS_DEFAULT_NAME_KEY, fsDefaultFS.replace(accountName, 
fakeAccountName));
+    conf.set(FS_AZURE_ACCOUNT_KEY + "." + fakeAccountName, 
this.getAccountKey());
+
+    intercept(AbfsRestOperationException.class,
+            "Can not reach endpoint: " + fakeAccountName,
+            () -> FileSystem.get(conf.getRawConfiguration()));
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to