From 4f6e842ba936f4a068168b518eea80bb6dd02d85 Mon Sep 17 00:00:00 2001 From: cnauroth Date: Fri, 9 Oct 2015 14:27:13 -0700 Subject: [PATCH] HDFS-9085. Show renewer information in DelegationTokenIdentifier#toString. Contributed by Zhihai Xu. --- .../token/delegation/DelegationTokenIdentifier.java | 3 ++- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../apache/hadoop/hdfs/security/TestDelegationToken.java | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenIdentifier.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenIdentifier.java index 4544b0ec8bf..62d5b9ba98e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenIdentifier.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenIdentifier.java @@ -61,7 +61,8 @@ public class DelegationTokenIdentifier @Override public String toString() { return getKind() + " token " + getSequenceNumber() - + " for " + getUser().getShortUserName(); + + " for " + getUser().getShortUserName() + " with renewer " + + getRenewer(); } /** @return a string representation of the token */ diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 9d73776d049..6dc949b46db 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -39,6 +39,9 @@ Trunk (Unreleased) HDFS-8981. Adding revision to data node jmx getVersion() method. (Siqi Li via mingma) + HDFS-9085. Show renewer information in DelegationTokenIdentifier#toString. + (Zhihai Xu via cnauroth) + NEW FEATURES HDFS-3125. Add JournalService to enable Journal Daemon. (suresh) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/TestDelegationToken.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/TestDelegationToken.java index 35f31becd1f..35c653decef 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/TestDelegationToken.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/TestDelegationToken.java @@ -314,4 +314,13 @@ public class TestDelegationToken { } }); } + + @Test + public void testDelegationTokenIdentifierToString() throws Exception { + DelegationTokenIdentifier dtId = new DelegationTokenIdentifier(new Text( + "SomeUser"), new Text("JobTracker"), null); + Assert.assertEquals("HDFS_DELEGATION_TOKEN token 0" + + " for SomeUser with renewer JobTracker", + dtId.toString()); + } }