Search in sources :

Example 6 with Stopwatch

use of org.apache.hbase.thirdparty.com.google.common.base.Stopwatch in project hbase by apache.

the class ScanPerformanceEvaluation method testScanMapReduce.

public void testScanMapReduce() throws IOException, InterruptedException, ClassNotFoundException {
    Stopwatch scanOpenTimer = Stopwatch.createUnstarted();
    Stopwatch scanTimer = Stopwatch.createUnstarted();
    Scan scan = getScan();
    String jobName = "testScanMapReduce";
    Job job = new Job(conf);
    job.setJobName(jobName);
    job.setJarByClass(getClass());
    TableMapReduceUtil.initTableMapperJob(this.tablename, scan, MyMapper.class, NullWritable.class, NullWritable.class, job);
    job.setNumReduceTasks(0);
    job.setOutputKeyClass(NullWritable.class);
    job.setOutputValueClass(NullWritable.class);
    job.setOutputFormatClass(NullOutputFormat.class);
    scanTimer.start();
    job.waitForCompletion(true);
    scanTimer.stop();
    Counters counters = job.getCounters();
    long numRows = counters.findCounter(ScanCounter.NUM_ROWS).getValue();
    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.elapsed(TimeUnit.SECONDS);
    double throughputRows = (double) numRows / scanTimer.elapsed(TimeUnit.SECONDS);
    double throughputCells = (double) numCells / scanTimer.elapsed(TimeUnit.SECONDS);
    System.out.println("HBase scan mapreduce: ");
    System.out.println("total time to open scanner: " + scanOpenTimer.elapsed(TimeUnit.MILLISECONDS) + " ms");
    System.out.println("total time to scan: " + scanTimer.elapsed(TimeUnit.MILLISECONDS) + " ms");
    System.out.println("total bytes: " + totalBytes + " bytes (" + StringUtils.humanReadableInt(totalBytes) + ")");
    System.out.println("throughput  : " + StringUtils.humanReadableInt((long) throughput) + "B/s");
    System.out.println("total rows  : " + numRows);
    System.out.println("throughput  : " + StringUtils.humanReadableInt((long) throughputRows) + " rows/s");
    System.out.println("total cells : " + numCells);
    System.out.println("throughput  : " + StringUtils.humanReadableInt((long) throughputCells) + " cells/s");
}
Also used : Stopwatch(org.apache.hbase.thirdparty.com.google.common.base.Stopwatch) Scan(org.apache.hadoop.hbase.client.Scan) Counters(org.apache.hadoop.mapreduce.Counters) Job(org.apache.hadoop.mapreduce.Job)

Aggregations

Stopwatch (org.apache.hbase.thirdparty.com.google.common.base.Stopwatch)6 Scan (org.apache.hadoop.hbase.client.Scan)4 Path (org.apache.hadoop.fs.Path)2 Result (org.apache.hadoop.hbase.client.Result)2 ScanMetrics (org.apache.hadoop.hbase.client.metrics.ScanMetrics)2 Counters (org.apache.hadoop.mapreduce.Counters)2 Job (org.apache.hadoop.mapreduce.Job)2 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Connection (org.apache.hadoop.hbase.client.Connection)1 ResultScanner (org.apache.hadoop.hbase.client.ResultScanner)1 Table (org.apache.hadoop.hbase.client.Table)1 TableSnapshotScanner (org.apache.hadoop.hbase.client.TableSnapshotScanner)1