public ExitCode run(LlapStatusServiceCommandLine cl, long watchTimeoutMs) {
    appStatusBuilder = new AppStatusBuilder();
    try {
      if (appName == null) {
        // user provided configs
        for (Map.Entry<Object, Object> props : cl.getHiveConf().entrySet()) {
          conf.set((String) props.getKey(), (String) props.getValue());
        }

        appName = cl.getName();
        if (StringUtils.isEmpty(appName)) {
          appName = HiveConf.getVar(conf, HiveConf.ConfVars.LLAP_DAEMON_SERVICE_HOSTS);
          if (appName.startsWith("@") && appName.length() > 1) {
            // This is a valid YARN Service name. Parse it out.
            appName = appName.substring(1);
          } else {
            // Invalid app name. Checked later.
            appName = null;
          }
        }
        if (StringUtils.isEmpty(appName)) {
          LOG.error("Invalid app name. This must be setup via config or passed in as a parameter." +
              " This tool works with clusters deployed by YARN Service");
          return ExitCode.INCORRECT_USAGE;
        }
        LOG.debug("Using appName: {}", appName);

        llapRegistryConf.set(HiveConf.ConfVars.LLAP_DAEMON_SERVICE_HOSTS.varname, "@" + appName);
      }

      try {
        if (serviceClient == null) {
          serviceClient = LlapSliderUtils.createServiceClient(conf);
        }
      } catch (Exception e) {
        LlapStatusCliException le = new LlapStatusCliException(
            ExitCode.SERVICE_CLIENT_ERROR_CREATE_FAILED, "Failed to create service client", e);
        logError(le);
        return le.getExitCode();
      }

      // Get the App report from YARN
      ApplicationReport appReport;
      try {
        appReport = getAppReport(appName, cl.getFindAppTimeoutMs());
      } catch (LlapStatusCliException e) {
        logError(e);
        return e.getExitCode();
      }

      // Process the report
      ExitCode ret;
      try {
        ret = processAppReport(appReport, appStatusBuilder);
      } catch (LlapStatusCliException e) {
        logError(e);
        return e.getExitCode();
      }

      if (ret != ExitCode.SUCCESS) {
        return ret;
      } else if (NO_YARN_SERVICE_INFO_STATES.contains(appStatusBuilder.getState())) {
        return ExitCode.SUCCESS;
      } else {
        // Get information from YARN Service
        try {
          ret = populateAppStatusFromServiceStatus(appName, serviceClient, appStatusBuilder);
        } catch (LlapStatusCliException e) {
          // In case of failure, send back whatever is constructed so far - which would be from the AppReport
          logError(e);
          return e.getExitCode();
        }
      }

      if (ret != ExitCode.SUCCESS) {
        return ret;
      } else {
        try {
          ret = populateAppStatusFromLlapRegistry(appStatusBuilder, watchTimeoutMs);
        } catch (LlapStatusCliException e) {
          logError(e);
          return e.getExitCode();
        }
      }

      return ret;
    } finally {
      LOG.debug("Final AppState: " + appStatusBuilder.toString());
    }
  }
Checks the status of the Llap.
llap-server/src/java/org/apache/hadoop/hive/llap/cli/status/LlapStatusServiceDriver.java