X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcontrol%2Fsubscription.go;h=58f0adf545703644eaa18263e4e8df1af718ac4b;hb=6ec447f82f4be787897432dc291e2d1fb0f771f1;hp=c3e1c205cecaa85e03995deed140ceec8287ebd4;hpb=d708a43badb0742684b22866977f14cc1c03a1ba;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/subscription.go b/pkg/control/subscription.go index c3e1c20..58f0adf 100644 --- a/pkg/control/subscription.go +++ b/pkg/control/subscription.go @@ -21,8 +21,8 @@ package control import ( "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap" - "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks" "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" + "sync" ) @@ -30,20 +30,33 @@ import ( // //----------------------------------------------------------------------------- type Subscription struct { - mutex sync.Mutex // Lock - valid bool // valid - registry *Registry // Registry - ReqId RequestId // ReqId (Requestor Id + Seq Nro a.k.a subsid) - Meid *xapp.RMRMeid // Meid/ RanName - EpList RmrEndpointList // Endpoints - TransLock sync.Mutex // Lock transactions, only one executed per time for subs - TheTrans TransactionIf // Ongoing transaction - SubReqMsg *e2ap.E2APSubscriptionRequest // Subscription information - SubRFMsg interface{} // Subscription information + mutex sync.Mutex // Lock + valid bool // valid + registry *Registry // Registry + ReqId RequestId // ReqId (Requestor Id + Seq Nro a.k.a subsid) + Meid *xapp.RMRMeid // Meid/RanName + EpList xapp.RmrEndpointList // Endpoints + RMRRouteCreated bool // Does subscription have RMR route + TransLock sync.Mutex // Lock transactions, only one executed per time for subs + TheTrans TransactionIf // Ongoing transaction + SubReqMsg *e2ap.E2APSubscriptionRequest // Subscription information + SubRFMsg interface{} // Subscription information + OngoingReqCount int // Subscription create process is ongoing. In merge case it can ongoing for more than one endpoint + OngoingDelCount int // Subscription delete process is ongoing. In merge case it can ongoing for more than one endpoint + PolicyUpdate bool // This is true when policy subscrition is being updated. Used not to send delete for update after timeout or restart + RetryFromXapp bool // Retry form xApp for subscription that already exist + SubRespRcvd bool // Subscription response received + DeleteFromDb bool // Delete subscription from db + NoRespToXapp bool // Send no response for subscription delete to xApp after restart + DoNotWaitSubResp bool // Test flag. Response is not waited for Subscription Request } func (s *Subscription) String() string { - return "subs(" + s.ReqId.String() + "/" + (&xapptweaks.RMRMeid{s.Meid}).String() + "/" + s.EpList.String() + ")" + meidstr := "N/A" + if s.Meid != nil { + meidstr = s.Meid.String() + } + return "subs(" + s.ReqId.String() + "/" + meidstr + "/" + s.EpList.String() + ")" } func (s *Subscription) GetCachedResponse() (interface{}, bool) { @@ -69,10 +82,7 @@ func (s *Subscription) GetReqId() *RequestId { func (s *Subscription) GetMeid() *xapp.RMRMeid { s.mutex.Lock() defer s.mutex.Unlock() - if s.Meid != nil { - return s.Meid - } - return nil + return s.Meid } func (s *Subscription) GetTransaction() TransactionIf { @@ -114,22 +124,13 @@ func (s *Subscription) IsMergeable(trans *TransactionXapp, subReqMsg *e2ap.E2APS } // EventTrigger check - if s.SubReqMsg.EventTriggerDefinition.InterfaceDirection != subReqMsg.EventTriggerDefinition.InterfaceDirection || - s.SubReqMsg.EventTriggerDefinition.ProcedureCode != subReqMsg.EventTriggerDefinition.ProcedureCode || - s.SubReqMsg.EventTriggerDefinition.TypeOfMessage != subReqMsg.EventTriggerDefinition.TypeOfMessage { - return false - } - - if s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present || - s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId || - s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.String() != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.String() { + if s.SubReqMsg.EventTriggerDefinition.Data.Length != subReqMsg.EventTriggerDefinition.Data.Length { return false } - - if s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.Present != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.Present || - s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.NodeId != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.NodeId || - s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.PlmnIdentity.String() != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.PlmnIdentity.String() { - return false + for i := uint64(0); i < s.SubReqMsg.EventTriggerDefinition.Data.Length; i++ { + if s.SubReqMsg.EventTriggerDefinition.Data.Data[i] != subReqMsg.EventTriggerDefinition.Data.Data[i] { + return false + } } // Actions check @@ -150,11 +151,18 @@ func (s *Subscription) IsMergeable(trans *TransactionXapp, subReqMsg *e2ap.E2APS return false } - if acts.ActionDefinition.Present != actt.ActionDefinition.Present || - acts.ActionDefinition.StyleId != actt.ActionDefinition.StyleId || - acts.ActionDefinition.ParamId != actt.ActionDefinition.ParamId { + if acts.RicActionDefinitionPresent != actt.RicActionDefinitionPresent { + return false + } + + if acts.ActionDefinitionChoice.Data.Length != actt.ActionDefinitionChoice.Data.Length { return false } + for i := uint64(0); i < acts.ActionDefinitionChoice.Data.Length; i++ { + if acts.ActionDefinitionChoice.Data.Data[i] != actt.ActionDefinitionChoice.Data.Data[i] { + return false + } + } if acts.SubsequentAction.Present != actt.SubsequentAction.Present || acts.SubsequentAction.Type != actt.SubsequentAction.Type || acts.SubsequentAction.TimetoWait != actt.SubsequentAction.TimetoWait { @@ -162,6 +170,5 @@ func (s *Subscription) IsMergeable(trans *TransactionXapp, subReqMsg *e2ap.E2APS } } } - return true }