Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-10211

Add more info to DelegationTokenIdentifier#toString for better supportability

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • None
    • None
    • None
    • None

    Description

      Base class AbstractDelegationTokenIdentifier has the following implementation of toString() method

      @Override
        public String toString() {
          StringBuilder buffer = new StringBuilder();
          buffer
              .append("owner=" + owner + ", renewer=" + renewer + ", realUser="
                  + realUser + ", issueDate=" + issueDate + ", maxDate=" + maxDate
                  + ", sequenceNumber=" + sequenceNumber + ", masterKeyId="
                  + masterKeyId);
          return buffer.toString();
        }
      

      However, derived class
      org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier

      has the following implementation that overrides the base class above:

        @Override
        public String toString() {
          return getKind() + " token " + getSequenceNumber()
              + " for " + getUser().getShortUserName();
        }
      

      And when exception is thrown because of token expiration or other reason (in AbstractDelegationTokenSecretManager#checkToken):

          if (info.getRenewDate() < Time.now()) {
            throw new InvalidToken("token (" + identifier.toString() + ") is expired");
          }
      

      The exception doesn't show the detailed information about the token, like the base class' toString() method returns.

      Creating this jira to change the
      org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier
      implementation to include all the info about the token, as included by the base class.

      This change would help supportability, at the expense of printing a little more information to the log. I hope no code really depends on the output string.

      Attachments

        Issue Links

          Activity

            People

              yzhangal Yongjun Zhang
              yzhangal Yongjun Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: