CPS-1034 Publish LCM Events on Cmhandle State Change(NcmpEventsCmHandleStateHandler)

CPS-1034: Publish lifecycle events for ADVISED , READY and LOCKED state transitionClosed



#

Issue

Notes/Jira

Decision

#

Issue

Notes/Jira

Decision

1

Agree on a solution

proceed with Solution#2 as it would be more scalable.



Implementation Proposal


Problem Statement :  

To publish the NcmpEvent when there is a change in the cmHandleState ( state transition )



Scenarios to keep in mind

  • We have to introduce a detail field in the NcmpEvent payload which can contain the previous state and other details.

  • We have to publish an event on public properties update ( even though we dont have any state change ???? ) 



Potential Solutions

  1. Use code triggers

  2. Any other solution ? Common State Handler



Solution #1 : Code Triggers



  • Identify all the possible cm handle state transitions.


State Transition Event

previousState 

targetState

State Transition Event

previousState 

targetState

NOTHING_TO_ADVISED

NOTHING

ADVISED

ADVISED_TO_LOCKED

ADVISED

LOCKED

LOCKED_TO_ADVISED

LOCKED

ADVISED

ADVISED_TO_READY

ADVISED

READY

READY_TO_LOCKED

READY

LOCKED

LOCKED_TO_READY

LOCKED

READY

ADVISED_TO_DELETING

ADVISED

DELETING

READY_TO_DELETING

READY

DELETING

LOCKED_TO_DELETING

LOCKED

DELETING

DELETING_TO_DELETED

DELETING

DELETED



  • Create a cmHandleState handler which takes in the cmHandleState transition event
    --  Responsible for identifying the state transition
    --  Based on state transition call the relevant methods to create the NcmpEvent accordingly.



  • Identify the trigger points in the code where the actual state transitioning is happening and call the handler from there and provide the type of transition.


    Overview

2. Solution #2

Responsibilities of the state handlers

  • Accept : cmHandleId and other common params.

  • Set the object to the required state.

  • Persist the new state.

  • Send the correct event about the state change.



  • Identify the input and output params.
    I/P : examine the existing code , identify the commonalities and then propose.



Current State Transition:

  1. Create Registration (NEW to ADVISED)

  2. Module Sync Success ( ADVISED TO READY)
    Fail (ADVISED TO LOCKED)

  3. Retry ( LOCKED TO ADVISED ) 

  4. Deleting ( ADVISED to DELETING , READY to DELETING, LOCKED to DELETING )  / separate us **

  5. Deleted ( DELETING to DELETED )  separate us **  CPS-1120: Actions we need to perform when cmHandleState changes from * to DELETING and then DELETING to DELETEDClosed



At a high level the method signature should like below.


State Handler
/** * Responsible for handling the state transition and publishing the lcm event if required. * * @param cmHandleId cm handle id * @param yangModelCmHandle cm handle represented as Yang Model * @param targetCmHandleState target cm handle state */ void updateState(final String cmHandleId, final YangModelCmHandle yangModelCmHandle, final CmHandleState targetCmHandleState);





References

CPS-799 Spike: Define states and state handling for CM handle

CPS-858 Define Notifications on CM Handle Add (Ready) & Delete