private void symLinkAndConfigureFiles ( JobConf job ) throws IOException { if ( ! ( job . getBoolean ( "mapred.used.genericoptionsparser" , false ) ) ) { LOG . warn ( "Use GenericOptionsParser for parsing the arguments. " + "Applications should implement Tool for the same." ) ; } // get all the command line arguments into the // jobconf passed in by the user conf String files = job . get ( "tmpfiles" ) ; String archives = job . get ( "tmparchives" ) ; // "tmpjars" are not needed because its in the classpath List < String > filesToSymLink = new ArrayList < String > ( ) ; splitAndAdd ( files , filesToSymLink ) ; splitAndAdd ( archives , filesToSymLink ) ; for ( String file : filesToSymLink ) { String target = new Path ( file ) . toUri ( ) . getPath ( ) ; String basename = new File ( target ) . getName ( ) ; String linkName = new File ( "." ) . getAbsolutePath ( ) + File . separator + basename ; File toLink = new File ( linkName ) ; if ( toLink . exists ( ) ) { LOG . info ( "Symlink " + linkName + " already exists. Delete it." ) ; toLink . delete ( ) ; } int ret = FileUtil . symLink ( target , linkName ) ; LOG . info ( "Creating symlink " + linkName + " -> " + target + " returns " + ret + "." ) ; } // Configure job name String originalJar = job . getJar ( ) ; if ( originalJar != null ) { // use jar name if job is not named. if ( "" . equals ( job . getJobName ( ) ) ) { job . setJobName ( new Path ( originalJar ) . getName ( ) ) ; } } // Configure username configureUserName ( job ) ; }
Create symlinks for the files needed for the jobs in current directory