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);
  }
}

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 ) ; } }
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 .
