public boolean tryUse(boolean ignoreExpiration) {
    while (true) {
      int oldValue = sessionState.get();
      if (oldValue == STATE_IN_USE) throw new AssertionError(this + " is already in use");
      if (oldValue == STATE_EXPIRED) return false;
      int finalState = (!ignoreExpiration && shouldExpire()) ? STATE_EXPIRED : STATE_IN_USE;
      if (sessionState.compareAndSet(STATE_NONE, finalState)) {
        if (finalState == STATE_IN_USE) return true;
        // Restart asynchronously, don't block the caller.
        expirationTracker.closeAndRestartExpiredSessionAsync(this);
        return false;
      }
    }
  }
Tries to use this session. When the session is in use, it will not expire.
@return true if the session can be used; false if it has already expired.
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionPoolSession.java