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");
}
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");
}
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");
}
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;
}
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");
}
Aggregations