How startPhase is currently implemented

  • startPhase is configured in composition definition element and defines the order of execution of instance elements;
  • Any instance element is executed only once;
  • All instance elements whit same startPhase are executed at same time in parallel;
  • startPhase is used by deploy and unlock; startPhase in reverse order is used by lock, undeploy and delete;

Example using the Demo. The table below shows the startPhase for each Composition Definition Element

ParticipantComposition Definition Element

startPhase

Policyonap.policy.clamp.ac.element.Policy_AutomationCompositionElement0
K8sonap.policy.clamp.ac.element.K8S_StarterAutomationCompositionElement0
K8sonap.policy.clamp.ac.element.K8S_BridgeAutomationCompositionElement0
K8sonap.policy.clamp.ac.element.K8S_SinkAutomationCompositionElement0
Httponap.policy.clamp.ac.element.Http_StarterAutomationCompositionElement1
Httponap.policy.clamp.ac.element.Http_BridgeAutomationCompositionElement1
Httponap.policy.clamp.ac.element.Http_SinkAutomationCompositionElement1


The diagram below shows the flow of messages: Rest Rest ACM Runtime ACM Runtime Kafka Kafka Policy Participant Int Policy Participant Int Policy Participant Policy Participant K8s Participant Int K8s Participant Int K8s Participant K8s Participant Http Participant Int Http Participant Int Http Participant Http Participant ACM deploytriggered by the user [ASYNC] Deploy orderwith startPhase = 0 [ASYNC] startPhase = 0 Element deploy order [ASYNC] Element deployed [ASYNC] startPhase = 0 Element Starter deploy order Element Bridge deploy order Element Sink deploy order [ASYNC] Element Starter deployed [ASYNC] Element Bridge deployed [ASYNC] Element Sink deployed [ASYNC] startPhase = 0 [ASYNC] All deployed elements All element with startPhase = 0 are deployed [ASYNC] Deploy orderwith startPhase = 1 [ASYNC] startPhase = 1 [ASYNC] startPhase = 1 [ASYNC] startPhase = 1 Element Starter deploy order Element Bridge deploy order Element Sink deploy order [ASYNC] Element Starter deployed [ASYNC] Element Bridge deployed [ASYNC] Element Sink deployed [ASYNC] All deployed elements All element with startPhase = 1 are deployed set the instance as deployed

Alternative flow with "stage"

To maintain the backward compatibility, we are introducing a new property: "stage".

Minimal support for stage:

  • Still valid the startPhase definition for backward compatibility;
  • stage is configured in composition definition element;
  • stage  is applied only for migrate operation;
  • Any instance element could be executed more then one time; 
  • All instance elements whit same stage are executed at same time in parallel;

Example of composition definition element stage property:

properties:
  stage: [0,2]

Default value set to 0.

Full support for stage:

  • Still valid the startPhase definition for backward compatibility;
  • Using startPhase and stage in a composition definition is not valid;
  • stage is configured in composition definition element;
  • Any composition definition element could have different stage for each operation: for example the order for deploy could different for migrate;
  • Any instance element could be executed more then one time; 
  • All instance elements whit same stage are executed at same time in parallel;
  • stage has not reversal order.

Example of composition definition element stage property:

properties:
  stage:
    - deploy: [0,1]
    - migrate: [0,2]
    - update: [0]
    - undeploy: [0]
    - delete: [0]

All not defined operations will be set to 0.

Example of stage

The table below shows the stage for each Composition Definition Element:

ParticipantComposition Definition Element

stage

SEFA10, 2
SEFA20, 2
CNLCMB1

Rest Rest ACM Runtime ACM Runtime Kafka Kafka SEF Participant Int SEF Participant Int SEF Participant SEF Participant CNLCM Participant Int CNLCM Participant Int CNLCM Participant CNLCM Participant ACM migratetriggered by the user [ASYNC] Migrate orderwith stage = 0 [ASYNC] stage = 0 Element A1 migrate order Element A2 migrate order [ASYNC] Element A1 migrated [ASYNC] Element A2 migrated [ASYNC] stage = 0 [ASYNC] All migrated elements All element with stage = 0 are migrated [ASYNC] Migrate orderwith stage = 1 [ASYNC] stage = 1 [ASYNC] stage = 1 Element B migrate order [ASYNC] Element B migrated [ASYNC] All migrated elements All element with stage = 1 are migrated [ASYNC] Migrate orderwith stage = 2 [ASYNC] stage = 2 Element A1 migrate order Element A2 migrate order [ASYNC] Element A1 migrated [ASYNC] Element A2 migrated [ASYNC] stage = 2 [ASYNC] All migrated elements All element with stage = 2 are migrated set the instance as deployedAt the migrate method will be add a new stage parameter, and it will be created a new abstract class AcElementListenerV3. The abstract class AcElementListenerV1 and AcElementListenerV2 will wrap the new method to maintain the compatibility. 

Below the refactored migrate method.

    /**
     * Handle an update on a automation composition element.
     *
     * @param compositionElement the information of the Automation Composition Definition Element
     * @param compositionElementTarget the information of the Automation Composition Definition Element Target
     * @param instanceElement the information of the Automation Composition Instance Element
     * @param instanceElementMigrate the information of the Automation Composition Instance Element updated
     * @param stage the stage to perform
     * @throws PfModelException from Policy framework
     */
    void migrate(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget,
            InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate, Integer stage) throws PfModelException;

Note: instanceElement will contain the old properties only in the first call, if required we can implement old properties for each stage.

When an instance element has completed a stage, not means that the full execution is completed (DEPLOYED state).

It will add new method "updateAutomationCompositionElementStage" as below.

    /**
     * Update the stage of a automation composition element.
     *
     * @param instanceId the ID of the automation composition to update the state on
     * @param elementId the ID of the automation composition element to update the state on
     * @param stateChangeResult the indicator if error occurs
     * @param nextStage the next stage to do
     * @param message the message
     */
    void updateAutomationCompositionElementStage(UUID instanceId, UUID elementId, StateChangeResult stateChangeResult, Integer nextStage, String message);

Note: Participant has the control to decide what will be the next stage.


During the execution of the operation the user is able to see the stage that is executing for each instance element. "stage" field will be add in DB.

                "709c62b3-8918-41b9-a747-d21eb79c6c23": {
                    "id": "709c62b3-8918-41b9-a747-d21eb79c6c23",
                    "definition": {
                        "name": "onap.policy.clamp.ac.element.SefAutomationCompositionElement",
                        "version": "1.2.3"
                    },
                    "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c91",
                    "deployState": "MIGRATING",
                    "stage": 2,
                    "lockState": "LOCKED",
                    "description": "Sef Automation Composition Element for the Demo",
                    "message": "Stage 0 completed",






  • No labels