private void checkOwnMaster ( ) throws Exception { int retry_times = 10 ; StormClusterState zkClient = data . getStormClusterState ( ) ; for ( int i = 0 ; i < retry_times ; i ++ , JStormUtils . sleepMs ( sleepTime ) ) { if ( ! zkClient . leader_existed ( ) ) { continue ; } String zkHost = zkClient . get_leader_host ( ) ; if ( hostPort . equals ( zkHost ) ) { // current process own master return ; } LOG . warn ( "Current nimbus has started thrift, but fail to set as leader in zk:" + zkHost ) ; } String err = "Current nimbus failed to set as leader in zk, halting process" ; LOG . error ( err ) ; JStormUtils . halt_process ( 0 , err ) ; }
Check whether current node is master