private List < HdfsStats > createFromScanResults ( String cluster , String path , Scan scan , int maxCount , boolean checkPath , long starttime , long endtime ) throws IOException { Map < HdfsStatsKey , HdfsStats > hdfsStats = new HashMap < HdfsStatsKey , HdfsStats > ( ) ; ResultScanner scanner = null ; Stopwatch timer = new Stopwatch ( ) . start ( ) ; int rowCount = 0 ; long colCount = 0 ; long resultSize = 0 ; Table hdfsUsageTable = null ; try { hdfsUsageTable = hbaseConnection . getTable ( TableName . valueOf ( HdfsConstants . HDFS_USAGE_TABLE ) ) ; scanner = hdfsUsageTable . getScanner ( scan ) ; for ( Result result : scanner ) { if ( result != null && ! result . isEmpty ( ) ) { colCount += result . size ( ) ; // TODO dogpiledays resultSize += result.getWritableSize(); rowCount = populateHdfsStats ( result , hdfsStats , checkPath , path , starttime , endtime , rowCount ) ; // return if we've already hit the limit if ( rowCount >= maxCount ) { break ; } } } timer . stop ( ) ; LOG . info ( "In createFromScanResults For cluster " + cluster + " Fetched from hbase " + rowCount + " rows, " + colCount + " columns, " + resultSize + " bytes ( " + resultSize / ( 1024 * 1024 ) + ") MB, in total time of " + timer ) ; } finally { try { if ( scanner != null ) { scanner . close ( ) ; } } finally { if ( hdfsUsageTable != null ) { hdfsUsageTable . close ( ) ; } } } List < HdfsStats > values = new ArrayList < HdfsStats > ( hdfsStats . values ( ) ) ; // sort so that timestamps are arranged in descending order Collections . sort ( values ) ; return values ; }
Scans the hbase table and populates the hdfs stats