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_r213061640
##########
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:
I think its pretty clean the way it is now. I added tests to cover crazy
corner cases
----------------------------------------------------------------
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]