public static void downloadDistributeStormCode ( Map conf , String topologyId , String masterCodeDir ) throws IOException , TException { String tmpToot = null ; try { // STORM_LOCAL_DIR/supervisor/tmp/(UUID) tmpToot = StormConfig . supervisorTmpDir ( conf ) + File . separator + UUID . randomUUID ( ) . toString ( ) ; // STORM_LOCAL_DIR/supervisor/stormdist/topologyId String stormRoot = StormConfig . supervisor_stormdist_root ( conf , topologyId ) ; // JStormServerUtils.downloadCodeFromMaster(conf, tmproot, masterCodeDir, topologyId, true); JStormServerUtils . downloadCodeFromBlobStore ( conf , tmpToot , topologyId ) ; // tmproot/stormjar.jar String localFileJarTmp = StormConfig . stormjar_path ( tmpToot ) ; // extract dir from jar JStormUtils . extractDirFromJar ( localFileJarTmp , StormConfig . RESOURCES_SUBDIR , tmpToot ) ; File srcDir = new File ( tmpToot ) ; File destDir = new File ( stormRoot ) ; try { FileUtils . moveDirectory ( srcDir , destDir ) ; } catch ( FileExistsException e ) { FileUtils . copyDirectory ( srcDir , destDir ) ; FileUtils . deleteQuietly ( srcDir ) ; } } finally { if ( tmpToot != null ) { File srcDir = new File ( tmpToot ) ; FileUtils . deleteQuietly ( srcDir ) ; } } }
no need to synchronize since EventManager will execute sequentially