private List<Node> getTopNodes(BaseWork work) {
    List<Node> topNodes = new ArrayList<Node>();

    if (work instanceof MapWork) {
      Map<String, Operator<? extends OperatorDesc>> aliasToWork = ((MapWork) work).getAliasToWork();
      for (Operator<? extends OperatorDesc> operator : aliasToWork.values()) {
        topNodes.add(operator);
      }
    } else if (work instanceof ReduceWork) {
      topNodes.add(((ReduceWork) work).getReducer());
    } else if (work instanceof MergeJoinWork) {
      for (Operator<? extends OperatorDesc> operator : ((MergeJoinWork) work)
          .getAllRootOperators()) {
        topNodes.add(operator);
      }
    } else if (work instanceof UnionWork) {
      for (Operator<? extends OperatorDesc> operator : ((UnionWork) work).getAllRootOperators()) {
        topNodes.add(operator);
      }
    }

    return topNodes;
  }
Set up credentials for the base work on secure clusters
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/DagUtils.java