HDFS-8693. Addendum patch to execute the command using UGI. Contributed by 
Brahma Reddy Battula.

(cherry picked from commit 35c17351cab645dcc72e0d2ae1608507aa787ffb)
(cherry picked from commit 24af0bc144b7e89fc2ea8d2f49b2c8eeb5a2b725)


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

Branch: refs/heads/branch-2.9
Commit: ed512645b28c33cab724324199b606d815c84669
Parents: 41d434d
Author: Brahma Reddy Battula <bra...@apache.org>
Authored: Mon Feb 12 22:14:34 2018 +0530
Committer: Brahma Reddy Battula <bra...@apache.org>
Committed: Mon Feb 12 22:27:21 2018 +0530

----------------------------------------------------------------------
 .../hdfs/server/datanode/BlockPoolManager.java  | 21 ++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed512645/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolManager.java
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolManager.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolManager.java
index f6a11c2..b9d8a36 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolManager.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolManager.java
@@ -240,20 +240,33 @@ class BlockPoolManager {
           Joiner.on(",").useForNull("<default>").join(toRefresh));
       
       for (String nsToRefresh : toRefresh) {
-        BPOfferService bpos = bpByNameserviceId.get(nsToRefresh);
+        final BPOfferService bpos = bpByNameserviceId.get(nsToRefresh);
         Map<String, InetSocketAddress> nnIdToAddr = addrMap.get(nsToRefresh);
         Map<String, InetSocketAddress> nnIdToLifelineAddr =
             lifelineAddrMap.get(nsToRefresh);
-        ArrayList<InetSocketAddress> addrs =
+        final ArrayList<InetSocketAddress> addrs =
             Lists.newArrayListWithCapacity(nnIdToAddr.size());
-        ArrayList<InetSocketAddress> lifelineAddrs =
+        final ArrayList<InetSocketAddress> lifelineAddrs =
             Lists.newArrayListWithCapacity(nnIdToAddr.size());
         for (String nnId : nnIdToAddr.keySet()) {
           addrs.add(nnIdToAddr.get(nnId));
           lifelineAddrs.add(nnIdToLifelineAddr != null ?
               nnIdToLifelineAddr.get(nnId) : null);
         }
-        bpos.refreshNNList(addrs, lifelineAddrs);
+        try {
+          UserGroupInformation.getLoginUser()
+              .doAs(new PrivilegedExceptionAction<Object>() {
+                @Override
+                public Object run() throws Exception {
+                  bpos.refreshNNList(addrs, lifelineAddrs);
+                  return null;
+                }
+              });
+        } catch (InterruptedException ex) {
+          IOException ioe = new IOException();
+          ioe.initCause(ex.getCause());
+          throw ioe;
+        }
       }
     }
   }


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

Reply via email to