Class AccessTokenTimer
java.lang.Object
org.apache.hadoop.hdfs.web.oauth2.AccessTokenTimer
Access tokens generally expire. This timer helps keep track of that.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongGet next time we should refresh the token.voidsetExpiresIn(String expiresIn) Set when the access token will expire as reported by the oauth server, ie in seconds from now.voidsetExpiresInMSSinceEpoch(String expiresInMSSinceEpoch) Set when the access token will expire in milliseconds from epoch, as required by the WebHDFS configuration.booleanReturn 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).
-
Field Details
-
EXPIRE_BUFFER_MS
public static final long EXPIRE_BUFFER_MS- See Also:
-
-
Constructor Details
-
AccessTokenTimer
public AccessTokenTimer() -
AccessTokenTimer
public AccessTokenTimer(org.apache.hadoop.util.Timer timer) - Parameters:
timer- Timer instance for unit testing
-
-
Method Details
-
setExpiresIn
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
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).
-