public static Optional<Token<?>> getTokenFromSeqFile(String userNameKey, Path tokenFilePath) throws IOException {
    log.info("Reading tokens from sequence file " + tokenFilePath);

    try (Closer closer = Closer.create()) {
      FileSystem localFs = FileSystem.getLocal(new Configuration());
      @SuppressWarnings("deprecation")
      SequenceFile.Reader tokenReader =
          closer.register(new SequenceFile.Reader(localFs, tokenFilePath, localFs.getConf()));
      Text key = new Text();
      Token<?> value = new Token<>();
      while (tokenReader.next(key, value)) {
        log.debug("Found token for user: " + key);
        if (key.toString().equals(userNameKey)) {
          return Optional.<Token<?>> of(value);
        }
      }
    }
    log.warn("Did not find any tokens for user " + userNameKey);
    return Optional.absent();
  }
public static Optional < Token < ? > > getTokenFromSeqFile ( String userNameKey , Path tokenFilePath ) throws IOException { log . info ( "Reading tokens from sequence file " + tokenFilePath ) ; try ( Closer closer = Closer . create ( ) ) { FileSystem localFs = FileSystem . getLocal ( new Configuration ( ) ) ; @ SuppressWarnings ( "deprecation" ) SequenceFile . Reader tokenReader = closer . register ( new SequenceFile . Reader ( localFs , tokenFilePath , localFs . getConf ( ) ) ) ; Text key = new Text ( ) ; Token < ? > value = new Token < > ( ) ; while ( tokenReader . next ( key , value ) ) { log . debug ( "Found token for user: " + key ) ; if ( key . toString ( ) . equals ( userNameKey ) ) { return Optional . < Token < ? > > of ( value ) ; } } } log . warn ( "Did not find any tokens for user " + userNameKey ) ; return Optional . absent ( ) ; }
Retrives a {@link Token} from a given sequence file for a specified user. The sequence file should contain a list
of key, value pairs where each key corresponds to a user and each value corresponds to a {@link Token} for that
user.

@param userNameKey The name of the user to retrieve a {@link Token} for
@param tokenFilePath The path to the sequence file containing the {@link Token}s

@return A {@link Token} for the given user name