Class AccessTokenTimer

java.lang.Object
org.apache.hadoop.hdfs.web.oauth2.AccessTokenTimer

@Public @Evolving public class AccessTokenTimer extends Object
Access tokens generally expire. This timer helps keep track of that.
  • Field Details

  • Constructor Details

    • AccessTokenTimer

      public AccessTokenTimer()
    • AccessTokenTimer

      public AccessTokenTimer(org.apache.hadoop.util.Timer timer)
      Parameters:
      timer - Timer instance for unit testing
  • Method Details

    • setExpiresIn

      public void setExpiresIn(String expiresIn)
      Set when the access token will expire as reported by the oauth server, ie in seconds from now.
      Parameters:
      expiresIn - Access time expiration as reported by OAuth server
    • setExpiresInMSSinceEpoch

      public void setExpiresInMSSinceEpoch(String expiresInMSSinceEpoch)
      Set when the access token will expire in milliseconds from epoch, as required by the WebHDFS configuration. This is a bit hacky and lame.
      Parameters:
      expiresInMSSinceEpoch - Access time expiration in ms since epoch.
    • getNextRefreshMSSinceEpoch

      public long getNextRefreshMSSinceEpoch()
      Get next time we should refresh the token.
      Returns:
      Next time since epoch we'll need to refresh the token.
    • shouldRefresh

      public boolean shouldRefresh()
      Return true if the current token has expired or will expire within the EXPIRE_BUFFER_MS (to give ample wiggle room for the call to be made to the server).