public synchronized void losePrimacy ( ) throws IOException { Preconditions . checkState ( mState == State . PRIMARY , "unexpected state " + mState ) ; Preconditions . checkState ( mWriter != null , "writer thread must not be null in primary mode" ) ; Preconditions . checkState ( mTailerThread == null , "tailer thread must be null in primary mode" ) ; mWriter . close ( ) ; mWriter = null ; mAsyncWriter = null ; mMaster . resetState ( ) ; mTailerThread = new UfsJournalCheckpointThread ( mMaster , this ) ; mTailerThread . start ( ) ; mState = State . SECONDARY ; }
Transitions the journal from primary to secondary mode . The journal will no longer allow writes and the state machine is rebuilt from the journal and kept up to date .