public synchronized Node nonMasterNode ( ) { final ClusterState state = client ( ) . admin ( ) . cluster ( ) . prepareState ( ) . execute ( ) . actionGet ( ) . getState ( ) ; final String name = state . nodes ( ) . getMasterNode ( ) . getName ( ) ; for ( final Node node : nodeList ) { if ( ! node . isClosed ( ) && ! name . equals ( node . settings ( ) . get ( NODE_NAME ) ) ) { return node ; } } return null ; }
Return a non - master node .