if ( img == null )
return;
// test if last checkpoint was written ok.
if ( panic_ )
throw new LogException ( "StreamObjectLog: PANIC" );
try {
try {
logstream_.flushObject ( img , shouldSync );
writeCheckpoint ();
// fout_.flush();
} catch ( LogException ioerr ) {
ioerr.printStackTrace ();
errors.push ( ioerr );
// make sure that logfile remains in consistent state by
// checkpointing
try {
logstream_.writeCheckpoint ( logTable_.elements () );
} catch ( Exception e ) {
errors.push ( e );
}
throw new LogException ( ioerr.getMessage (), errors );
}
// replace/add local tid status in logTable_.
// for Checkpointing!
if ( img.isForgettable () ) {
if ( logTable_.containsKey ( img.getId () ) ) {
// to avoid that logTable_ keeps growing!
logTable_.remove ( img.getId () );
size_--;
}
} else {
if ( !logTable_.containsKey ( img.getId () ) ) {
size_++;
}
logTable_.put ( img.getId (), img );
}
}// try
catch ( LogException le ) {
System.err.println ( "Error in StreamObjectLog.flush() "
+ le.getMessage () );
throw le;
} catch ( Exception e ) {
System.err.println ( "Error in StreamObjectLog.flush() "
+ e.getMessage () );
errors.push ( e );
throw new LogException ( e.getMessage (), errors );
}// catch
}