void startTriggerValidator(long triggerValidationIntervalMs) {
      if (scheduledExecutorService == null) {
        scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(
          new ThreadFactoryBuilder().setDaemon(true).setNameFormat("TriggerValidator").build());
        Runnable triggerValidatorRunnable = getTriggerValidatorRunnable();
        scheduledExecutorService.scheduleWithFixedDelay(triggerValidatorRunnable, triggerValidationIntervalMs,
          triggerValidationIntervalMs, TimeUnit.MILLISECONDS);
        LOG.info("Started trigger validator with interval: {} ms", triggerValidationIntervalMs);
      }
    }
TezSession that is aware of the session pool, and also keeps track of expiration and use.
It has 3 states - not in use, in use, and expired. When in the pool, it is not in use;
use and expiration may compete to take the session out of the pool and change it to the
corresponding states. When someone tries to get a session, they check for expiration time;
if it's time, the expiration is triggered; in that case, or if it was already triggered, the
caller gets a different session. When the session is in use when it expires, the expiration
thread ignores it and lets the return to the pool take care of the expiration.
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionPoolSession.java