private void doNodeLeft ( final Node node ) { tasks . runTask ( new Handler < Task > ( ) { @ Override public void handle ( final Task task ) { if ( currentContext != null ) { log . info ( String . format ( "%s - %s left the cluster. Reassigning components" , NetworkManager . this , node . address ( ) ) ) ; deploymentNodes . keySet ( new Handler < AsyncResult < Set < String > > > ( ) { @ Override public void handle ( AsyncResult < Set < String > > result ) { if ( result . succeeded ( ) ) { final CountingCompletionHandler < Void > counter = new CountingCompletionHandler < Void > ( result . result ( ) . size ( ) ) ; counter . setHandler ( new Handler < AsyncResult < Void > > ( ) { @ Override public void handle ( AsyncResult < Void > result ) { task . complete ( ) ; } } ) ; // If the instance was deployed on the node that left the cluster then // redeploy it on a new node. for ( final String instanceAddress : result . result ( ) ) { deploymentNodes . get ( instanceAddress , new Handler < AsyncResult < String > > ( ) { @ Override public void handle ( AsyncResult < String > result ) { if ( result . succeeded ( ) && result . result ( ) . equals ( node . address ( ) ) ) { // Look up the current instance context in the cluster. data . get ( instanceAddress , new Handler < AsyncResult < String > > ( ) { @ Override public void handle ( AsyncResult < String > result ) { if ( result . succeeded ( ) && result . result ( ) != null ) { deployInstance ( Contexts . < InstanceContext > deserialize ( new JsonObject ( result . result ( ) ) ) , counter ) ; } else { counter . succeed ( ) ; } } } ) ; } else { counter . succeed ( ) ; } } } ) ; } } } } ) ; } else { task . complete ( ) ; } } } ) ; }
Handles a node leaving the cluster .