From 3d17c5017604d59b029278a920da3e4606ac3f51 Mon Sep 17 00:00:00 2001 From: Arun Suresh Date: Fri, 10 Apr 2015 11:40:25 -0700 Subject: [PATCH] HDFS-7931. DistributedFileSystem should not look for keyProvider in cache if Encryption is disabled (asuresh) (cherry picked from commit 7660da95cb67cbfe034aa8fa2a5bf0f8c9fdf41a) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../src/main/java/org/apache/hadoop/hdfs/DFSClient.java | 4 ++++ .../java/org/apache/hadoop/hdfs/DistributedFileSystem.java | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 88f8c3907c2..b88dcad15e0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -161,6 +161,9 @@ Release 2.7.1 - UNRELEASED HDFS-8081. Split getAdditionalBlock() into two methods. (shv) + HDFS-7931. DistributedFileSystem should not look for keyProvider in + cache if Encryption is disabled (asuresh) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java index 5fffe012778..3fda9a00761 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java @@ -3537,6 +3537,10 @@ public class DFSClient implements java.io.Closeable, RemotePeerFactory, } } + public boolean isHDFSEncryptionEnabled() { + return conf.get( + DFSConfigKeys.DFS_ENCRYPTION_KEY_PROVIDER_URI, null) != null; + } /** * Returns the SaslDataTransferClient configured for this DFSClient. * diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java index ad4162121b5..ab74b594929 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java @@ -2227,7 +2227,7 @@ public class DistributedFileSystem extends FileSystem { public Token[] addDelegationTokens( final String renewer, Credentials credentials) throws IOException { Token[] tokens = super.addDelegationTokens(renewer, credentials); - if (dfs.getKeyProvider() != null) { + if (dfs.isHDFSEncryptionEnabled()) { KeyProviderDelegationTokenExtension keyProviderDelegationTokenExtension = KeyProviderDelegationTokenExtension. createKeyProviderDelegationTokenExtension(dfs.getKeyProvider());