private void shutdownAndAwaitTermination(ExecutorService threadPool) {

    // Disable new tasks from being submitted
    threadPool.shutdown();
    try {

      // Wait a while for existing tasks to terminate
      // XXX this will wait forever... :)
      while (!threadPool.awaitTermination(10, TimeUnit.SECONDS)) {
        LOG.debug("Waiting for all stats tasks to finish...");
      }
      // Cancel currently executing tasks
      threadPool.shutdownNow();

      // Wait a while for tasks to respond to being cancelled
      if (!threadPool.awaitTermination(100, TimeUnit.SECONDS)) {
        LOG.debug("Stats collection thread pool did not terminate");
      }
    } catch (InterruptedException ie) {

      // Cancel again if current thread also interrupted
      threadPool.shutdownNow();

      // Preserve interrupt status
      Thread.currentThread().interrupt();
    }
  }
StatsNoJobTask is used in cases where stats collection is the only task for the given query (no
parent MR or Tez job). It is used in the following cases 1) ANALYZE with noscan for
file formats that implement StatsProvidingRecordReader interface: ORC format (implements
StatsProvidingRecordReader) stores column statistics for all columns in the file footer. It's much
faster to compute the table/partition statistics by reading the footer than scanning all the
rows. This task can be used for computing basic stats like numFiles, numRows, fileSize,
rawDataSize from ORC footer.
However, this cannot be used for full ACID tables, since some files may contain updates
and deletes to existing rows, so summing up the per-file row counts is invalid.
ql/src/java/org/apache/hadoop/hive/ql/stats/BasicStatsNoJobTask.java