@ Override public void run ( ) { try { waitUntilServerIsInitialized ( ) ; recoveryLog . log ( "Start recovery." ) ; while ( true ) { if ( shutdown ) { break ; } ConsumerJournalEntry cje = reader . readJournalEntry ( ) ; if ( cje == null ) { break ; } cje . invokeMethod ( delegate , recoveryLog ) ; cje . close ( ) ; } reader . shutdown ( ) ; recoveryLog . log ( "Recovery complete." ) ; } catch ( Throwable e ) { /* * It makes sense to catch Exception here, because any uncaught * exception will not be reported - there is no console to print the * stack trace! It might not be appropriate to catch Throwable, but * it's the only way we can know about missing class files and such. * Of course, if we catch an OutOfMemoryError or a * VirtualMachineError, all bets are off. */ logger . error ( "Error during Journal recovery" , e ) ; String stackTrace = JournalHelper . captureStackTrace ( e ) ; recoveryLog . log ( "PROBLEM: " + stackTrace ) ; recoveryLog . log ( "Recovery terminated prematurely." ) ; } finally { recoveryLog . shutdown ( ) ; } }
Wait until the server completes its initialization then process journal entries until the reader says there are no more or until a shutdown is requested .