Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

"outProperties" is controlled by the participant side, and saved into ACM-r Db by status message (by sendAcElementInfo method).  Each participant replica will be synchronized as well.

The examples below are suggestions.

...

Code Block
languagejava
    @Override
    public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) throws PfModelException {

        if ("DEPLOYED".equals(instanceElement.outProperties().get("state"))) {
            // deploy process already done
            intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Already Deployed");
            return;
        }
         
        // deployment process
        .......................................
        .......................................
        // end of the deployment process
        
        if (isDeploySuccess()) {
            instanceElement.outProperties().put("state", "DEPLOYED");
            intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(), null, null, instanceElement.outProperties());
 
            intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
        } else {
            instanceElement.outProperties().put("state", "UNDEPLOYED");
            intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(), null, null, instanceElement.outProperties());
 
            intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "Deploy failed!");
        } 
    }


    @Override
    public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) throws PfModelException {

        if ("DEPLOYED".equals(instanceElement.outProperties().get("state"))) {
            // undeploy process already done

            intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Already Undeployed");
            return;
        }

        // undeployment process
        .......................................
        .......................................
        // end of the undeployment process        
        
        if (isUndeploySuccess()) {
             instanceElement.outProperties().put("state", "UNDEPLOYED");
            intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(), null, null, instanceElement.outProperties());

            intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Undeployed");
        } else {
            instanceElement.outProperties().put("state", "DEPLOYED");
            intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(), null, null, instanceElement.outProperties());

            intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Undeploy failed!");
        }
    }


  • Below other suggestion with operationalState and useStateother suggestion:
Code Block
languagejava
    @Override
    public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) throws PfModelException {

        var state = instanceElement.outProperties().get("state");
        if ("DEPLOYED".equals(instanceElement.operationalState(state))) {
                // clean up deployment
             
        } else if ("DEPLOYING".equals(instanceElement.operationalState(state)) || "UNDEPLOYING".equals(instanceElement.operationalState(state)) {
                // check and clean up

        }

        
        // deployment process
        .......................................
           .......................................
        intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(), "Step1", "DEPLOYING", instanceElement.outProperties()); 
        .......................................
         .......................................// end of the deployment process        
        
         if (isDeploySuccess()) {
            instanceElement.outProperties().put("state", "DEPLOYED");
            intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(), "Step2"null, "DEPLOYING"null, instanceElement.outProperties());
 
             intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.....................................
  elementId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
     .......................................   } else {
   // end of the deployment process        
        instanceElement.outProperties().put("state", "UNDEPLOYED");
            intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(), ""null, "DEPLOYED"null, instanceElement.outProperties());
 
            intermediaryApi intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DEPLOYEDUNDEPLOYED, null, StateChangeResult.NO_ERRORFAILED, "DeployedDeploy failed!");
        } 
     }


    @Override
    public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) throws PfModelException {

         var state if ("UNDEPLOYED".equals(instanceElement.operationalState())) {= instanceElement.outProperties().get("state");
        if ("UNDEPLOYED".equals(state)) {
  // undeploy process already done      // clean up undeployment
    intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Already Undeployed");
      
     return;         } 
        else if ("DEPLOYING".equals(instanceElement.operationalState(state)) || "UNDEPLOYING".equals(instanceElement.operationalState(state)) {
                // check and clean up

        }    }
 
        // undeployment process
        .......................................
        .......................................
        intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(), "Step1", "UNDEPLOYING", instanceElement.outProperties());
         .......................................
        .......................................
        // end of the undeployment process        
        
         if (isUndeploySuccess()) {
             instanceElement.outProperties().put("state", "UNDEPLOYED");
            intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(), "Step2"null, "UNDEPLOYING"null, instanceElement.outProperties());


      .......................................         intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState....................................UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Undeployed");
        } //else end{
of the undeployment process            instanceElement.outProperties().put("state", "DEPLOYED");
            intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(), ""null, "UNDEPLOYED"null, instanceElement.outProperties());

            intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.UNDEPLOYEDDEPLOYED, null, StateChangeResult.NO_ERRORFAILED, "UndeployedUndeploy failed!");
         }
    }