List of usage examples for org.apache.hadoop.hdfs.security.token.delegation DelegationTokenIdentifier getIssueDate
public long getIssueDate()
From source file:co.cask.cdap.app.runtime.spark.SparkCredentialsUpdater.java
License:Apache License
@VisibleForTesting long getNextUpdateDelay(Credentials credentials) throws IOException { long now = System.currentTimeMillis(); // This is almost the same logic as in SparkHadoopUtil.getTimeFromNowToRenewal for (Token<? extends TokenIdentifier> token : credentials.getAllTokens()) { if (DelegationTokenIdentifier.HDFS_DELEGATION_KIND.equals(token.getKind())) { DelegationTokenIdentifier identifier = new DelegationTokenIdentifier(); try (DataInputStream input = new DataInputStream(new ByteArrayInputStream(token.getIdentifier()))) { identifier.readFields(input); // speed up by 2 seconds to account for any time race between driver and executor return Math.max(0L, (long) (identifier.getIssueDate() + 0.8 * updateIntervalMs) - now - 2000); }/*from ww w . ja v a2 s . c om*/ } } return 0L; }