private void sessionDestroyOrReturnToPool(Ref<TezSessionState> sessionStateRef,
      TezSessionState sessionState) throws Exception{
    sessionStateRef.value = null;
    if (sessionState.isDefault() && sessionState instanceof TezSessionPoolSession) {
      sessionState.returnToSessionManager();
    } else {
      sessionState.destroy();
    }
  }
Ensures that the Tez Session is open and the AM has all necessary jars configured.
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezTask.java