private ApplicationReport getAppReport(String appName, long timeoutMs)
      throws LlapStatusCliException {
    Clock clock = SystemClock.getInstance();
    long startTime = clock.getTime();
    long timeoutTime = timeoutMs < 0 ? Long.MAX_VALUE : (startTime + timeoutMs);
    ApplicationReport appReport = null;
    ApplicationId appId;
    try {
      appId = serviceClient.getAppId(appName);
    } catch (YarnException | IOException e) {
      return null;
    }

    while (appReport == null) {
      try {
        appReport = serviceClient.getYarnClient().getApplicationReport(appId);
        if (timeoutMs == 0) {
          // break immediately if timeout is 0
          break;
        }
        // Otherwise sleep, and try again.
        if (appReport == null) {
          long remainingTime = Math.min(timeoutTime - clock.getTime(), 500L);
          if (remainingTime > 0) {
            Thread.sleep(remainingTime);
          } else {
            break;
          }
        }
      } catch (Exception e) {
        if (e instanceof ApplicationNotFoundException) {
          //This might happen when serviceClient caches an appId from the past which is now not
          // valid (i.e. Yarn RM restart). This will force re-creation of service client in the
          // next check (if watch mode is on..) which effectively invalidates such cache.
          serviceClient = null;
        }
        throw new LlapStatusCliException(ExitCode.YARN_ERROR, "Failed to get Yarn AppReport", e);
      }
    }
    return appReport;
  }
Checks the status of the Llap.
llap-server/src/java/org/apache/hadoop/hive/llap/cli/status/LlapStatusServiceDriver.java