Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.

Commit 750e479

Browse files
committed
Resolved bug with unit times
1 parent fd13bc8 commit 750e479

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/org/keedio/flume/metrics/SqlSourceCounter.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
*/
1313
package org.keedio.flume.metrics;
1414

15+
import java.util.concurrent.TimeUnit;
16+
1517
import org.apache.flume.instrumentation.MonitoredCounterGroup;
1618

1719
/**
@@ -66,16 +68,18 @@ public void startProcess(){
6668

6769
public void endProcess(int events){
6870

69-
long runningTime = System.currentTimeMillis() - getStartTime();
70-
long processTime = System.currentTimeMillis() - startProcessTime;
71+
long runningTime = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - getStartTime());
72+
long processTime = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - startProcessTime);
7173
long throughput = 0L;
7274

7375
if (events > 0 && processTime > 0)
74-
throughput = 1000*events/processTime;
76+
throughput = events/processTime;
7577
if (getMaxThroughput() < throughput)
7678
set(MAX_THROUGHPUT,throughput);
7779

78-
set(AVERAGE_THROUGHPUT, getEventCount()/(runningTime/1000));
80+
if (runningTime > 0 && getEventCount() > 0)
81+
set(AVERAGE_THROUGHPUT, (getEventCount()/runningTime));
82+
7983
set(CURRENT_THROUGHPUT,throughput);
8084
}
8185
}

0 commit comments

Comments
 (0)