Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CRITEO] Add a property to force canonicalization of hostname with WebHdfsFileSystem #75

Open
wants to merge 2 commits into
base: branch-3.3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public interface HdfsClientConfigKeys {
String DFS_WEBHDFS_OAUTH_ENABLED_KEY = "dfs.webhdfs.oauth2.enabled";
boolean DFS_WEBHDFS_OAUTH_ENABLED_DEFAULT = false;

String DFS_WEBHDFS_HOST_CANONICALIZE_ENABLED_KEY = "dfs.webhdfs.host.canonicalize.enabled";
boolean DFS_WEBHDFS_HOST_CANONICALIZE_ENABLED_DEFAULT = false;

String DFS_WEBHDFS_REST_CSRF_ENABLED_KEY = "dfs.webhdfs.rest-csrf.enabled";
boolean DFS_WEBHDFS_REST_CSRF_ENABLED_DEFAULT = false;
String DFS_WEBHDFS_REST_CSRF_CUSTOM_HEADER_KEY =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,21 @@ public synchronized void initialize(URI uri, Configuration conf
this.uri = URI.create(uri.getScheme() + "://" + uri.getAuthority());
this.nnAddrs = resolveNNAddr();

boolean canonicalizeWebHdfsUri = conf.getBoolean(
HdfsClientConfigKeys.DFS_WEBHDFS_HOST_CANONICALIZE_ENABLED_KEY,
HdfsClientConfigKeys.DFS_WEBHDFS_HOST_CANONICALIZE_ENABLED_DEFAULT
);

if (canonicalizeWebHdfsUri) {
for (int i = 0; i < nnAddrs.length; i++) {
InetSocketAddress nonCanonicalizedAddr = nnAddrs[i];
nnAddrs[i] = new InetSocketAddress(
nonCanonicalizedAddr.getAddress().getCanonicalHostName(),
nonCanonicalizedAddr.getPort()
);
}
}

boolean isHA = HAUtilClient.isClientFailoverConfigured(conf, this.uri);
boolean isLogicalUri = isHA && HAUtilClient.isLogicalUri(conf, this.uri);
// In non-HA or non-logical URI case, the code needs to call
Expand Down