public void awaitTermination ( boolean waitQuietPeriod ) { LOG . info ( "{}: Journal checkpointer shutdown has been initiated." , mMaster . getName ( ) ) ; mWaitQuietPeriod = waitQuietPeriod ; mShutdownInitiated = true ; // Actively interrupt to cancel slow checkpoints. synchronized ( mCheckpointingLock ) { if ( mCheckpointing ) { interrupt ( ) ; } } try { // Wait for the thread to finish. join ( ) ; LOG . info ( "{}: Journal shutdown complete" , mMaster . getName ( ) ) ; } catch ( InterruptedException e ) { LOG . error ( "{}: journal checkpointer shutdown is interrupted." , mMaster . getName ( ) , e ) ; // Kills the master. This can happen in the following two scenarios: // 1. The user Ctrl-C the server. // 2. Zookeeper selects this master as standby before the master finishes the previous // standby->leader transition. It is safer to crash the server because the behavior is // undefined to have two journal checkpointer running concurrently. throw new RuntimeException ( e ) ; } mStopped = true ; }
Initiates the shutdown of this checkpointer thread and also waits for it to finish .