drcrallen commented on a change in pull request #5913: Move Caching Cluster 
Client to java streams and allow parallel intermediate merges
URL: https://github.com/apache/incubator-druid/pull/5913#discussion_r208755327
 
 

 ##########
 File path: java-util/src/main/java/io/druid/java/util/common/JodaUtils.java
 ##########
 @@ -138,4 +139,24 @@ public static DateTime maxDateTime(DateTime... times)
         return max;
     }
   }
+
+  /**
+   * Return a qty of millisconds approximately until deadline. If deadline has 
passed, throw TimeoutException
+   *
+   * @param deadline The time on or after which things should be considered 
"timed out"
+   *
+   * @return A millisecond number where, if one were to wait that many 
milliseconds, the deadline would
+   * probably have passed. Always greater than zero
+   *
+   * @throws TimeoutException If the deadline has already passed (ties are 
treated as having passed the deadline)
+   */
+  public static long timeoutForDeadline(DateTime deadline) throws 
TimeoutException
+  {
+    final DateTime now = DateTimes.nowUtc();
+    final long diff = deadline.getMillis() - now.getMillis();
+    if (now.isAfter(deadline) || diff == 0) {
 
 Review comment:
   corner case for equals. The logic could be modified to not worry about that 
~1ms race condition, potentially. But I was trying to keep the prior conditions 
to fail in the same scenarios. I'll change it to use the method directly and 
return the diff.
   
   Also the usage of the `isAfter` method is to prevent any potential oddities 
for date times that are not close to now (like something on or around 
`MIN_INSTANT`)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to