private boolean killTempletonJobWithRetry(String user, String jobId) {
    /*
     * Make null safe Check if the job submission has gone through and if job is valid.
     */
    if (StringUtils.startsWith(jobId, "job_")) {
      LOG.info("Started killing the job " + jobId);

      boolean success = false;
      int count = 0;
      do {
        try {
          count++;
          killJob(user, jobId);
          success = true;
          LOG.info("Kill job attempt succeeded.");
         } catch (Exception e) {
          LOG.info("Failed to kill the job due to exception: " + e.getMessage());
          LOG.info("Waiting for " + jobTimeoutTaskRetryIntervalInSec + "s before retrying "
                       + "the operation. Iteration: " + count);
          try {
            Thread.sleep(jobTimeoutTaskRetryIntervalInSec * 1000);
          } catch (InterruptedException ex) {
            LOG.info("Got interrupted while waiting for next retry.");
          }
        }
      } while (!success && count < jobTimeoutTaskRetryCount);

      return success;
    } else {
      LOG.info("Couldn't find a valid job id after job request is timed out.");
      return false;
    }
  }
Enqueue the TempletonControllerJob directly calling doAs.
hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/LauncherDelegator.java