private Map < Integer , DiskScanInfo [ ] > getDiskReportPerNamespace ( ) { if ( dataset . volumes == null ) { LOG . warn ( "Dataset volumes are not initialized yet" ) ; return new HashMap < Integer , DiskScanInfo [ ] > ( ) ; } // First get list of data directories FSVolume [ ] volumes = dataset . volumes . getVolumes ( ) ; ScanInfoListPerNamespace [ ] volumeReports = new ScanInfoListPerNamespace [ volumes . length ] ; Map < Integer , Future < ScanInfoListPerNamespace > > volumeCompilers = new HashMap < Integer , Future < ScanInfoListPerNamespace > > ( ) ; for ( int i = 0 ; i < volumes . length ; i ++ ) { // check volume is valid if ( dataset . volumes . isValid ( volumes [ i ] ) ) { // and run compiler for it ReportCompiler reportCompiler = new ReportCompiler ( volumes [ i ] , datanode ) ; Future < ScanInfoListPerNamespace > result = reportCompileThreadPool . submit ( reportCompiler ) ; volumeCompilers . put ( i , result ) ; } } for ( Entry < Integer , Future < ScanInfoListPerNamespace > > e : volumeCompilers . entrySet ( ) ) { try { int volume = e . getKey ( ) ; volumeReports [ volume ] = e . getValue ( ) . get ( ) ; } catch ( Exception ex ) { LOG . error ( "Error compiling report" , ex ) ; // Propagate ex to DataBlockScanner to deal with throw new RuntimeException ( ex ) ; } } // Compile consolidated report for all the volumes ScanInfoListPerNamespace list = new ScanInfoListPerNamespace ( ) ; for ( int i = 0 ; i < volumes . length ; i ++ ) { if ( dataset . volumes . isValid ( volumes [ i ] ) ) { // volume is still valid list . addAll ( volumeReports [ i ] ) ; } } return list . toSortedArrays ( ) ; }
Get lists of blocks on the disk sorted by blockId per namespace