private TezClient startSessionAndContainers(TezClient session, HiveConf conf,
      Map<String, LocalResource> commonLocalResources, TezConfiguration tezConfig,
      boolean isOnThread) throws TezException, IOException {
    boolean isSuccessful = false;
    try {
      session.start();
      if (HiveConf.getBoolVar(conf, ConfVars.HIVE_PREWARM_ENABLED)) {
        int n = HiveConf.getIntVar(conf, ConfVars.HIVE_PREWARM_NUM_CONTAINERS);
        LOG.info("Prewarming " + n + " containers  (id: " + sessionId
            + ", scratch dir: " + tezScratchDir + ")");
        PreWarmVertex prewarmVertex = utils.createPreWarmVertex(
            tezConfig, n, commonLocalResources);
        try {
          session.preWarm(prewarmVertex);
        } catch (IOException ie) {
          if (!isOnThread && ie.getMessage().contains("Interrupted while waiting")) {
            LOG.warn("Hive Prewarm threw an exception ", ie);
          } else {
            throw ie;
          }
        }
      }
      try {
        session.waitTillReady();
      } catch (InterruptedException ie) {
        if (isOnThread) {
          throw new IOException(ie);
          //ignore
        }
      }
      isSuccessful = true;
      // sessionState.getQueueName() comes from cluster wide configured queue names.
      // sessionState.getConf().get("tez.queue.name") is explicitly set by user in a session.
      // TezSessionPoolManager sets tez.queue.name if user has specified one or use the one from
      // cluster wide queue names.
      // There is no way to differentiate how this was set (user vs system).
      // Unset this after opening the session so that reopening of session uses the correct queue
      // names i.e, if client has not died and if the user has explicitly set a queue name
      // then reopened session will use user specified queue name else default cluster queue names.
      if (conf.getBoolVar(ConfVars.HIVE_SERVER2_TEZ_INITIALIZE_DEFAULT_SESSIONS)) {
        LOG.debug("Unsetting tez.queue.name (from: {})", conf.get(TezConfiguration.TEZ_QUEUE_NAME));
        conf.unset(TezConfiguration.TEZ_QUEUE_NAME);
      }
      return session;
    } finally {
      if (isOnThread && !isSuccessful) {
        closeAndIgnoreExceptions(session);
      }
      if (!isSuccessful) {
        cleanupScratchDir();
        cleanupDagResources();
      }
    }
  }
Check if Kerberos authentication is enabled.
This is used by:
- HS2 (upon Tez session creation)
In secure scenarios HS2 might either be logged on (by Kerberos) by itself or by a launcher
script it was forked from. In the latter case UGI.getLoginUser().isFromKeytab() returns false,
hence UGI.getLoginUser().hasKerberosCredentials() is a tightest setting we can check against.
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionState.java