diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedAction.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedAction.java index 410dd0c81d..401da7f97b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedAction.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedAction.java @@ -70,6 +70,7 @@ public abstract class MultiThreadedAction { protected AtomicLong numCols = new AtomicLong(); protected AtomicLong totalOpTimeMs = new AtomicLong(); protected boolean verbose = false; + protected boolean isProgressReporterRunning = false; protected LoadTestDataGenerator dataGenerator = null; @@ -182,10 +183,12 @@ public abstract class MultiThreadedAction { @Override public void run() { + isProgressReporterRunning = true; long startTime = System.currentTimeMillis(); long priorNumKeys = 0; long priorCumulativeOpTime = 0; int priorAverageKeysPerSecond = 0; + long time = System.currentTimeMillis() - startTime; // Give other threads time to start. Threads.sleep(REPORTING_INTERVAL_MS); @@ -197,7 +200,7 @@ public abstract class MultiThreadedAction { LOG.info(threadsLeft + "Number of keys = 0"); } else { long numKeys = MultiThreadedAction.this.numKeys.get(); - long time = System.currentTimeMillis() - startTime; + time = System.currentTimeMillis() - startTime; long totalOpTime = totalOpTimeMs.get(); long numKeysDelta = numKeys - priorNumKeys; @@ -231,10 +234,23 @@ public abstract class MultiThreadedAction { priorNumKeys = numKeys; priorCumulativeOpTime = totalOpTime; priorAverageKeysPerSecond = (int) averageKeysPerSecond; - } + } Threads.sleep(REPORTING_INTERVAL_MS); } + LOG.info("RUN SUMMARY: " + + "Keys=" + + priorNumKeys + + ", cols=" + + StringUtils.humanReadableInt(numCols.get()) + + ", time=" + + formatTime(time) + + ((priorNumKeys > 0 && time > 0) ? (" Overall: [" + "keys/s= " + + priorNumKeys * 1000 / time + ", latency=" + + String.format("%.2f", (double)priorCumulativeOpTime / (double)priorNumKeys) + + " ms]") : "") + ); + isProgressReporterRunning = false; } private void printStreamingCounters(long numKeysDelta, @@ -261,7 +277,7 @@ public abstract class MultiThreadedAction { } public void waitForFinish() { - while (numThreadsWorking.get() != 0) { + while (numThreadsWorking.get() != 0 || isProgressReporterRunning) { Threads.sleepWithoutInterrupt(1000); } close();