DirectDruidClient: Fix division by zero. (#4206)

* DirectDruidClient: Fix division by zero.

Introduced in #3954 when some floating math was changed to
integer math. This patch restores the old math.

* Added comment.
This commit is contained in:
Gian Merlino 2017-04-25 13:03:00 +09:00 committed by GitHub
parent de815da942
commit 809112cd5f
1 changed files with 3 additions and 2 deletions

View File

@ -269,13 +269,14 @@ public class DirectDruidClient<T> implements QueryRunner<T>
{
long stopTimeNs = System.nanoTime();
long nodeTimeNs = stopTimeNs - responseStartTimeNs;
final long nodeTimeMs = TimeUnit.NANOSECONDS.toMillis(nodeTimeNs);
log.debug(
"Completed queryId[%s] request to url[%s] with %,d bytes returned in %,d millis [%,f b/s].",
query.getId(),
url,
byteCount.get(),
TimeUnit.NANOSECONDS.toMillis(nodeTimeNs),
byteCount.get() / TimeUnit.NANOSECONDS.toSeconds(nodeTimeNs)
nodeTimeMs,
byteCount.get() / (0.001 * nodeTimeMs) // Floating math; division by zero will yield Inf, not exception
);
queryMetrics.reportNodeTime(nodeTimeNs);
queryMetrics.reportNodeBytes(byteCount.get());