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 3761f4ddb9..fa8f742cfd 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 @@ -34,8 +34,6 @@ 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. */ @@ -169,6 +167,10 @@ private boolean executeHttpOperation(final int retryCount) throws AzureBlobFileS httpOperation.processResponse(buffer, bufferOffset, bufferLength); } catch (IOException ex) { + if (ex instanceof UnknownHostException) { + LOG.warn(String.format("Unknown host name: %s. Retrying to resolve the host name...", httpOperation.getUrl().getHost())); + } + if (LOG.isDebugEnabled()) { if (httpOperation != null) { LOG.debug("HttpRequestFailure: " + httpOperation.toString(), ex); @@ -177,14 +179,6 @@ private boolean executeHttpOperation(final int retryCount) throws AzureBlobFileS } } - 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 ddc1dceaab..bc05e7d64d 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 @@ -21,6 +21,7 @@ import java.util.UUID; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import org.apache.hadoop.fs.FileSystem; @@ -55,8 +56,11 @@ public void testContinuationTokenHavingEqualSign() throws Exception { } } + @Ignore("Enable this to verify the log warning message format for HostNotFoundException") @Test - public void verifyUnknownHost() throws Exception { + public void testUnknownHost() throws Exception { + // When hitting hostName not found exception, the retry will take about 14 mins until failed. + // This test is to verify that the "Unknown host name: %s. Retrying to resolve the host name..." is logged as warning during the retry. AbfsConfiguration conf = this.getConfiguration(); String accountName = this.getAccountName(); String fakeAccountName = "fake" + UUID.randomUUID() + accountName.substring(accountName.indexOf(".")); @@ -66,7 +70,7 @@ public void verifyUnknownHost() throws Exception { conf.set(FS_AZURE_ACCOUNT_KEY + "." + fakeAccountName, this.getAccountKey()); intercept(AbfsRestOperationException.class, - "Can not reach endpoint: " + fakeAccountName, + "UnknownHostException: " + fakeAccountName, () -> FileSystem.get(conf.getRawConfiguration())); } }