HADOOP-14669. GenericTestUtils.waitFor should use monotonic time. Contributed by Daniel Templeton
This commit is contained in:
parent
2843c688bc
commit
df180259b0
@ -356,10 +356,10 @@ public static void waitFor(Supplier<Boolean> check, int checkEveryMillis,
|
|||||||
Preconditions.checkArgument(waitForMillis >= checkEveryMillis,
|
Preconditions.checkArgument(waitForMillis >= checkEveryMillis,
|
||||||
ERROR_INVALID_ARGUMENT);
|
ERROR_INVALID_ARGUMENT);
|
||||||
|
|
||||||
long st = Time.now();
|
long st = Time.monotonicNow();
|
||||||
boolean result = check.get();
|
boolean result = check.get();
|
||||||
|
|
||||||
while (!result && (Time.now() - st < waitForMillis)) {
|
while (!result && (Time.monotonicNow() - st < waitForMillis)) {
|
||||||
Thread.sleep(checkEveryMillis);
|
Thread.sleep(checkEveryMillis);
|
||||||
result = check.get();
|
result = check.get();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user