From 5847097df01e5443b516871cdb24944def50a3cf Mon Sep 17 00:00:00 2001 From: maji2014 Date: Tue, 23 Dec 2014 19:25:15 -0800 Subject: [PATCH] add judgement for ConsumerPerformance against negative number --- core/src/main/scala/kafka/tools/ConsumerPerformance.scala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/main/scala/kafka/tools/ConsumerPerformance.scala b/core/src/main/scala/kafka/tools/ConsumerPerformance.scala index 093c800ea7f8a..661a5e28e82b7 100644 --- a/core/src/main/scala/kafka/tools/ConsumerPerformance.scala +++ b/core/src/main/scala/kafka/tools/ConsumerPerformance.scala @@ -71,6 +71,12 @@ object ConsumerPerformance { val endMs = System.currentTimeMillis val elapsedSecs = (endMs - startMs - config.consumerConfig.consumerTimeoutMs) / 1000.0 + + if(elapsedSecs <= 0) { + println("The total running time should be more than 'consumer.timeout.ms'!") + System.exit(1) + } + if (!config.showDetailedStats) { val totalMBRead = (totalBytesRead.get * 1.0) / (1024 * 1024) println(("%s, %s, %d, %.4f, %.4f, %d, %.4f").format(config.dateFormat.format(startMs), config.dateFormat.format(endMs),