Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Add delay between attempts of invoking requests
Browse files Browse the repository at this point in the history
With the current implementation, the client intensively sends requests
to the workflow service if the former request failed.
This intensity leads to high CPU consumption which impacts both client
and mainly the server.

By adding a small timeout between failed requests, the chance for
completing a workflow increases and so the resource consumption drops
significantly (20% CPU vs over 100%).

This is a temporary fix before replacing the current implementation with
Executor service and future.

Signed-off-by: Moti Asayag <masayag@redhat.com>
  • Loading branch information
masayag authored and openshift-merge-robot committed Jun 6, 2023
1 parent 7781200 commit 02a1e12
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ public static <T> T waitAsyncResponse(FuncExecutor<T> f) throws ApiException, In
public void onFailure(ApiException e, int statusCode, Map<String, List<String>> responseHeaders) {
log.info("onFailure {}", e.getMessage());
try {
Thread.sleep(3000);
f.execute(this);
}
catch (ApiException apie) {
catch (ApiException | InterruptedException apie) {
asyncResult.setError(apie.getMessage());
signal();
}
Expand All @@ -133,9 +134,10 @@ public void onFailure(ApiException e, int statusCode, Map<String, List<String>>
public void onSuccess(T result, int statusCode, Map<String, List<String>> responseHeaders) {
if (f.check(result, statusCode)) {
try {
Thread.sleep(3000);
f.execute(this);
}
catch (ApiException apie) {
catch (ApiException | InterruptedException apie) {
asyncResult.setError(apie.getMessage());
signal();
}
Expand Down

0 comments on commit 02a1e12

Please sign in to comment.