...
In order to cover the scenario where the process is failed but elements that are in a success state should not be repeat the process, the participant have to know what was the previous state.
Solutions
A simple solution from participant side is that they can use "useState" or "operationalState" to save information related to the deployment process.
...
Code Block | ||
---|---|---|
| ||
public record InstanceElementDto(UUID instanceId, UUID elementId, ToscaServiceTemplate toscaServiceTemplateFragment, Map<String, Object> inProperties, Map<String, Object> outProperties, String operationalState, String useState) { } |
Below an example how could be usedwith operationalState:
Code Block | ||
---|---|---|
| ||
@Override public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) throws PfModelException { if ("DEPLOYED".equals(instanceElement.useStateoperationalState())) { // 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.useStateoperationalState())) { // 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"); } |
...