private void persistPaxosData ( long segmentTxId , PersistedRecoveryPaxosData newData ) throws IOException { File f = journalStorage . getPaxosFile ( segmentTxId ) ; boolean success = false ; AtomicFileOutputStream fos = new AtomicFileOutputStream ( f ) ; try { newData . writeDelimitedTo ( fos ) ; fos . write ( ' ' ) ; // Write human-readable data after the protobuf. This is only // to assist in debugging -- it's not parsed at all. OutputStreamWriter writer = new OutputStreamWriter ( fos , Charsets . UTF_8 ) ; writer . write ( String . valueOf ( newData ) ) ; writer . write ( ' ' ) ; writer . flush ( ) ; fos . flush ( ) ; success = true ; } finally { if ( success ) { IOUtils . closeStream ( fos ) ; } else { fos . abort ( ) ; } } }
Persist data for recovering the given segment from disk .