|
@@ -21,6 +21,8 @@ package org.apache.hadoop.fs.s3a.impl;
|
|
|
import java.io.IOException;
|
|
|
import java.lang.reflect.Constructor;
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
+import java.net.URI;
|
|
|
+import java.net.URISyntaxException;
|
|
|
|
|
|
import javax.net.ssl.HostnameVerifier;
|
|
|
import javax.net.ssl.SSLSocketFactory;
|
|
@@ -30,9 +32,12 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
+import org.apache.hadoop.net.NetUtils;
|
|
|
import org.apache.hadoop.security.ssl.DelegatingSSLSocketFactory;
|
|
|
|
|
|
+import static org.apache.hadoop.fs.s3a.Constants.DEFAULT_ENDPOINT;
|
|
|
import static org.apache.hadoop.fs.s3a.Constants.DEFAULT_SSL_CHANNEL_MODE;
|
|
|
+import static org.apache.hadoop.fs.s3a.Constants.ENDPOINT;
|
|
|
import static org.apache.hadoop.fs.s3a.Constants.SSL_CHANNEL_MODE;
|
|
|
|
|
|
/**
|
|
@@ -121,4 +126,30 @@ public class NetworkBinding {
|
|
|
? "us-east-1"
|
|
|
: region;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Log the dns address associated with s3 endpoint. If endpoint is
|
|
|
+ * not set in the configuration, the {@code Constants#DEFAULT_ENDPOINT}
|
|
|
+ * will be used.
|
|
|
+ * @param conf input configuration.
|
|
|
+ */
|
|
|
+ public static void logDnsLookup(Configuration conf) {
|
|
|
+ String endPoint = conf.getTrimmed(ENDPOINT, DEFAULT_ENDPOINT);
|
|
|
+ String hostName = endPoint;
|
|
|
+ if (!endPoint.isEmpty() && LOG.isDebugEnabled()) {
|
|
|
+ // Updating the hostname if there is a scheme present.
|
|
|
+ if (endPoint.contains("://")) {
|
|
|
+ try {
|
|
|
+ URI uri = new URI(endPoint);
|
|
|
+ hostName = uri.getHost();
|
|
|
+ } catch (URISyntaxException e) {
|
|
|
+ LOG.debug("Got URISyntaxException, ignoring");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ LOG.debug("Bucket endpoint : {}, Hostname : {}, DNSAddress : {}",
|
|
|
+ endPoint,
|
|
|
+ hostName,
|
|
|
+ NetUtils.normalizeHostName(hostName));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|