diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java index 0a5a37f..aaf8082 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java @@ -35,6 +35,7 @@ import java.util.concurrent.atomic.AtomicLong; import org.apache.hadoop.hbase.CellComparator; import org.apache.commons.lang.NotImplementedException; +import org.apache.commons.lang.time.StopWatch; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; @@ -85,7 +86,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import com.google.common.base.Stopwatch; import com.google.protobuf.ByteString; import com.google.protobuf.RpcController; import com.google.protobuf.ServiceException; @@ -681,14 +681,14 @@ public class TestClientNoCluster extends Configured implements Tool { TableName tableName = TableName.valueOf(BIG_USER_TABLE); if (get) { try (Table table = sharedConnection.getTable(tableName)){ - Stopwatch stopWatch = new Stopwatch(); + StopWatch stopWatch = new StopWatch(); stopWatch.start(); for (int i = 0; i < namespaceSpan; i++) { byte [] b = format(rd.nextLong()); Get g = new Get(b); table.get(g); if (i % printInterval == 0) { - LOG.info("Get " + printInterval + "/" + stopWatch.elapsedMillis()); + LOG.info("Get " + printInterval + "/" + stopWatch.getTime()); stopWatch.reset(); stopWatch.start(); } @@ -698,7 +698,7 @@ public class TestClientNoCluster extends Configured implements Tool { } } else { try (BufferedMutator mutator = sharedConnection.getBufferedMutator(tableName)) { - Stopwatch stopWatch = new Stopwatch(); + StopWatch stopWatch = new StopWatch(); stopWatch.start(); for (int i = 0; i < namespaceSpan; i++) { byte [] b = format(rd.nextLong()); @@ -706,7 +706,7 @@ public class TestClientNoCluster extends Configured implements Tool { p.addColumn(HConstants.CATALOG_FAMILY, b, b); mutator.mutate(p); if (i % printInterval == 0) { - LOG.info("Put " + printInterval + "/" + stopWatch.elapsedMillis()); + LOG.info("Put " + printInterval + "/" + stopWatch.getTime()); stopWatch.reset(); stopWatch.start(); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JvmPauseMonitor.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JvmPauseMonitor.java index 436f04a..169aa77 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JvmPauseMonitor.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JvmPauseMonitor.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.commons.lang.time.StopWatch; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.classification.InterfaceAudience; @@ -31,7 +32,6 @@ import org.apache.hadoop.conf.Configuration; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; -import com.google.common.base.Stopwatch; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -146,17 +146,18 @@ public class JvmPauseMonitor { private class Monitor implements Runnable { @Override public void run() { - Stopwatch sw = new Stopwatch(); + StopWatch sw = new StopWatch(); Map gcTimesBeforeSleep = getGcTimes(); while (shouldRun) { - sw.reset().start(); + sw.reset(); + sw.start(); try { Thread.sleep(SLEEP_INTERVAL_MS); } catch (InterruptedException ie) { return; } - long extraSleepTime = sw.elapsedMillis() - SLEEP_INTERVAL_MS; + long extraSleepTime = sw.getTime() - SLEEP_INTERVAL_MS; Map gcTimesAfterSleep = getGcTimes(); if (extraSleepTime > infoThresholdMs) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ScanPerformanceEvaluation.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ScanPerformanceEvaluation.java index 24e9590..608c387 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ScanPerformanceEvaluation.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ScanPerformanceEvaluation.java @@ -21,6 +21,7 @@ package org.apache.hadoop.hbase; import java.io.IOException; import java.util.concurrent.TimeUnit; +import org.apache.commons.lang.time.StopWatch; import org.apache.commons.cli.CommandLine; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FSDataInputStream; @@ -47,8 +48,6 @@ import org.apache.hadoop.mapreduce.lib.output.NullOutputFormat; import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.ToolRunner; -import com.google.common.base.Stopwatch; - /** * A simple performance evaluation tool for single client and MR scans * and snapshot scans. @@ -102,8 +101,8 @@ public class ScanPerformanceEvaluation extends AbstractHBaseTool { FileSystem fs = filename.getFileSystem(getConf()); // read the file from start to finish - Stopwatch fileOpenTimer = new Stopwatch(); - Stopwatch streamTimer = new Stopwatch(); + StopWatch fileOpenTimer = new StopWatch(); + StopWatch streamTimer = new StopWatch(); fileOpenTimer.start(); FSDataInputStream in = fs.open(filename); @@ -120,11 +119,11 @@ public class ScanPerformanceEvaluation extends AbstractHBaseTool { } streamTimer.stop(); - double throughput = (double)totalBytes / streamTimer.elapsedTime(TimeUnit.SECONDS); + double throughput = (double)totalBytes / TimeUnit.MILLISECONDS.toSeconds(streamTimer.getTime()); System.out.println("HDFS streaming: "); - System.out.println("total time to open: " + fileOpenTimer.elapsedMillis() + " ms"); - System.out.println("total time to read: " + streamTimer.elapsedMillis() + " ms"); + System.out.println("total time to open: " + fileOpenTimer.getTime() + " ms"); + System.out.println("total time to read: " + streamTimer.getTime() + " ms"); System.out.println("total bytes: " + totalBytes + " bytes (" + StringUtils.humanReadableInt(totalBytes) + ")"); System.out.println("throghput : " + StringUtils.humanReadableInt((long)throughput) + "B/s"); @@ -143,9 +142,9 @@ public class ScanPerformanceEvaluation extends AbstractHBaseTool { } public void testScan() throws IOException { - Stopwatch tableOpenTimer = new Stopwatch(); - Stopwatch scanOpenTimer = new Stopwatch(); - Stopwatch scanTimer = new Stopwatch(); + StopWatch tableOpenTimer = new StopWatch(); + StopWatch scanOpenTimer = new StopWatch(); + StopWatch scanTimer = new StopWatch(); tableOpenTimer.start(); Connection connection = ConnectionFactory.createConnection(getConf()); @@ -176,14 +175,15 @@ public class ScanPerformanceEvaluation extends AbstractHBaseTool { ScanMetrics metrics = scan.getScanMetrics(); long totalBytes = metrics.countOfBytesInResults.get(); - double throughput = (double)totalBytes / scanTimer.elapsedTime(TimeUnit.SECONDS); - double throughputRows = (double)numRows / scanTimer.elapsedTime(TimeUnit.SECONDS); - double throughputCells = (double)numCells / scanTimer.elapsedTime(TimeUnit.SECONDS); + long seconds = TimeUnit.MILLISECONDS.toSeconds(scanTimer.getTime()); + double throughput = (double)totalBytes / seconds; + double throughputRows = (double)numRows / seconds; + double throughputCells = (double)numCells / seconds; System.out.println("HBase scan: "); - System.out.println("total time to open table: " + tableOpenTimer.elapsedMillis() + " ms"); - System.out.println("total time to open scanner: " + scanOpenTimer.elapsedMillis() + " ms"); - System.out.println("total time to scan: " + scanTimer.elapsedMillis() + " ms"); + System.out.println("total time to open table: " + tableOpenTimer.getTime() + " ms"); + System.out.println("total time to open scanner: " + scanOpenTimer.getTime() + " ms"); + System.out.println("total time to scan: " + scanTimer.getTime() + " ms"); System.out.println("Scan metrics:\n" + metrics.getMetricsMap()); @@ -198,9 +198,9 @@ public class ScanPerformanceEvaluation extends AbstractHBaseTool { public void testSnapshotScan() throws IOException { - Stopwatch snapshotRestoreTimer = new Stopwatch(); - Stopwatch scanOpenTimer = new Stopwatch(); - Stopwatch scanTimer = new Stopwatch(); + StopWatch snapshotRestoreTimer = new StopWatch(); + StopWatch scanOpenTimer = new StopWatch(); + StopWatch scanTimer = new StopWatch(); Path restoreDir = new Path(this.restoreDir); @@ -230,14 +230,15 @@ public class ScanPerformanceEvaluation extends AbstractHBaseTool { ScanMetrics metrics = scanner.getScanMetrics(); long totalBytes = metrics.countOfBytesInResults.get(); - double throughput = (double)totalBytes / scanTimer.elapsedTime(TimeUnit.SECONDS); - double throughputRows = (double)numRows / scanTimer.elapsedTime(TimeUnit.SECONDS); - double throughputCells = (double)numCells / scanTimer.elapsedTime(TimeUnit.SECONDS); + long seconds = TimeUnit.MILLISECONDS.toSeconds(scanTimer.getTime()); + double throughput = (double)totalBytes / seconds; + double throughputRows = (double)numRows / seconds; + double throughputCells = (double)numCells / seconds; System.out.println("HBase scan snapshot: "); - System.out.println("total time to restore snapshot: " + snapshotRestoreTimer.elapsedMillis() + " ms"); - System.out.println("total time to open scanner: " + scanOpenTimer.elapsedMillis() + " ms"); - System.out.println("total time to scan: " + scanTimer.elapsedMillis() + " ms"); + System.out.println("total time to restore snapshot: " + snapshotRestoreTimer.getTime() + " ms"); + System.out.println("total time to open scanner: " + scanOpenTimer.getTime() + " ms"); + System.out.println("total time to scan: " + scanTimer.getTime() + " ms"); System.out.println("Scan metrics:\n" + metrics.getMetricsMap()); @@ -267,8 +268,8 @@ public class ScanPerformanceEvaluation extends AbstractHBaseTool { } public void testScanMapReduce() throws IOException, InterruptedException, ClassNotFoundException { - Stopwatch scanOpenTimer = new Stopwatch(); - Stopwatch scanTimer = new Stopwatch(); + StopWatch scanOpenTimer = new StopWatch(); + StopWatch scanTimer = new StopWatch(); Scan scan = getScan(); @@ -302,13 +303,14 @@ public class ScanPerformanceEvaluation extends AbstractHBaseTool { long numCells = counters.findCounter(ScanCounter.NUM_CELLS).getValue(); long totalBytes = counters.findCounter(HBASE_COUNTER_GROUP_NAME, "BYTES_IN_RESULTS").getValue(); - double throughput = (double)totalBytes / scanTimer.elapsedTime(TimeUnit.SECONDS); - double throughputRows = (double)numRows / scanTimer.elapsedTime(TimeUnit.SECONDS); - double throughputCells = (double)numCells / scanTimer.elapsedTime(TimeUnit.SECONDS); + long seconds = TimeUnit.MILLISECONDS.toSeconds(scanTimer.getTime()); + double throughput = (double)totalBytes / seconds; + double throughputRows = (double)numRows / seconds; + double throughputCells = (double)numCells / seconds; System.out.println("HBase scan mapreduce: "); - System.out.println("total time to open scanner: " + scanOpenTimer.elapsedMillis() + " ms"); - System.out.println("total time to scan: " + scanTimer.elapsedMillis() + " ms"); + System.out.println("total time to open scanner: " + scanOpenTimer.getTime() + " ms"); + System.out.println("total time to scan: " + scanTimer.getTime() + " ms"); System.out.println("total bytes: " + totalBytes + " bytes (" + StringUtils.humanReadableInt(totalBytes) + ")"); @@ -320,8 +322,8 @@ public class ScanPerformanceEvaluation extends AbstractHBaseTool { } public void testSnapshotScanMapReduce() throws IOException, InterruptedException, ClassNotFoundException { - Stopwatch scanOpenTimer = new Stopwatch(); - Stopwatch scanTimer = new Stopwatch(); + StopWatch scanOpenTimer = new StopWatch(); + StopWatch scanTimer = new StopWatch(); Scan scan = getScan(); @@ -357,13 +359,14 @@ public class ScanPerformanceEvaluation extends AbstractHBaseTool { long numCells = counters.findCounter(ScanCounter.NUM_CELLS).getValue(); long totalBytes = counters.findCounter(HBASE_COUNTER_GROUP_NAME, "BYTES_IN_RESULTS").getValue(); - double throughput = (double)totalBytes / scanTimer.elapsedTime(TimeUnit.SECONDS); - double throughputRows = (double)numRows / scanTimer.elapsedTime(TimeUnit.SECONDS); - double throughputCells = (double)numCells / scanTimer.elapsedTime(TimeUnit.SECONDS); + long seconds = TimeUnit.MILLISECONDS.toSeconds(scanTimer.getTime()); + double throughput = (double)totalBytes / seconds; + double throughputRows = (double)numRows / seconds; + double throughputCells = (double)numCells / seconds; System.out.println("HBase scan mapreduce: "); - System.out.println("total time to open scanner: " + scanOpenTimer.elapsedMillis() + " ms"); - System.out.println("total time to scan: " + scanTimer.elapsedMillis() + " ms"); + System.out.println("total time to open scanner: " + scanOpenTimer.getTime() + " ms"); + System.out.println("total time to scan: " + scanTimer.getTime() + " ms"); System.out.println("total bytes: " + totalBytes + " bytes (" + StringUtils.humanReadableInt(totalBytes) + ")");