use of org.batfish.common.util.Backoff in project batfish by batfish.
the class Client method pollWork.
private boolean pollWork(UUID wItemId, @Nullable FileWriter outWriter) {
Pair<WorkStatusCode, String> response;
try (ActiveSpan workStatusSpan = GlobalTracer.get().buildSpan("Waiting for work status").startActive()) {
// avoid unused warning
assert workStatusSpan != null;
// Poll the work item until it finishes or fails.
response = _workHelper.getWorkStatus(wItemId);
if (response == null) {
return false;
}
WorkStatusCode status = response.getFirst();
Backoff backoff = Backoff.builder().withMaximumBackoff(Duration.ofSeconds(1)).build();
while (!status.isTerminated() && backoff.hasNext()) {
printWorkStatusResponse(response, false);
try {
Thread.sleep(backoff.nextBackoff().toMillis());
} catch (InterruptedException e) {
throw new BatfishException("Interrupted while waiting for work item to complete", e);
}
response = _workHelper.getWorkStatus(wItemId);
if (response == null) {
return false;
}
status = response.getFirst();
}
printWorkStatusResponse(response, false);
}
return true;
}
Aggregations