@Override
    public void run() {
        int retryCount = 5;
        while (true) {
            JsonElement jsonResponse;

            try {
                WebRequest webRequest = new GetRequestStatusWebRequest(serverParams, clusterName, requestId);
                jsonResponse = RestApiUtils.executeRequest(webRequest);
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
            if (!jsonResponse.isJsonNull()) {
                JsonObject jsonObj = jsonResponse.getAsJsonObject();
                JsonObject jsonRequestsObj = jsonObj.getAsJsonObject("Requests");
                String requestStatus = jsonRequestsObj.get("request_status").getAsString();
                hostRoleStatus = HostRoleStatus.valueOf(requestStatus);

                if (hostRoleStatus == HostRoleStatus.COMPLETED ||
                        hostRoleStatus == HostRoleStatus.ABORTED ||
                        hostRoleStatus == HostRoleStatus.TIMEDOUT ||
                        retryCount == 0)
                    break;
            }

            try {
                Thread.sleep(5000);
            } catch (InterruptedException ex) {
                break;
            }

            retryCount--;
        }
    }
Polls the status of a service component host request.
ambari-funtest/src/test/java/org/apache/ambari/funtest/server/utils/RequestStatusPoller.java