Versions Compared

Key

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

...

Add support for the participant to understand what was the last state.

Additional comments

It is important to make distinction between the state of the instance/element in the flow, and the state of the application involved. A deployed element means that a participant has completed a deploy action, and should not be confused with a deployed application.

...

A simple solution from participant side is that it can use "useState" or and "operationalState" to save information related to the deployment process.Into the participant implementation it can send the completition of

the process "useState", "operationalState" and "outProperties" are controlled by the participant side, and saved into ACM-r Db by status message (by sendAcElementInfo method).

To support the participant implementation we can add "useState" and "operationalState" into the InstanceElementDto:

Code Block
languagejava
public record InstanceElementDto(UUID instanceId, UUID elementId, ToscaServiceTemplate toscaServiceTemplateFragment,
                                 Map<String, Object> inProperties, Map<String, Object> outProperties, String operationalState, String useState) {
}

  

...


The examples below are suggestions, there are al lot possibility how these parameters can be used.

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

        if ("DEPLOYED".equals(instanceElement.operationalState())) {

            // deploy process already done
            intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
                    DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Already Deployed");
            return;
        }
         
        // deployment process
        .......................................
        .......................................
        // end of the deployment process
        
        intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(),
                "", "DEPLOYED", instanceElement.outProperties());

        intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
                DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
    }


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

        if ("UNDEPLOYED".equals(instanceElement.operationalState())) {
            // undeploy process already done

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

        // undeployment process
        .......................................
        .......................................
        // end of the undeployment process        
        
        intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(),
                "", "UNDEPLOYED", instanceElement.outProperties());

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


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

        if ("DEPLOYED".equals(instanceElement.operationalState())) {

            // deploy process already done
            intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
                    DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Already Deployed");
            return;
        }

         // deployment process
        .......................................
        .......................................
        intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(),
                "Step 1", "DEPLOYING", instanceElement.outProperties()); 
        .......................................
        .......................................
        intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(),
                "Step 2", "DEPLOYING", instanceElement.outProperties());
        .......................................
        .......................................
        // end of the deployment process        
        
        intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(),
                "", "DEPLOYED", instanceElement.outProperties());

        intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
                DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
    }


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

        if ("UNDEPLOYED".equals(instanceElement.operationalState())) {
            // undeploy process already done

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

        // undeployment process
        .......................................
        .......................................
        intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(),
                "Step 1", "UNDEPLOYING", instanceElement.outProperties()); 
        .......................................
        .......................................
        intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(),
                "Step 2", "UNDEPLOYING", instanceElement.outProperties());
        .......................................
        .......................................
        // end of the undeployment process        
        
        intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(),
                "", "UNDEPLOYED", instanceElement.outProperties());

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

...