Versions Compared

Key

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

...

There are scenarios where it make sense when a process is failed, all elements should be repeat fully, by in other scenarios could de be different, it depend of the context.  Anyway Anyway a participant could implement idempotent operations.  

...

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

...

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

        if ("DEPLOYED".equals(instanceElement.operationalState())) {
                 // deployclean processup alreadydeployment
done
        } else if ("DEPLOYING".equals(instanceElement.operationalState())    intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
    || "UNDEPLOYING".equals(instanceElement.operationalState()) {
            // check and clean up

      DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Already Deployed");
  }
          return;
        }
 
        // deployment process
        .......................................
        .......................................
        intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(),
                "Step 1Step1", "DEPLOYING", instanceElement.outProperties()); 
        .......................................
        .......................................
        intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(),
                "Step 2"Step2", "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;
        DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Already Undeployed");
            return; }

        if ("DEPLOYING".equals(instanceElement.operationalState()) || "UNDEPLOYING".equals(instanceElement.operationalState()) {
             // check and clean up
         }
 
        // undeployment process
        .......................................
        .......................................
        intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(),
                "Step 1Step1", "UNDEPLOYING", instanceElement.outProperties()); 
        .......................................
        .......................................
        intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(),
                "Step 2"Step2", "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");
     }

...