X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcontrol%2Fsdl_e2SubsDb.go;h=d1830dee9df6f11ac43ff1e648dd0285a9da6a0e;hb=afadb6df033657afef927964aa637ba7c8fc0880;hp=c2526bcd50c0dc6724a8488391847924cd5b512a;hpb=268d715e3bceab8f7955d89945141efdb2c3b368;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/sdl_e2SubsDb.go b/pkg/control/sdl_e2SubsDb.go index c2526bc..d1830de 100644 --- a/pkg/control/sdl_e2SubsDb.go +++ b/pkg/control/sdl_e2SubsDb.go @@ -29,18 +29,21 @@ import ( "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" ) +const e2SubSdlNs = "submgr_e2SubsDb" + type SubscriptionInfo struct { - Valid bool - ReqId RequestId - Meid xapp.RMRMeid - EpList xapp.RmrEndpointList - SubReqMsg e2ap.E2APSubscriptionRequest - SubRespMsg e2ap.E2APSubscriptionResponse - SubRespRcvd string + Valid bool + ReqId RequestId + Meid xapp.RMRMeid + EpList xapp.RmrEndpointList + SubReqMsg e2ap.E2APSubscriptionRequest + SubRespMsg e2ap.E2APSubscriptionResponse + SubRespRcvd string + PolicyUpdate bool } func CreateSdl() Sdlnterface { - return sdl.NewSdlInstance("submgr_e2SubsDb", sdl.NewDatabase()) + return sdl.NewSyncStorage() } func (c *Control) WriteSubscriptionToSdl(subId uint32, subs *Subscription) error { @@ -51,6 +54,7 @@ func (c *Control) WriteSubscriptionToSdl(subId uint32, subs *Subscription) error subscriptionInfo.Meid = *subs.Meid subscriptionInfo.EpList = subs.EpList subscriptionInfo.SubReqMsg = *subs.SubReqMsg + subscriptionInfo.PolicyUpdate = subs.PolicyUpdate if typeofSubsMessage(subs.SubRFMsg) == "SubResp" { subscriptionInfo.SubRespRcvd = "SubResp" @@ -64,7 +68,7 @@ func (c *Control) WriteSubscriptionToSdl(subId uint32, subs *Subscription) error return fmt.Errorf("SDL: WriteSubscriptionToSdl() json.Marshal error: %s", err.Error()) } - if err = c.e2SubsDb.Set(strconv.FormatUint(uint64(subId), 10), jsonData); err != nil { + if err = c.e2SubsDb.Set(e2SubSdlNs, strconv.FormatUint(uint64(subId), 10), jsonData); err != nil { c.UpdateCounter(cSDLWriteFailure) return fmt.Errorf("SDL: WriteSubscriptionToSdl(): %s", err.Error()) } else { @@ -77,7 +81,7 @@ func (c *Control) ReadSubscriptionFromSdl(subId uint32) (*Subscription, error) { // This function is now just for testing purpose key := strconv.FormatUint(uint64(subId), 10) - retMap, err := c.e2SubsDb.Get([]string{key}) + retMap, err := c.e2SubsDb.Get(e2SubSdlNs, []string{key}) if err != nil { c.UpdateCounter(cSDLReadFailure) return nil, fmt.Errorf("SDL: ReadSubscriptionFromSdl(): %s", err.Error()) @@ -118,6 +122,7 @@ func (c *Control) CreateSubscription(subscriptionInfo *SubscriptionInfo, jsonSub subReq := e2ap.E2APSubscriptionRequest{} subReq = subscriptionInfo.SubReqMsg subs.SubReqMsg = &subReq + subs.PolicyUpdate = subscriptionInfo.PolicyUpdate if subscriptionInfo.SubRespRcvd == "SubResp" { subs.SubRespRcvd = true @@ -135,7 +140,7 @@ func (c *Control) CreateSubscription(subscriptionInfo *SubscriptionInfo, jsonSub func (c *Control) RemoveSubscriptionFromSdl(subId uint32) error { key := strconv.FormatUint(uint64(subId), 10) - if err := c.e2SubsDb.Remove([]string{key}); err != nil { + if err := c.e2SubsDb.Remove(e2SubSdlNs, []string{key}); err != nil { return fmt.Errorf("SDL: RemoveSubscriptionfromSdl(): %s\n", err.Error()) } else { xapp.Logger.Debug("SDL: Subscription removed from e2SubsDb. subId = %v", subId) @@ -154,7 +159,7 @@ func (c *Control) ReadAllSubscriptionsFromSdl() ([]uint32, map[uint32]*Subscript retMap := make(map[uint32]*Subscription) // Get all keys - keys, err := c.e2SubsDb.GetAll() + keys, err := c.e2SubsDb.GetAll(e2SubSdlNs) if err != nil { c.UpdateCounter(cSDLReadFailure) return nil, nil, fmt.Errorf("SDL: ReadAllSubscriptionsFromSdl(), GetAll(). Error while reading E2 subscriptions keys from DBAAS %s\n", err.Error()) @@ -165,7 +170,7 @@ func (c *Control) ReadAllSubscriptionsFromSdl() ([]uint32, map[uint32]*Subscript } // Get all subscriptionInfos - iSubscriptionMap, err := c.e2SubsDb.Get(keys) + iSubscriptionMap, err := c.e2SubsDb.Get(e2SubSdlNs, keys) if err != nil { c.UpdateCounter(cSDLReadFailure) return nil, nil, fmt.Errorf("SDL: ReadAllSubscriptionsFromSdl(), Get(): Error while reading E2 subscriptions from DBAAS %s\n", err.Error()) @@ -210,7 +215,7 @@ func removeNumber(s []uint32, removedNum uint32) ([]uint32, error) { } func (c *Control) RemoveAllSubscriptionsFromSdl() error { - if err := c.e2SubsDb.RemoveAll(); err != nil { + if err := c.e2SubsDb.RemoveAll(e2SubSdlNs); err != nil { c.UpdateCounter(cSDLRemoveFailure) return fmt.Errorf("SDL: RemoveAllSubscriptionsFromSdl(): %s\n", err.Error()) } else { @@ -218,3 +223,14 @@ func (c *Control) RemoveAllSubscriptionsFromSdl() error { } return nil } + +func (c *Control) GetE2KeyCount() (int, error) { + + // Get all keys + keys, err := c.e2SubsDb.GetAll(e2SubSdlNs) + if err != nil { + c.UpdateCounter(cSDLReadFailure) + return 0, fmt.Errorf("SDL: GetE2KeyCount(), GetAll(). Error while reading E2 subscriptions keys from DBAAS %s\n", err.Error()) + } + return len(keys), nil +}