From 24af0bc144b7e89fc2ea8d2f49b2c8eeb5a2b725 Mon Sep 17 00:00:00 2001 From: Brahma Reddy Battula Date: Mon, 12 Feb 2018 22:14:34 +0530 Subject: [PATCH] HDFS-8693. Addendum patch to execute the command using UGI. Contributed by Brahma Reddy Battula. (cherry picked from commit 35c17351cab645dcc72e0d2ae1608507aa787ffb) --- .../server/datanode/BlockPoolManager.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) 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 f6a11c24bb5..b9d8a362b2a 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("").join(toRefresh)); for (String nsToRefresh : toRefresh) { - BPOfferService bpos = bpByNameserviceId.get(nsToRefresh); + final BPOfferService bpos = bpByNameserviceId.get(nsToRefresh); Map nnIdToAddr = addrMap.get(nsToRefresh); Map nnIdToLifelineAddr = lifelineAddrMap.get(nsToRefresh); - ArrayList addrs = + final ArrayList addrs = Lists.newArrayListWithCapacity(nnIdToAddr.size()); - ArrayList lifelineAddrs = + final ArrayList 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() { + @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; + } } } }