private String extractQueryIdFromContext() {
    //TODO: Remove following instance of check, When TEZ-2672 exposes getConf from DagInfo
    DagInfo dagInfo = getContext().getCurrentDagInfo();
    if (dagInfo instanceof DAG) {
      return ((DAG)dagInfo).getConf().get(ConfVars.HIVE_QUERY_ID.varname);
    }
    return null;
  }
This is a best effort action in case of an invalid LLAP_TOKEN. The communicator (LlapProtocolClientProxy) periodically
refreshes tokens, but there is a relatively small time window (compared to the whole token maxLifetime),
when the token is cancelled and it's not yet fetched from daemons. By the time we detect this problem, the current
task attempt is already failed, but usually there are at least 3 task attempts before failing the task and dag, therefore
fetching an LLAP_TOKEN synchronously here definitely solves the invalid token problem (as the next task attempt will use it).
llap-tez/src/java/org/apache/hadoop/hive/llap/tezplugins/LlapTaskCommunicator.java