DelegationTokenRenewer extends AbstractService { @VisibleForTesting protected void setTimerForTokenRenewal(DelegationTokenToRenew token) throws IOException { long expiresIn = token.expirationDate - System.currentTimeMillis(); if (expiresIn <= 0) { LOG.info("Will not renew token " + token); return; } long renewIn = token.expirationDate - expiresIn/10; RenewalTimerTask tTask = new RenewalTimerTask(token); token.setTimerTask(tTask); renewalTimer.schedule(token.timerTask, new Date(renewIn)); LOG.info("Renew " + token + " in " + expiresIn + " ms, appId = " + token.referringAppIds); } DelegationTokenRenewer(); @VisibleForTesting Set<Token<?>> getDelegationTokens(); void addApplicationAsync(ApplicationId applicationId, Credentials ts,
      boolean shouldCancelAtEnd, String user, Configuration tokenConf); void addApplicationAsyncDuringRecovery(ApplicationId applicationId,
      Credentials ts, boolean shouldCancelAtEnd, String user,
      Configuration tokenConf); void addApplicationSync(ApplicationId applicationId, Credentials ts,
      boolean shouldCancelAtEnd, String user); void applicationFinished(ApplicationId applicationId); void updateKeepAliveApplications(List<ApplicationId> appIds); void setRMContext(RMContext rmContext); @VisibleForTesting void setDelegationTokenRenewerPoolTracker(boolean flag); @VisibleForTesting
  static final Text HDFS_DELEGATION_KIND; static final String SCHEME; static final String RM_SYSTEM_CREDENTIALS_VALID_TIME_REMAINING; static final long DEFAULT_RM_SYSTEM_CREDENTIALS_VALID_TIME_REMAINING; }
@Test public void testTokenRenewerInvalidReturn() throws Exception { DelegationTokenToRenew mockDttr = mock(DelegationTokenToRenew.class); mockDttr.expirationDate = 0; delegationTokenRenewer.setTimerForTokenRenewal(mockDttr); assertNull(mockDttr.timerTask); mockDttr.expirationDate = -1; delegationTokenRenewer.setTimerForTokenRenewal(mockDttr); assertNull(mockDttr.timerTask); mockDttr.expirationDate = System.currentTimeMillis() - 1; delegationTokenRenewer.setTimerForTokenRenewal(mockDttr); assertNull(mockDttr.timerTask); }