hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From su...@apache.org
Subject [04/50] [abbrv] hadoop git commit: HDFS-11702. Remove indefinite caching of key provider uri in DFSClient. Contributed by Rushabh S Shah.
Date Mon, 08 May 2017 23:53:32 GMT
HDFS-11702. Remove indefinite caching of key provider uri in DFSClient. Contributed by Rushabh
S Shah.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/cef2815c
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/cef2815c
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/cef2815c

Branch: refs/heads/YARN-2915
Commit: cef2815cf48154fe82f44082dcbdce6373c81284
Parents: a9a3d21
Author: Kihwal Lee <kihwal@apache.org>
Authored: Mon May 8 08:27:37 2017 -0500
Committer: Kihwal Lee <kihwal@apache.org>
Committed: Mon May 8 08:27:37 2017 -0500

----------------------------------------------------------------------
 .../main/java/org/apache/hadoop/hdfs/DFSClient.java   | 14 +-------------
 .../org/apache/hadoop/hdfs/TestEncryptionZones.java   |  9 ---------
 2 files changed, 1 insertion(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/cef2815c/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
index 3f1f3ea..d21b9b4 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
@@ -232,7 +232,6 @@ public class DFSClient implements java.io.Closeable, RemotePeerFactory,
   private static ThreadPoolExecutor HEDGED_READ_THREAD_POOL;
   private static volatile ThreadPoolExecutor STRIPED_READ_THREAD_POOL;
   private final int smallBufferSize;
-  private URI keyProviderUri = null;
 
   public DfsClientConf getConf() {
     return dfsClientConf;
@@ -2901,10 +2900,7 @@ public class DFSClient implements java.io.Closeable, RemotePeerFactory,
    * @throws IOException
    */
   URI getKeyProviderUri() throws IOException {
-    if (keyProviderUri != null) {
-      return keyProviderUri;
-    }
-
+    URI keyProviderUri = null;
     // Lookup the secret in credentials object for namenodeuri.
     Credentials credentials = ugi.getCredentials();
     byte[] keyProviderUriBytes = credentials.getSecretKey(getKeyProviderMapKey());
@@ -2936,14 +2932,6 @@ public class DFSClient implements java.io.Closeable, RemotePeerFactory,
     return clientContext.getKeyProviderCache().get(conf, getKeyProviderUri());
   }
 
-  /*
-   * Should be used only for testing.
-   */
-  @VisibleForTesting
-  public void setKeyProviderUri(URI providerUri) {
-    this.keyProviderUri = providerUri;
-  }
-
   @VisibleForTesting
   public void setKeyProvider(KeyProvider provider) {
     clientContext.getKeyProviderCache().setKeyProvider(conf, provider);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/cef2815c/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
index 093d516..8eb3b7b 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
@@ -1702,7 +1702,6 @@ public class TestEncryptionZones {
     credentials.addSecretKey(lookUpKey,
         DFSUtilClient.string2Bytes(dummyKeyProvider));
     client.ugi.addCredentials(credentials);
-    client.setKeyProviderUri(null);
     Assert.assertEquals("Client Key provider is different from provider in "
         + "credentials map", dummyKeyProvider,
         client.getKeyProviderUri().toString());
@@ -1724,7 +1723,6 @@ public class TestEncryptionZones {
         CommonConfigurationKeysPublic.HADOOP_SECURITY_KEY_PROVIDER_PATH,
         dummyKeyProviderUri1);
     DFSClient mockClient = Mockito.spy(cluster.getFileSystem().getClient());
-    mockClient.setKeyProviderUri(null);
     // Namenode returning null as keyProviderUri in FSServerDefaults.
     FsServerDefaults serverDefaultsWithKeyProviderNull =
         getTestServerDefaults(null);
@@ -1736,7 +1734,6 @@ public class TestEncryptionZones {
     Mockito.verify(mockClient, Mockito.times(1)).getServerDefaults();
 
     String dummyKeyProviderUri2 = "dummy://foo:bar@test_provider2";
-    mockClient.setKeyProviderUri(null);
     FsServerDefaults serverDefaultsWithDummyKeyProvider =
         getTestServerDefaults(dummyKeyProviderUri2);
     // Namenode returning dummyKeyProvider2 in serverDefaults.
@@ -1765,8 +1762,6 @@ public class TestEncryptionZones {
     // Unset the provider path in conf
     clusterConf.unset(
         CommonConfigurationKeysPublic.HADOOP_SECURITY_KEY_PROVIDER_PATH);
-    // Nullify the cached value for key provider uri on client
-    cluster.getFileSystem().getClient().setKeyProviderUri(null);
     // Even after unsetting the local conf, the client key provider should be
     // the same as namenode's provider.
     Assert.assertEquals("Key Provider for client and namenode are different",
@@ -1777,8 +1772,6 @@ public class TestEncryptionZones {
     clusterConf.set(
         CommonConfigurationKeysPublic.HADOOP_SECURITY_KEY_PROVIDER_PATH,
         "dummy://foo:bar@test_provider1");
-    // Nullify the cached value for key provider uri on client
-    cluster.getFileSystem().getClient().setKeyProviderUri(null);
     // Even after pointing the conf to some dummy provider, the client key
     // provider should be the same as namenode's provider.
     Assert.assertEquals("Key Provider for client and namenode are different",
@@ -1813,8 +1806,6 @@ public class TestEncryptionZones {
     // Creating a fake serverdefaults so that we can simulate namenode not
     // being upgraded.
     DFSClient spyClient = Mockito.spy(cluster.getFileSystem().getClient());
-    // Clear the cache value of keyProviderUri on client side.
-    spyClient.setKeyProviderUri(null);
     Mockito.doReturn(spyServerDefaults).when(spyClient).getServerDefaults();
 
     // Since FsServerDefaults#keyProviderUri is null, the client


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message