question: public void addAndDeploy ( DeploymentDescriptor dd , Handler < ExtendedAsyncResult < DeploymentDescriptor > > fut ) { logger . info ( "addAndDeploy: " + Json . encodePrettily ( dd ) ) ; final String srvcId = dd . getSrvcId ( ) ; if ( srvcId == null ) { fut . handle ( new Failure < > ( USER , "Needs srvcId" ) ) ; return ; } LaunchDescriptor launchDesc = dd . getDescriptor ( ) ; final String nodeId = dd . getNodeId ( ) ; if ( launchDesc == null && nodeId == null ) { final String instId = dd . getInstId ( ) ; if ( instId == null ) { fut . handle ( new Failure < > ( USER , "Needs instId" ) ) ; return ; } deployments . add ( srvcId , instId , dd , null ) ; } else if ( nodeId == null ) { fut . handle ( new Failure < > ( USER , "missing nodeId" ) ) ; } else { if ( launchDesc == null ) { if ( moduleManager == null ) { fut . handle ( new Failure < > ( INTERNAL , "no module manager (should not happen)" ) ) ; return ; } String modId = dd . getSrvcId ( ) ; if ( modId == null || modId . isEmpty ( ) ) { fut . handle ( new Failure < > ( USER , "Needs srvcId" ) ) ; return ; } ModuleDescriptor md = moduleManager . get ( modId ) ; if ( md == null ) { fut . handle ( new Failure < > ( NOT_FOUND , "Module " + modId + " not found" ) ) ; return ; } launchDesc = md . getLaunchDescriptor ( ) ; if ( launchDesc == null ) { fut . handle ( new Failure < > ( USER , "Module " + modId + " has no launchDescriptor" ) ) ; return ; } dd . setDescriptor ( launchDesc ) ; } getNode ( nodeId , null ) ; } }
target:  Adds a service to the discovery, and optionally deploys it too. 1: We have launchDescriptor and NodeId: Deploy on that node. 2: NodeId, but no launchDescriptor: Fetch the module, use its launchdesc, and deploy. 3: No nodeId: Do not deploy at all, just record the existence (URL and instId) of the module.