fix: sleep in MdsTaskRetryWrapper
This commit is contained in:
parent
84b1120efb
commit
d2c1efe63a
@ -12,7 +12,7 @@ public record MdsTaskRetryWrapper(Map<String, ExponentialBackoff> backoffs, Thro
|
||||
public void accept(MdsMod mod) throws IOException {
|
||||
String key = mod.getMetadataPath().getFileName().toString() + "/" + inner.getClass().getTypeName();
|
||||
ExponentialBackoff backoff = backoffs.computeIfAbsent(key, _ -> new ExponentialBackoff());
|
||||
if (!backoff.shouldTry()) return;
|
||||
backoff.sleep();
|
||||
try {
|
||||
inner.accept(mod);
|
||||
backoff.success();
|
||||
|
@ -12,6 +12,15 @@ public class ExponentialBackoff {
|
||||
return retries == 0 || System.currentTimeMillis() > nextRetry;
|
||||
}
|
||||
|
||||
public void sleep() {
|
||||
try {
|
||||
long time = nextRetry - System.currentTimeMillis();
|
||||
if (time > 0) Thread.sleep(time);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
public void success() {
|
||||
retries = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user