You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by pt...@apache.org on 2016/04/25 21:30:59 UTC
[2/3] storm git commit: STORM-1535: Make sure hdfs key tab login
happens only once for multiple bolts/executors.
STORM-1535: Make sure hdfs key tab login happens only once for multiple bolts/executors.
Signed-off-by: P. Taylor Goetz <pt...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/6ce8fa81
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/6ce8fa81
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/6ce8fa81
Branch: refs/heads/1.x-branch
Commit: 6ce8fa812301ddb727c9a6e7f40473e37b74f1a2
Parents: 49fade1
Author: Priyank <ps...@hortonworks.com>
Authored: Thu Mar 31 12:46:25 2016 -0700
Committer: P. Taylor Goetz <pt...@gmail.com>
Committed: Mon Apr 25 15:28:49 2016 -0400
----------------------------------------------------------------------
.../hdfs/common/security/HdfsSecurityUtil.java | 25 ++++++++++++--------
1 file changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/6ce8fa81/external/storm-hdfs/src/main/java/org/apache/storm/hdfs/common/security/HdfsSecurityUtil.java
----------------------------------------------------------------------
diff --git a/external/storm-hdfs/src/main/java/org/apache/storm/hdfs/common/security/HdfsSecurityUtil.java b/external/storm-hdfs/src/main/java/org/apache/storm/hdfs/common/security/HdfsSecurityUtil.java
index 993214a..d2f6273 100644
--- a/external/storm-hdfs/src/main/java/org/apache/storm/hdfs/common/security/HdfsSecurityUtil.java
+++ b/external/storm-hdfs/src/main/java/org/apache/storm/hdfs/common/security/HdfsSecurityUtil.java
@@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
import static org.apache.storm.Config.TOPOLOGY_AUTO_CREDENTIALS;
@@ -40,23 +41,27 @@ public class HdfsSecurityUtil {
public static final String STORM_USER_NAME_KEY = "hdfs.kerberos.principal";
private static final Logger LOG = LoggerFactory.getLogger(HdfsSecurityUtil.class);
-
+ private static AtomicBoolean isLoggedIn = new AtomicBoolean();
public static void login(Map conf, Configuration hdfsConfig) throws IOException {
//If AutoHDFS is specified, do not attempt to login using keytabs, only kept for backward compatibility.
if(conf.get(TOPOLOGY_AUTO_CREDENTIALS) == null ||
(!(((List)conf.get(TOPOLOGY_AUTO_CREDENTIALS)).contains(AutoHDFS.class.getName())) &&
!(((List)conf.get(TOPOLOGY_AUTO_CREDENTIALS)).contains(AutoTGT.class.getName())))) {
if (UserGroupInformation.isSecurityEnabled()) {
- LOG.info("Logging in using keytab as AutoHDFS is not specified for " + TOPOLOGY_AUTO_CREDENTIALS);
- String keytab = (String) conf.get(STORM_KEYTAB_FILE_KEY);
- if (keytab != null) {
- hdfsConfig.set(STORM_KEYTAB_FILE_KEY, keytab);
- }
- String userName = (String) conf.get(STORM_USER_NAME_KEY);
- if (userName != null) {
- hdfsConfig.set(STORM_USER_NAME_KEY, userName);
+ // compareAndSet added because of https://issues.apache.org/jira/browse/STORM-1535
+ // need to test it first during ERIE release testing since the JIRA says "might" be and port it to apache.
+ if (isLoggedIn.compareAndSet(false, true)) {
+ LOG.info("Logging in using keytab as AutoHDFS is not specified for " + TOPOLOGY_AUTO_CREDENTIALS);
+ String keytab = (String) conf.get(STORM_KEYTAB_FILE_KEY);
+ if (keytab != null) {
+ hdfsConfig.set(STORM_KEYTAB_FILE_KEY, keytab);
+ }
+ String userName = (String) conf.get(STORM_USER_NAME_KEY);
+ if (userName != null) {
+ hdfsConfig.set(STORM_USER_NAME_KEY, userName);
+ }
+ SecurityUtil.login(hdfsConfig, STORM_KEYTAB_FILE_KEY, STORM_USER_NAME_KEY);
}
- SecurityUtil.login(hdfsConfig, STORM_KEYTAB_FILE_KEY, STORM_USER_NAME_KEY);
}
}
}