From 201b7879ba6994400c1aa955f242665c16c2c0ea Mon Sep 17 00:00:00 2001 From: Suresh Srinivas Date: Tue, 27 Sep 2011 23:16:17 +0000 Subject: [PATCH] HDFS-2373. Commands using webhdfs and hftp print unnecessary debug info on the console with security enabled. Contributed by Arpit Gupta. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1176654 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 ++ .../hdfs/tools/DelegationTokenFetcher.java | 45 +++++++++++++------ 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index e1c3993e59..40a95c746c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -72,6 +72,9 @@ Trunk (unreleased changes) HDFS-2366. Initialize WebHdfsFileSystem.ugi in object construction. (szetszwo) + HDFS-2373. Commands using webhdfs and hftp print unnecessary debug + info on the console with security enabled. (Arpit Gupta via suresh) + Release 0.23.0 - Unreleased INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DelegationTokenFetcher.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DelegationTokenFetcher.java index d085534e11..1e85393343 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DelegationTokenFetcher.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DelegationTokenFetcher.java @@ -149,7 +149,9 @@ public Object run() throws Exception { DataInputStream in = new DataInputStream( new ByteArrayInputStream(token.getIdentifier())); id.readFields(in); - System.out.println("Token (" + id + ") for " + token.getService()); + if(LOG.isDebugEnabled()) { + LOG.debug("Token (" + id + ") for " + token.getService()); + } } return null; } @@ -160,22 +162,28 @@ public Object run() throws Exception { for (Token token : readTokens(tokenFile, conf)) { result = renewDelegationToken(webUrl, (Token) token); - System.out.println("Renewed token via " + webUrl + " for " - + token.getService() + " until: " + new Date(result)); + if(LOG.isDebugEnabled()) { + LOG.debug("Renewed token via " + webUrl + " for " + + token.getService() + " until: " + new Date(result)); + } } } else if (cancel) { for (Token token : readTokens(tokenFile, conf)) { cancelDelegationToken(webUrl, (Token) token); - System.out.println("Cancelled token via " + webUrl + " for " - + token.getService()); + if(LOG.isDebugEnabled()) { + LOG.debug("Cancelled token via " + webUrl + " for " + + token.getService()); + } } } else { Credentials creds = getDTfromRemote(webUrl, renewer); creds.writeTokenStorageFile(tokenFile, conf); for (Token token : creds.getAllTokens()) { - System.out.println("Fetched token via " + webUrl + " for " - + token.getService() + " into " + tokenFile); + if(LOG.isDebugEnabled()) { + LOG.debug("Fetched token via " + webUrl + " for " + + token.getService() + " into " + tokenFile); + } } } } else { @@ -184,24 +192,30 @@ public Object run() throws Exception { for (Token token : readTokens(tokenFile, conf)) { ((DistributedFileSystem) fs) .cancelDelegationToken((Token) token); - System.out.println("Cancelled token for " - + token.getService()); + if(LOG.isDebugEnabled()) { + LOG.debug("Cancelled token for " + + token.getService()); + } } } else if (renew) { long result; for (Token token : readTokens(tokenFile, conf)) { result = ((DistributedFileSystem) fs) .renewDelegationToken((Token) token); - System.out.println("Renewed token for " + token.getService() - + " until: " + new Date(result)); + if(LOG.isDebugEnabled()) { + LOG.debug("Renewed token for " + token.getService() + + " until: " + new Date(result)); + } } } else { Token token = fs.getDelegationToken(renewer); Credentials cred = new Credentials(); cred.addToken(token.getService(), token); cred.writeTokenStorageFile(tokenFile, conf); - System.out.println("Fetched token for " + token.getService() - + " into " + tokenFile); + if(LOG.isDebugEnabled()) { + LOG.debug("Fetched token for " + token.getService() + + " into " + tokenFile); + } } } return null; @@ -221,6 +235,11 @@ static public Credentials getDTfromRemote(String nnAddr, } else { url.append(nnAddr).append(GetDelegationTokenServlet.PATH_SPEC); } + + if(LOG.isDebugEnabled()) { + LOG.debug("Retrieving token from: " + url); + } + URL remoteURL = new URL(url.toString()); SecurityUtil.fetchServiceTicket(remoteURL); URLConnection connection = remoteURL.openConnection();