public boolean flush ( ) { boolean ret = true ; PrintWriter out = null ; // Save source water marks try { // Backup the original file if ( file . exists ( ) ) { if ( fileOriginal . exists ( ) ) { fileOriginal . delete ( ) ; } file . renameTo ( fileOriginal ) ; } // Overwrite the existing file out = new PrintWriter ( new FileOutputStream ( file ) ) ; for ( String source : sourceWaterMarkMap . keySet ( ) ) { WaterMarkEntry wmEntry = sourceWaterMarkMap . get ( source ) ; out . println ( wmEntry ) ; } out . flush ( ) ; } catch ( IOException ioe ) { logger . error ( "Failed to flush water marks" , ioe ) ; ret = false ; } finally { if ( out != null ) { out . close ( ) ; out = null ; } } return ret ; }
Flushes low water marks and high water marks for all the sources .