private boolean check_nimbus_priority ( ) throws Exception { int gap = update_nimbus_detail ( ) ; if ( gap == 0 ) { return true ; } int left = SLAVE_NIMBUS_WAIT_TIME ; while ( left > 0 ) { LOG . info ( "nimbus.differ.count.zk is {}, so after {} seconds, nimbus will try to be leader!" , gap , left ) ; Thread . sleep ( 10 * 1000 ) ; left -= 10 ; } StormClusterState zkClusterState = data . getStormClusterState ( ) ; List < String > followers = zkClusterState . list_dirs ( Cluster . NIMBUS_SLAVE_DETAIL_SUBTREE , false ) ; if ( followers == null || followers . size ( ) == 0 ) { return false ; } for ( String follower : followers ) { if ( follower != null && ! follower . equals ( hostPort ) ) { Map bMap = zkClusterState . get_nimbus_detail ( follower , false ) ; if ( bMap != null ) { Object object = bMap . get ( NIMBUS_DIFFER_COUNT_ZK ) ; if ( object != null && ( JStormUtils . parseInt ( object ) ) < gap ) { LOG . info ( "Current node can't be leader, due to {} has higher priority" , follower ) ; return false ; } } } } return true ; }
Compared with other nimbus to get priority of this nimbus