private void deployInstance ( final Node node , final InstanceContext instance , final CountingCompletionHandler < Void > counter ) { data . put ( instance . address ( ) , Contexts . serialize ( instance ) . encode ( ) , new Handler < AsyncResult < String > > ( ) { @ Override public void handle ( AsyncResult < String > result ) { if ( result . failed ( ) ) { counter . fail ( result . cause ( ) ) ; } else { if ( ! watchHandlers . containsKey ( instance . address ( ) ) ) { final Handler < MapEvent < String , String > > watchHandler = new Handler < MapEvent < String , String > > ( ) { @ Override public void handle ( MapEvent < String , String > event ) { if ( event . type ( ) . equals ( MapEvent . Type . CREATE ) || event . type ( ) . equals ( MapEvent . Type . UPDATE ) ) { handleReady ( instance . address ( ) ) ; } else if ( event . type ( ) . equals ( MapEvent . Type . DELETE ) ) { handleUnready ( instance . address ( ) ) ; } } } ; // Watch the instance's status for changes. Once the instance has started // up, the component coordinator will set the instance's status key in the // cluster, indicating that the instance has completed started. Once all // instances in the network have completed startup the network will be started. data . watch ( instance . status ( ) , watchHandler , new Handler < AsyncResult < Void > > ( ) { @ Override public void handle ( AsyncResult < Void > result ) { if ( result . failed ( ) ) { counter . fail ( result . cause ( ) ) ; } else { watchHandlers . put ( instance . address ( ) , watchHandler ) ; if ( instance . component ( ) . isModule ( ) ) { deployModule ( node , instance , counter ) ; } else if ( instance . component ( ) . isVerticle ( ) && ! instance . component ( ) . asVerticle ( ) . isWorker ( ) ) { deployVerticle ( node , instance , counter ) ; } else if ( instance . component ( ) . isVerticle ( ) && instance . component ( ) . asVerticle ( ) . isWorker ( ) ) { deployWorkerVerticle ( node , instance , counter ) ; } } } } ) ; } else { if ( instance . component ( ) . isModule ( ) ) { deployModule ( node , instance , counter ) ; } else if ( instance . component ( ) . isVerticle ( ) && ! instance . component ( ) . asVerticle ( ) . isWorker ( ) ) { deployVerticle ( node , instance , counter ) ; } else if ( instance . component ( ) . isVerticle ( ) && instance . component ( ) . asVerticle ( ) . isWorker ( ) ) { deployWorkerVerticle ( node , instance , counter ) ; } } } } } ) ; }
Deploys an instance to a specific node .