public synchronized void saveWorkdir ( ) throws IOException { Preconditions . checkState ( mState == State . STARTED , "cluster must be started before you can save its work directory" ) ; ARTIFACTS_DIR . mkdirs ( ) ; File tarball = new File ( mWorkDir . getParentFile ( ) , mWorkDir . getName ( ) + ".tar.gz" ) ; // Tar up the work directory. ProcessBuilder pb = new ProcessBuilder ( "tar" , "-czf" , tarball . getName ( ) , mWorkDir . getName ( ) ) ; pb . directory ( mWorkDir . getParentFile ( ) ) ; pb . redirectOutput ( Redirect . appendTo ( TESTS_LOG ) ) ; pb . redirectError ( Redirect . appendTo ( TESTS_LOG ) ) ; Process p = pb . start ( ) ; try { p . waitFor ( ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; throw new RuntimeException ( e ) ; } // Move tarball to artifacts directory. File finalTarball = new File ( ARTIFACTS_DIR , tarball . getName ( ) ) ; FileUtils . moveFile ( tarball , finalTarball ) ; LOG . info ( "Saved cluster {} to {}" , mClusterName , finalTarball . getAbsolutePath ( ) ) ; }
Copies the work directory to the artifacts folder .