From fed2339e285e84a40514f877703b2712a2305a6f Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Mon, 7 Mar 2016 14:00:02 -0800 Subject: [PATCH] HADOOP-12901. Add warning log when KMSClientProvider cannot create a connection to the KMS server. (Xiao Chen via wang) (cherry picked from commit 391da36d93358038c50c15d91543f6c765fa0471) --- .../apache/hadoop/crypto/key/kms/KMSClientProvider.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/kms/KMSClientProvider.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/kms/KMSClientProvider.java index a73eda6893a..1fc9e2b621d 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/kms/KMSClientProvider.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/kms/KMSClientProvider.java @@ -42,6 +42,8 @@ import org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthentica import org.apache.hadoop.util.HttpExceptionUtils; import org.apache.http.client.utils.URIBuilder; import org.codehaus.jackson.map.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.net.ssl.HttpsURLConnection; @@ -85,6 +87,9 @@ import com.google.common.base.Strings; public class KMSClientProvider extends KeyProvider implements CryptoExtension, KeyProviderDelegationTokenExtension.DelegationTokenExtension { + private static final Logger LOG = + LoggerFactory.getLogger(KMSClientProvider.class); + private static final String INVALID_SIGNATURE = "Invalid signature"; private static final String ANONYMOUS_REQUESTS_DISALLOWED = "Anonymous requests are disallowed"; @@ -491,6 +496,9 @@ public class KMSClientProvider extends KeyProvider implements CryptoExtension, } }); } catch (IOException ex) { + if (ex instanceof SocketTimeoutException) { + LOG.warn("Failed to connect to {}:{}", url.getHost(), url.getPort()); + } throw ex; } catch (UndeclaredThrowableException ex) { throw new IOException(ex.getUndeclaredThrowable());