Map < String , LocalResource > getResources ( final ResourceLaunchEvent resourceLaunchEvent ) throws IOException { final Map < String , LocalResource > result = new HashMap <> ( ) ; result . putAll ( getGlobalResources ( ) ) ; final File localStagingFolder = this . tempFileCreator . createTempDirectory ( this . fileNames . getEvaluatorFolderPrefix ( ) ) ; // Write the configuration final File configurationFile = new File ( localStagingFolder , this . fileNames . getEvaluatorConfigurationName ( ) ) ; this . configurationSerializer . toFile ( makeEvaluatorConfiguration ( resourceLaunchEvent ) , configurationFile ) ; // Copy files to the staging folder JobJarMaker . copy ( resourceLaunchEvent . getFileSet ( ) , localStagingFolder ) ; // Make a JAR file out of it final File localFile = tempFileCreator . createTempFile ( this . fileNames . getEvaluatorFolderPrefix ( ) , this . fileNames . getJarFileSuffix ( ) ) ; new JARFileMaker ( localFile ) . addChildren ( localStagingFolder ) . close ( ) ; // Upload the JAR to the job folder final Path pathToEvaluatorJar = this . uploader . uploadToJobFolder ( localFile ) ; result . put ( this . fileNames . getLocalFolderPath ( ) , this . uploader . makeLocalResourceForJarFile ( pathToEvaluatorJar ) ) ; if ( this . deleteTempFiles ) { LOG . log ( Level . FINE , "Marking [{0}] for deletion at the exit of this JVM and deleting [{1}]" , new Object [ ] { localFile . getAbsolutePath ( ) , localStagingFolder . getAbsolutePath ( ) } ) ; localFile . deleteOnExit ( ) ; if ( ! localStagingFolder . delete ( ) ) { LOG . log ( Level . WARNING , "Failed to delete [{0}]" , localStagingFolder . getAbsolutePath ( ) ) ; } } else { LOG . log ( Level . FINE , "The evaluator staging folder will be kept at [{0}], the JAR at [{1}]" , new Object [ ] { localFile . getAbsolutePath ( ) , localStagingFolder . getAbsolutePath ( ) } ) ; } return result ; }
Sets up the LocalResources for a new Evaluator .