private static int CreateDFSPaths ( int level , String parentPath ) { Boolean isLeaf = false ; Boolean isDir = false ; if ( level + 1 >= levels_ ) { isLeaf = true ; } if ( isLeaf ) { if ( type_ . equals ( "dir" ) ) { isDir = true ; } else { isDir = false ; } } else { isDir = true ; } for ( int i = 0 ; i < inodesPerLevel_ ; i ++ ) { String path = parentPath + "/" + prefix_ + Integer . toString ( i ) ; //System.out.printf("Creating (isdir=%b) [%s]\n", isDir, path.toString()); if ( isDir ) { try { long startTime = System . nanoTime ( ) ; if ( dfsClient_ . mkdirs ( path ) == false ) { System . out . printf ( "Error in mkdirs(%s)\n" , path ) ; return - 1 ; } timingMkdirs_ . add ( new Double ( ( System . nanoTime ( ) - startTime ) / ( 1E9 ) ) ) ; System . out . printf ( "Creating dir %s\n" , path ) ; totalCreateCount ++ ; if ( totalCreateCount % COUNT_INCR == 0 ) { System . out . printf ( "Created paths so far: %d\n" , totalCreateCount ) ; } if ( ! isLeaf ) { if ( CreateDFSPaths ( level + 1 , path ) < 0 ) { System . out . printf ( "Error in CreateDFSPaths(%s)\n" , path ) ; return - 1 ; } } } catch ( IOException e ) { e . printStackTrace ( ) ; return - 1 ; } } else { try { System . out . printf ( "Creating file %s\n" , path ) ; long startTime = System . nanoTime ( ) ; OutputStream os = dfsClient_ . create ( path , true ) ; timingCreate_ . add ( new Double ( ( System . nanoTime ( ) - startTime ) / ( 1E9 ) ) ) ; files_ . put ( path , os ) ; totalCreateCount ++ ; if ( totalCreateCount % COUNT_INCR == 0 ) { System . out . printf ( "Created paths so far: %d\n" , totalCreateCount ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; return - 1 ; } } } return 0 ; }
Recursively creates directories and files .