private static void waitForCleanTasksToComplete(ExecutorService executor, List<Future<Void>> cleanTaskFutures)
          throws IOException, HiveException {
    executor.shutdown();
    for (Future<Void> cleanFuture : cleanTaskFutures) {
      try {
        cleanFuture.get();
      } catch (InterruptedException | ExecutionException e) {
        executor.shutdownNow();
        if (e.getCause() instanceof IOException) {
          throw (IOException) e.getCause();
        }
        if (e.getCause() instanceof HiveException) {
          throw (HiveException) e.getCause();
        }
      }
    }
  }
The name of a manifest file consists of the task ID and a .manifest extension, where
the task ID includes the attempt ID as well. It can happen that a task attempt already
wrote out the manifest file, and then fails, so Tez restarts it. If the next attempt
successfully finishes, the query won't fail but there could be multiple manifest files with
the same task ID, but different attempt IDs. In this case the manifest file which has
the highest attempt ID, and not empty, has to be considered.
The empty manifest files and the ones with the same task ID but lower attempt ID has to be ignored.
@param manifestFiles All the files listed in the manifest directory
@return The list of manifest files which have the highest attempt ID and are not empty
ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java