Search in sources :

Example 1 with Stopwatch

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

the class ScanPerformanceEvaluation method testSnapshotScan.

public void testSnapshotScan() throws IOException {
    Stopwatch snapshotRestoreTimer = Stopwatch.createUnstarted();
    Stopwatch scanOpenTimer = Stopwatch.createUnstarted();
    Stopwatch scanTimer = Stopwatch.createUnstarted();
    Path restoreDir = new Path(this.restoreDir);
    snapshotRestoreTimer.start();
    restoreDir.getFileSystem(conf).delete(restoreDir, true);
    snapshotRestoreTimer.stop();
    Scan scan = getScan();
    scanOpenTimer.start();
    TableSnapshotScanner scanner = new TableSnapshotScanner(conf, restoreDir, snapshotName, scan);
    scanOpenTimer.stop();
    long numRows = 0;
    long numCells = 0;
    scanTimer.start();
    while (true) {
        Result result = scanner.next();
        if (result == null) {
            break;
        }
        numRows++;
        numCells += result.rawCells().length;
    }
    scanTimer.stop();
    scanner.close();
    ScanMetrics metrics = scanner.getScanMetrics();
    long totalBytes = metrics.countOfBytesInResults.get();
    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 snapshot: ");
    System.out.println("total time to restore snapshot: " + snapshotRestoreTimer.elapsed(TimeUnit.MILLISECONDS) + " ms");
    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("Scan metrics:\n" + metrics.getMetricsMap());
    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 : Path(org.apache.hadoop.fs.Path) TableSnapshotScanner(org.apache.hadoop.hbase.client.TableSnapshotScanner) Stopwatch(org.apache.hbase.thirdparty.com.google.common.base.Stopwatch) Scan(org.apache.hadoop.hbase.client.Scan) ScanMetrics(org.apache.hadoop.hbase.client.metrics.ScanMetrics) Result(org.apache.hadoop.hbase.client.Result)

Example 2 with Stopwatch

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

the class ScanPerformanceEvaluation method testScan.

public void testScan() throws IOException {
    Stopwatch tableOpenTimer = Stopwatch.createUnstarted();
    Stopwatch scanOpenTimer = Stopwatch.createUnstarted();
    Stopwatch scanTimer = Stopwatch.createUnstarted();
    tableOpenTimer.start();
    Connection connection = ConnectionFactory.createConnection(getConf());
    Table table = connection.getTable(TableName.valueOf(tablename));
    tableOpenTimer.stop();
    Scan scan = getScan();
    scanOpenTimer.start();
    ResultScanner scanner = table.getScanner(scan);
    scanOpenTimer.stop();
    long numRows = 0;
    long numCells = 0;
    scanTimer.start();
    while (true) {
        Result result = scanner.next();
        if (result == null) {
            break;
        }
        numRows++;
        numCells += result.rawCells().length;
    }
    scanTimer.stop();
    scanner.close();
    table.close();
    connection.close();
    ScanMetrics metrics = scanner.getScanMetrics();
    long totalBytes = metrics.countOfBytesInResults.get();
    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: ");
    System.out.println("total time to open table: " + tableOpenTimer.elapsed(TimeUnit.MILLISECONDS) + " ms");
    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("Scan metrics:\n" + metrics.getMetricsMap());
    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 : Table(org.apache.hadoop.hbase.client.Table) ResultScanner(org.apache.hadoop.hbase.client.ResultScanner) Stopwatch(org.apache.hbase.thirdparty.com.google.common.base.Stopwatch) Connection(org.apache.hadoop.hbase.client.Connection) Scan(org.apache.hadoop.hbase.client.Scan) ScanMetrics(org.apache.hadoop.hbase.client.metrics.ScanMetrics) Result(org.apache.hadoop.hbase.client.Result)

Example 3 with Stopwatch

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

the class ScanPerformanceEvaluation method testHdfsStreaming.

protected void testHdfsStreaming(Path filename) throws IOException {
    byte[] buf = new byte[1024];
    FileSystem fs = filename.getFileSystem(getConf());
    // read the file from start to finish
    Stopwatch fileOpenTimer = Stopwatch.createUnstarted();
    Stopwatch streamTimer = Stopwatch.createUnstarted();
    fileOpenTimer.start();
    FSDataInputStream in = fs.open(filename);
    fileOpenTimer.stop();
    long totalBytes = 0;
    streamTimer.start();
    while (true) {
        int read = in.read(buf);
        if (read < 0) {
            break;
        }
        totalBytes += read;
    }
    streamTimer.stop();
    double throughput = (double) totalBytes / streamTimer.elapsed(TimeUnit.SECONDS);
    System.out.println("HDFS streaming: ");
    System.out.println("total time to open: " + fileOpenTimer.elapsed(TimeUnit.MILLISECONDS) + " ms");
    System.out.println("total time to read: " + streamTimer.elapsed(TimeUnit.MILLISECONDS) + " ms");
    System.out.println("total bytes: " + totalBytes + " bytes (" + StringUtils.humanReadableInt(totalBytes) + ")");
    System.out.println("throghput  : " + StringUtils.humanReadableInt((long) throughput) + "B/s");
}
Also used : FileSystem(org.apache.hadoop.fs.FileSystem) Stopwatch(org.apache.hbase.thirdparty.com.google.common.base.Stopwatch) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream)

Example 4 with Stopwatch

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

the class LoadBalancerPerformanceEvaluation method doWork.

@Override
protected int doWork() throws Exception {
    generateRegionsAndServers();
    String methodName = "roundRobinAssignment";
    LOG.info("Calling " + methodName);
    Stopwatch watch = Stopwatch.createStarted();
    loadBalancer.roundRobinAssignment(regions, servers);
    System.out.print(formatResults(methodName, watch.elapsed(TimeUnit.MILLISECONDS)));
    methodName = "retainAssignment";
    LOG.info("Calling " + methodName);
    watch.reset().start();
    loadBalancer.retainAssignment(regionServerMap, servers);
    System.out.print(formatResults(methodName, watch.elapsed(TimeUnit.MILLISECONDS)));
    methodName = "balanceCluster";
    LOG.info("Calling " + methodName);
    watch.reset().start();
    loadBalancer.balanceCluster(tableServerRegionMap);
    System.out.print(formatResults(methodName, watch.elapsed(TimeUnit.MILLISECONDS)));
    return EXIT_SUCCESS;
}
Also used : Stopwatch(org.apache.hbase.thirdparty.com.google.common.base.Stopwatch)

Example 5 with Stopwatch

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

the class ScanPerformanceEvaluation method testSnapshotScanMapReduce.

public void testSnapshotScanMapReduce() throws IOException, InterruptedException, ClassNotFoundException {
    Stopwatch scanOpenTimer = Stopwatch.createUnstarted();
    Stopwatch scanTimer = Stopwatch.createUnstarted();
    Scan scan = getScan();
    String jobName = "testSnapshotScanMapReduce";
    Job job = new Job(conf);
    job.setJobName(jobName);
    job.setJarByClass(getClass());
    TableMapReduceUtil.initTableSnapshotMapperJob(this.snapshotName, scan, MyMapper.class, NullWritable.class, NullWritable.class, job, true, new Path(restoreDir));
    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 : Path(org.apache.hadoop.fs.Path) 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