sv2000 commented on a change in pull request #2907: [GOBBLIN-1068]Clean up
cyclic logic in task cancellation
URL: https://github.com/apache/incubator-gobblin/pull/2907#discussion_r387986073
##########
File path:
gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SleepingTask.java
##########
@@ -64,19 +74,27 @@ public void run() {
throw new IOException("File creation error: " +
taskStateFile.getName());
}
long endTime = System.currentTimeMillis() + sleepTime * 1000;
- while (System.currentTimeMillis() <= endTime) {
- Thread.sleep(1000L);
- log.warn("Sleeping for {} seconds", sleepTime);
- }
+
+
AssertWithBackoff.create().maxSleepMs(1000).timeoutMs(Integer.MAX_VALUE).backoffFactor(1).
+ assertTrue(new Predicate<Void>() {
+ @Override
+ public boolean apply(@Nullable Void input) {
+ return System.currentTimeMillis() > endTime && !infiniteSleep;
Review comment:
Nit: change the order of evaluation to: !infiniteSleep &&
System.currentTimeMillis() > endTIme
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services