diff --git a/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java b/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java index 3292cb3..1c8c652 100644 --- a/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java +++ b/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java @@ -531,13 +531,27 @@ public void setupConfiguration(Configuration conf) { // else the updates do not get flushed properly KeyProviderCryptoExtension keyProvider = miniDFSCluster.getNameNode().getNamesystem().getProvider(); if (keyProvider != null) { - miniDFSCluster.getFileSystem().getClient().setKeyProvider(keyProvider); + try { + setKeyProvider(miniDFSCluster.getFileSystem().getClient(), keyProvider); + } catch (Exception err) { + throw new IOException(err); + } } cluster = new MiniDFSShim(miniDFSCluster); return cluster; } + private static void setKeyProvider(DFSClient dfsClient, KeyProviderCryptoExtension provider) + throws Exception { + if (setKeyProviderHadoop27Method != null) { + // Cast provider to KeyProvider + setKeyProviderHadoop27Method.invoke(dfsClient, (KeyProvider) provider); + } else { + dfsClient.setKeyProvider(provider); + } + } + /** * MiniDFSShim. * @@ -1021,6 +1035,7 @@ public void mergeCredentials(JobConf dest, JobConf src) throws IOException { protected static final Method accessMethod; protected static final Method getPasswordMethod; + protected static final Method setKeyProviderHadoop27Method; static { Method m = null; @@ -1038,6 +1053,14 @@ public void mergeCredentials(JobConf dest, JobConf src) throws IOException { m = null; } getPasswordMethod = m; + + try { + m = DFSClient.class.getMethod("setKeyProvider", KeyProvider.class); + } catch (NoSuchMethodException err) { + // We can just use setKeyProvider() as it is + m = null; + } + setKeyProviderHadoop27Method = m; } @Override