X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcontrol%2Fsdl.go;h=ac8b8fb39e97b28c7b902c128f8bd0606ae0d1ee;hb=316d8a176feac5e67dcaa360c0f5996e87b32904;hp=3a083fb6e43bf7bc66cc4217328688e7cf6274a7;hpb=c92b421ec9f89e77df36422987e478ed8db85299;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/sdl.go b/pkg/control/sdl.go index 3a083fb..ac8b8fb 100644 --- a/pkg/control/sdl.go +++ b/pkg/control/sdl.go @@ -35,7 +35,6 @@ type SubscriptionInfo struct { EpList xapp.RmrEndpointList SubReqMsg e2ap.E2APSubscriptionRequest SubRespMsg e2ap.E2APSubscriptionResponse - SubFailMsg e2ap.E2APSubscriptionFailure SubRespRcvd string } @@ -55,9 +54,6 @@ func (c *Control) WriteSubscriptionToSdl(subId uint32, subs *Subscription) error if typeofSubsMessage(subs.SubRFMsg) == "SubResp" { subscriptionInfo.SubRespRcvd = "SubResp" subscriptionInfo.SubRespMsg = *subs.SubRFMsg.(*e2ap.E2APSubscriptionResponse) - } else if typeofSubsMessage(subs.SubRFMsg) == "SubFail" { - subscriptionInfo.SubRespRcvd = "SubFail" - subscriptionInfo.SubFailMsg = *subs.SubRFMsg.(*e2ap.E2APSubscriptionFailure) } else { subscriptionInfo.SubRespRcvd = "" } @@ -67,8 +63,8 @@ func (c *Control) WriteSubscriptionToSdl(subId uint32, subs *Subscription) error return fmt.Errorf("SDL: WriteSubscriptionToSdl() json.Marshal error: %s", err.Error()) } - err = c.db.Set(strconv.FormatUint(uint64(subId), 10), jsonData) - if err != nil { + if err = c.db.Set(strconv.FormatUint(uint64(subId), 10), jsonData); err != nil { + c.UpdateCounter(cSDLWriteFailure) return fmt.Errorf("SDL: WriteSubscriptionToSdl(): %s", err.Error()) } else { xapp.Logger.Debug("SDL: Subscription written in db. subId = %v", subId) @@ -82,6 +78,7 @@ func (c *Control) ReadSubscriptionFromSdl(subId uint32) (*Subscription, error) { key := strconv.FormatUint(uint64(subId), 10) retMap, err := c.db.Get([]string{key}) if err != nil { + c.UpdateCounter(cSDLReadFailure) return nil, fmt.Errorf("SDL: ReadSubscriptionFromSdl(): %s", err.Error()) } else { xapp.Logger.Debug("SDL: Subscription read from db. subId = %v", subId) @@ -97,8 +94,7 @@ func (c *Control) ReadSubscriptionFromSdl(subId uint32) (*Subscription, error) { subscriptionInfo := &SubscriptionInfo{} jsonSubscriptionInfo := iSubscriptionInfo.(string) - err := json.Unmarshal([]byte(jsonSubscriptionInfo), subscriptionInfo) - if err != nil { + if err := json.Unmarshal([]byte(jsonSubscriptionInfo), subscriptionInfo); err != nil { return nil, fmt.Errorf("SDL: ReadSubscriptionFromSdl() json.unmarshal error: %s\n", err.Error()) } @@ -127,11 +123,6 @@ func (c *Control) CreateSubscription(subscriptionInfo *SubscriptionInfo, jsonSub subResp := e2ap.E2APSubscriptionResponse{} subResp = subscriptionInfo.SubRespMsg subs.SubRFMsg = &subResp - } else if subscriptionInfo.SubRespRcvd == "SubFail" { - subs.SubRespRcvd = false - subFail := e2ap.E2APSubscriptionFailure{} - subFail = subscriptionInfo.SubFailMsg - subs.SubRFMsg = &subFail } else { subs.SubRespRcvd = false subs.SubRFMsg = nil @@ -143,8 +134,7 @@ func (c *Control) CreateSubscription(subscriptionInfo *SubscriptionInfo, jsonSub func (c *Control) RemoveSubscriptionFromSdl(subId uint32) error { key := strconv.FormatUint(uint64(subId), 10) - err := c.db.Remove([]string{key}) - if err != nil { + if err := c.db.Remove([]string{key}); err != nil { return fmt.Errorf("SDL: RemoveSubscriptionfromSdl(): %s\n", err.Error()) } else { xapp.Logger.Debug("SDL: Subscription removed from db. subId = %v", subId) @@ -165,6 +155,7 @@ func (c *Control) ReadAllSubscriptionsFromSdl() ([]uint32, map[uint32]*Subscript // Get all keys keys, err := c.db.GetAll() if err != nil { + c.UpdateCounter(cSDLReadFailure) return nil, nil, fmt.Errorf("SDL: ReadAllSubscriptionsFromSdl(), GetAll(). Error while reading keys from DBAAS %s\n", err.Error()) } @@ -175,6 +166,7 @@ func (c *Control) ReadAllSubscriptionsFromSdl() ([]uint32, map[uint32]*Subscript // Get all subscriptionInfos iSubscriptionMap, err := c.db.Get(keys) if err != nil { + c.UpdateCounter(cSDLReadFailure) return nil, nil, fmt.Errorf("SDL: ReadAllSubscriptionsFromSdl(), Get(): Error while reading subscriptions from DBAAS %s\n", err.Error()) } @@ -187,8 +179,7 @@ func (c *Control) ReadAllSubscriptionsFromSdl() ([]uint32, map[uint32]*Subscript subscriptionInfo := &SubscriptionInfo{} jsonSubscriptionInfo := iSubscriptionInfo.(string) - err := json.Unmarshal([]byte(jsonSubscriptionInfo), subscriptionInfo) - if err != nil { + if err := json.Unmarshal([]byte(jsonSubscriptionInfo), subscriptionInfo); err != nil { return nil, nil, fmt.Errorf("SDL: ReadAllSubscriptionsFromSdl() json.unmarshal error: %s\n", err.Error()) } @@ -200,8 +191,7 @@ func (c *Control) ReadAllSubscriptionsFromSdl() ([]uint32, map[uint32]*Subscript retMap[subscriptionInfo.ReqId.InstanceId] = subs // Remove subId from free subIds. Original slice is modified here! - subIds, err = removeNumber(subIds, subscriptionInfo.ReqId.InstanceId) - if err != nil { + if subIds, err = removeNumber(subIds, subscriptionInfo.ReqId.InstanceId); err != nil { return nil, nil, fmt.Errorf("SDL: ReadAllSubscriptionsFromSdl() error: %s\n", err.Error()) } } @@ -219,8 +209,8 @@ func removeNumber(s []uint32, removedNum uint32) ([]uint32, error) { } func (c *Control) RemoveAllSubscriptionsFromSdl() error { - err := c.db.RemoveAll() - if err != nil { + if err := c.db.RemoveAll(); err != nil { + c.UpdateCounter(cSDLRemoveFailure) return fmt.Errorf("SDL: RemoveAllSubscriptionsFromSdl(): %s\n", err.Error()) } else { xapp.Logger.Debug("SDL: All subscriptions removed from db")