public TezApplicationData fetchData(AnalyticJob analyticJob) throws IOException, AuthenticationException {

    int maxSize = 0;
    String appId = analyticJob.getAppId();
    TezApplicationData jobData = new TezApplicationData();
    jobData.setAppId(appId);
    Properties jobConf = _jsonFactory.getProperties(_urlFactory.getApplicationURL(appId));
    jobData.setConf(jobConf);
    URL dagIdsUrl = _urlFactory.getDagURLByTezApplicationId(appId);

    List<String> dagIdsByApplicationId = _jsonFactory.getDagIdsByApplicationId(dagIdsUrl);

    List<TezTaskData> mapperListAggregate = new ArrayList<TezTaskData>();
    List<TezTaskData> reducerListAggregate = new ArrayList<TezTaskData>();
    List<TezTaskData> scopeListAggregate = new ArrayList<TezTaskData>();

    //Iterate over dagIds and choose the dagId with the highest no. of tasks/highest impact as settings changes can be made only at DAG level.
    for(String dagId : dagIdsByApplicationId){
      try {
        //set job task independent properties

        URL dagUrl = _urlFactory.getDagURL(dagId);
        String state = _jsonFactory.getState(dagUrl);

        jobData.setStartTime(_jsonFactory.getDagStartTime(dagUrl));
        jobData.setFinishTime(_jsonFactory.getDagEndTime(dagUrl));

        if (state.equals("SUCCEEDED")) {
          jobData.setSucceeded(true);

          List<TezTaskData> mapperList = new ArrayList<TezTaskData>();
          List<TezTaskData> reducerList = new ArrayList<TezTaskData>();
          List<TezTaskData> scopeTaskList = new ArrayList<TezTaskData>();

          // Fetch task data
          URL vertexListUrl = _urlFactory.getVertexListURL(dagId);
          _jsonFactory.getTaskDataAll(vertexListUrl, dagId, mapperList, reducerList, scopeTaskList);

          if(mapperList.size() + reducerList.size() + scopeTaskList.size() > maxSize){
            mapperListAggregate = mapperList;
            reducerListAggregate = reducerList;
            scopeListAggregate = scopeTaskList;
            maxSize = mapperList.size() + reducerList.size() + scopeTaskList.size();
          }
        }
        if (state.equals("FAILED")) {
          jobData.setSucceeded(false);
        }
      }
      finally {
        ThreadContextMR2.updateAuthToken();
      }
    }

    TezTaskData[] mapperData = mapperListAggregate.toArray(new TezTaskData[mapperListAggregate.size()]);
    TezTaskData[] reducerData = reducerListAggregate.toArray(new TezTaskData[reducerListAggregate.size()]);
    TezTaskData[] scopeTaskData = scopeListAggregate.toArray(new TezTaskData[scopeListAggregate.size()]);

    TezCounterData dagCounter = _jsonFactory.getDagCounter(_urlFactory.getDagURL(_jsonFactory.getDagIdsByApplicationId(dagIdsUrl).get(0)));

    jobData.setCounters(dagCounter).setMapTaskData(mapperData).setReduceTaskData(reducerData).setScopeTasks(scopeTaskData);

    return jobData;
  }
Task level data mining for Tez Tasks from timeline server API
app/com/linkedin/drelephant/tez/fetchers/TezFetcher.java