public void initFromBackup ( InputStream is ) throws IOException { int count = 0 ; try ( GzipCompressorInputStream gzIn = new GzipCompressorInputStream ( is ) ; JournalEntryStreamReader reader = new JournalEntryStreamReader ( gzIn ) ) { List < Master > masters = mRegistry . getServers ( ) ; JournalEntry entry ; Map < String , Master > mastersByName = Maps . uniqueIndex ( masters , Master :: getName ) ; while ( ( entry = reader . readEntry ( ) ) != null ) { String masterName = JournalEntryAssociation . getMasterForEntry ( entry ) ; Master master = mastersByName . get ( masterName ) ; try { master . processJournalEntry ( entry ) ; } catch ( Throwable t ) { JournalUtils . handleJournalReplayFailure ( LOG , t , "Failed to process journal entry %s when init from backup" , entry ) ; } try ( JournalContext jc = master . createJournalContext ( ) ) { jc . append ( entry ) ; count ++ ; } } } LOG . info ( "Restored {} entries from backup" , count ) ; }
Restores master state from the specified backup .