private void locateNode ( final String address , final Iterator < String > nodes , final Handler < AsyncResult < String > > doneHandler ) { if ( nodes . hasNext ( ) ) { final String node = nodes . next ( ) ; vertx . eventBus ( ) . sendWithTimeout ( node , new JsonObject ( ) . putString ( "action" , "ping" ) , 1000 , new Handler < AsyncResult < Message < JsonObject > > > ( ) { @ Override public void handle ( AsyncResult < Message < JsonObject > > result ) { if ( result . failed ( ) || result . result ( ) . body ( ) . getString ( "status" , "ok" ) . equals ( "error" ) ) { removeNode ( address , node ) ; locateNode ( address , nodes , doneHandler ) ; } else { new DefaultFutureResult < String > ( node ) . setHandler ( doneHandler ) ; } } } ) ; } else { new DefaultFutureResult < String > ( new IllegalStateException ( "No local nodes found" ) ) . setHandler ( doneHandler ) ; } }
Locates an active local node in a list of nodes .