public synchronized void stop ( ) { state = State . STOP ; dispatchEvent ( LeaderElectionEventType . STOP_START ) ; logger . info ( "Stopping leader election support" ) ; if ( leaderOffer != null ) { try { zooKeeper . delete ( leaderOffer . getNodePath ( ) , - 1 ) ; logger . info ( "Removed leader offer {}" , leaderOffer . getNodePath ( ) ) ; } catch ( InterruptedException e ) { becomeFailed ( e ) ; } catch ( KeeperException e ) { becomeFailed ( e ) ; } } dispatchEvent ( LeaderElectionEventType . STOP_COMPLETE ) ; }
Stops all election services revokes any outstanding leader offers and disconnects from ZooKeeper .