"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
)
+const restSubSdlNs = "submgr_restSubsDb"
+
type RESTSubscriptionInfo struct {
- xAppRmrEndPoint string
+ Created string
+ XAppServiceName string
+ XAppRmrEndPoint string
Meid string
InstanceIds []uint32
- xAppIdToE2Id map[int64]int64
+ XAppIdToE2Id map[int64]int64
SubReqOngoing bool
SubDelReqOngoing bool
Md5sum string
}
func CreateRESTSdl() Sdlnterface {
- return sdl.NewSdlInstance("submgr_restSubsDb", sdl.NewDatabase())
+ return sdl.NewSyncStorage()
}
func (c *Control) WriteRESTSubscriptionToSdl(restSubId string, restSubs *RESTSubscription) error {
var restSubscriptionInfo RESTSubscriptionInfo
- restSubscriptionInfo.xAppRmrEndPoint = restSubs.xAppRmrEndPoint
+ restSubscriptionInfo.Created = restSubs.Created
+ restSubscriptionInfo.XAppServiceName = restSubs.xAppServiceName
+ restSubscriptionInfo.XAppRmrEndPoint = restSubs.xAppRmrEndPoint
restSubscriptionInfo.Meid = restSubs.Meid
restSubscriptionInfo.InstanceIds = restSubs.InstanceIds
- restSubscriptionInfo.xAppIdToE2Id = restSubs.xAppIdToE2Id
+ restSubscriptionInfo.XAppIdToE2Id = restSubs.xAppIdToE2Id
restSubscriptionInfo.SubReqOngoing = restSubs.SubReqOngoing
restSubscriptionInfo.SubDelReqOngoing = restSubs.SubDelReqOngoing
restSubscriptionInfo.Md5sum = restSubs.lastReqMd5sum
return fmt.Errorf("SDL: WriteSubscriptionToSdl() json.Marshal error: %s", err.Error())
}
- if err = c.restSubsDb.Set(restSubId, jsonData); err != nil {
+ if err = c.restSubsDb.Set(restSubSdlNs, restSubId, jsonData); err != nil {
c.UpdateCounter(cSDLWriteFailure)
return fmt.Errorf("SDL: WriteSubscriptionToSdl(): %s", err.Error())
} else {
// This function is now just for testing purpose
key := restSubId
- retMap, err := c.restSubsDb.Get([]string{key})
+ retMap, err := c.restSubsDb.Get(restSubSdlNs, []string{key})
if err != nil {
c.UpdateCounter(cSDLReadFailure)
return nil, fmt.Errorf("SDL: ReadSubscriptionFromSdl(): %s", err.Error())
restSubs = c.CreateRESTSubscription(restSubscriptionInfo, &jsonSubscriptionInfo)
- restDuplicateCtrl.SetMd5sumFromLastOkRequest(restSubId, restSubs.lastReqMd5sum)
+ c.restDuplicateCtrl.SetMd5sumFromLastOkRequest(restSubId, restSubs.lastReqMd5sum)
}
return restSubs, nil
}
func (c *Control) CreateRESTSubscription(restSubscriptionInfo *RESTSubscriptionInfo, jsonSubscriptionInfo *string) *RESTSubscription {
restSubs := &RESTSubscription{}
- restSubs.xAppRmrEndPoint = restSubscriptionInfo.xAppRmrEndPoint
+ restSubs.Created = restSubscriptionInfo.Created
+ restSubs.xAppServiceName = restSubscriptionInfo.XAppServiceName
+ restSubs.xAppRmrEndPoint = restSubscriptionInfo.XAppRmrEndPoint
restSubs.Meid = restSubscriptionInfo.Meid
restSubs.InstanceIds = restSubscriptionInfo.InstanceIds
- restSubs.xAppIdToE2Id = restSubscriptionInfo.xAppIdToE2Id
+ restSubs.xAppIdToE2Id = restSubscriptionInfo.XAppIdToE2Id
restSubs.SubReqOngoing = restSubscriptionInfo.SubReqOngoing
restSubs.SubDelReqOngoing = restSubscriptionInfo.SubDelReqOngoing
restSubs.lastReqMd5sum = restSubscriptionInfo.Md5sum
func (c *Control) RemoveRESTSubscriptionFromSdl(restSubId string) error {
key := restSubId
- if err := c.restSubsDb.Remove([]string{key}); err != nil {
+ if err := c.restSubsDb.Remove(restSubSdlNs, []string{key}); err != nil {
return fmt.Errorf("SDL: RemoveSubscriptionfromSdl(): %s\n", err.Error())
} else {
xapp.Logger.Debug("SDL: Subscription removed from restSubsDb. restSubId = %v", restSubId)
retMap := make(map[string]*RESTSubscription)
// Get all keys
- keys, err := c.restSubsDb.GetAll()
+ keys, err := c.restSubsDb.GetAll(restSubSdlNs)
if err != nil {
c.UpdateCounter(cSDLReadFailure)
return nil, fmt.Errorf("SDL: ReadAllSubscriptionsFromSdl(), GetAll(). Error while reading REST subscriptions keys from DBAAS %s\n", err.Error())
}
// Get all subscriptionInfos
- iRESTSubscriptionMap, err := c.restSubsDb.Get(keys)
+ iRESTSubscriptionMap, err := c.restSubsDb.Get(restSubSdlNs, keys)
if err != nil {
c.UpdateCounter(cSDLReadFailure)
return nil, fmt.Errorf("SDL: ReadAllSubscriptionsFromSdl(), Get(): Error while reading REST subscriptions from DBAAS %s\n", err.Error())
func (c *Control) RemoveAllRESTSubscriptionsFromSdl() error {
- if err := c.restSubsDb.RemoveAll(); err != nil {
+ if err := c.restSubsDb.RemoveAll(restSubSdlNs); err != nil {
c.UpdateCounter(cSDLRemoveFailure)
return fmt.Errorf("SDL: RemoveAllSubscriptionsFromSdl(): %s\n", err.Error())
} else {
- xapp.Logger.Debug("SDL: All subscriptions removed from e2SubsDb")
+ xapp.Logger.Debug("SDL: All subscriptions removed from restSubsDb")
}
return nil
}
+
+func (c *Control) GetRESTKeyCount() (int, error) {
+
+ // Get all keys
+ keys, err := c.restSubsDb.GetAll(restSubSdlNs)
+ if err != nil {
+ c.UpdateCounter(cSDLReadFailure)
+ return 0, fmt.Errorf("SDL: GetRESTKeyCount(), GetAll(). Error while reading E2 subscriptions keys from DBAAS %s\n", err.Error())
+ }
+ return len(keys), nil
+}