AccessTokenTimer (Apache Hadoop Main 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.web.oauth2, class: AccessTokenTimer

Package org.apache.hadoop.hdfs.web.oauth2

# 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 Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final long`
  `EXPIRE_BUFFER_MS`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AccessTokenTimer()`
  `AccessTokenTimer(org.apache.hadoop.util.Timer timer)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `getNextRefreshMSSinceEpoch()`
  Get next time we should refresh the token.
  `void`
  `setExpiresIn(String expiresIn)`
  Set when the access token will expire as reported by the oauth server, ie in seconds from now.
  `void`
  `setExpiresInMSSinceEpoch(String expiresInMSSinceEpoch)`
  Set when the access token will expire in milliseconds from epoch, as required by the WebHDFS configuration.
  `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).

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### EXPIRE_BUFFER_MS

    public static final long EXPIRE_BUFFER_MS
    See Also:
      - Constant Field Values

- ## 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).