var e2tMaxSubReqTryCount uint64 // Initial try + retry
var e2tMaxSubDelReqTryCount uint64 // Initial try + retry
var readSubsFromDb string
-var restDuplicateCtrl duplicateCtrl
var dbRetryForever string
var dbTryCount int
type Control struct {
*xapp.RMRClient
- e2ap *E2ap
- registry *Registry
- tracker *Tracker
- e2SubsDb Sdlnterface
- restSubsDb Sdlnterface
- CntRecvMsg uint64
- ResetTestFlag bool
- Counters map[string]xapp.Counter
- LoggerLevel uint32
+ e2ap *E2ap
+ registry *Registry
+ tracker *Tracker
+ restDuplicateCtrl *DuplicateCtrl
+ e2SubsDb Sdlnterface
+ restSubsDb Sdlnterface
+ CntRecvMsg uint64
+ ResetTestFlag bool
+ Counters map[string]xapp.Counter
+ LoggerLevel uint32
+ UTTesting bool
}
type RMRMeid struct {
tracker := new(Tracker)
tracker.Init()
+ restDuplicateCtrl := new(DuplicateCtrl)
+ restDuplicateCtrl.Init()
+
c := &Control{e2ap: new(E2ap),
- registry: registry,
- tracker: tracker,
- e2SubsDb: CreateSdl(),
- restSubsDb: CreateRESTSdl(),
- Counters: xapp.Metric.RegisterCounterGroup(GetMetricsOpts(), "SUBMGR"),
- LoggerLevel: 3,
+ registry: registry,
+ tracker: tracker,
+ restDuplicateCtrl: restDuplicateCtrl,
+ e2SubsDb: CreateSdl(),
+ restSubsDb: CreateRESTSdl(),
+ Counters: xapp.Metric.RegisterCounterGroup(GetMetricsOpts(), "SUBMGR"),
+ LoggerLevel: 4,
}
c.ReadConfigParameters("")
xapp.Resource.InjectRoute("/ric/v1/restsubscriptions", c.GetAllRestSubscriptions, "GET")
xapp.Resource.InjectRoute("/ric/v1/symptomdata", c.SymptomDataHandler, "GET")
- go xapp.Subscription.Listen(c.SubscriptionHandler, c.QueryHandler, c.SubscriptionDeleteHandlerCB)
-
if readSubsFromDb == "false" {
return c
}
- restDuplicateCtrl.Init()
-
// Read subscriptions from db
c.ReadE2Subscriptions()
c.ReadRESTSubscriptions()
- /*
- xapp.Logger.Info("Reading subscriptions from db")
- subIds, register, err := c.ReadAllSubscriptionsFromSdl()
- if err != nil {
- xapp.Logger.Error("%v", err)
- } else {
- c.registry.subIds = subIds
- c.registry.register = register
- c.HandleUncompletedSubscriptions(register)
- }
+ go xapp.Subscription.Listen(c.SubscriptionHandler, c.QueryHandler, c.SubscriptionDeleteHandlerCB)
- restSubscriptions, err := c.ReadAllRESTSubscriptionsFromSdl()
- if err != nil {
- xapp.Logger.Error("%v", err)
- } else {
- c.registry.restSubscriptions = restSubscriptions
- }
- */
return c
}
var restSubscription *RESTSubscription
var err error
- prevRestSubsId, exists := restDuplicateCtrl.GetLastKnownRestSubsIdBasedOnMd5sum(md5sum)
+ prevRestSubsId, exists := c.restDuplicateCtrl.GetLastKnownRestSubsIdBasedOnMd5sum(md5sum)
if p.SubscriptionID == "" {
if exists {
restSubscription, err = c.registry.GetRESTSubscription(prevRestSubsId, false)
}
} else {
xapp.Logger.Info("None existing restSubId %s referred by MD5sum %s for a request without subscription ID - deleting cached entry", prevRestSubsId, md5sum)
- restDuplicateCtrl.DeleteLastKnownRestSubsIdBasedOnMd5sum(md5sum)
+ c.restDuplicateCtrl.DeleteLastKnownRestSubsIdBasedOnMd5sum(md5sum)
}
}
err = c.e2ap.FillSubscriptionReqMsgs(params, &subReqList, restSubscription)
if err != nil {
xapp.Logger.Error("%s", err.Error())
- restDuplicateCtrl.DeleteLastKnownRestSubsIdBasedOnMd5sum(md5sum)
+ c.restDuplicateCtrl.DeleteLastKnownRestSubsIdBasedOnMd5sum(md5sum)
c.registry.DeleteRESTSubscription(&restSubId)
c.UpdateCounter(cRestSubFailToXapp)
return nil, err
}
- duplicate := restDuplicateCtrl.IsDuplicateToOngoingTransaction(restSubId, md5sum)
+ duplicate := c.restDuplicateCtrl.IsDuplicateToOngoingTransaction(restSubId, md5sum)
if duplicate {
xapp.Logger.Info("Retransmission blocker direct ACK for request of restSubsId %s restSubId MD5sum %s as retransmission", restSubId, md5sum)
c.UpdateCounter(cRestSubRespToXapp)
return &subResp, nil
}
+ c.WriteRESTSubscriptionToDb(restSubId, restSubscription)
+
go c.processSubscriptionRequests(restSubscription, &subReqList, p.ClientEndpoint, p.Meid, &restSubId, xAppRmrEndpoint, md5sum)
c.UpdateCounter(cRestSubRespToXapp)
func (c *Control) processSubscriptionRequests(restSubscription *RESTSubscription, subReqList *e2ap.SubscriptionRequestList,
clientEndpoint *models.SubscriptionParamsClientEndpoint, meid *string, restSubId *string, xAppRmrEndpoint string, md5sum string) {
- xapp.Logger.Info("Subscription Request count=%v ", len(subReqList.E2APSubscriptionRequests))
+ c.SubscriptionProcessingStartDelay()
+ xapp.Logger.Debug("Subscription Request count=%v ", len(subReqList.E2APSubscriptionRequests))
var xAppEventInstanceID int64
var e2EventInstanceID int64
- defer restDuplicateCtrl.SetMd5sumFromLastOkRequest(*restSubId, md5sum)
+ defer c.restDuplicateCtrl.SetMd5sumFromLastOkRequest(*restSubId, md5sum)
for index := 0; index < len(subReqList.E2APSubscriptionRequests); index++ {
subReqMsg := subReqList.E2APSubscriptionRequests[index]
subRespMsg, err := c.handleSubscriptionRequest(trans, &subReqMsg, meid, *restSubId)
- xapp.Logger.Info("Handled SubscriptionRequest index=%v, %s", index, idstring(nil, trans))
+ xapp.Logger.Debug("Handled SubscriptionRequest index=%v, %s", index, idstring(nil, trans))
+ trans.Release()
if err != nil {
c.sendUnsuccesfullResponseNotification(restSubId, restSubscription, xAppEventInstanceID, err, clientEndpoint, trans)
index, *restSubId, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans))
c.sendSuccesfullResponseNotification(restSubId, restSubscription, xAppEventInstanceID, e2EventInstanceID, clientEndpoint, trans)
}
- trans.Release()
+ }
+}
+
+//-------------------------------------------------------------------
+//
+//------------------------------------------------------------------
+func (c *Control) SubscriptionProcessingStartDelay() {
+ if c.UTTesting == true {
+ // This is temporary fix for the UT problem that notification arrives before subscription response
+ // Correct fix would be to allow notification come before response and process it correctly
+ xapp.Logger.Debug("Setting 50 ms delay before starting processing Subscriptions")
+ <-time.After(time.Millisecond * 50)
+ xapp.Logger.Debug("Continuing after delay")
}
}
restSubscription.DeleteXappIdToE2Id(xAppEventInstanceID)
restSubscription.DeleteE2InstanceId(instanceId)
}
- restDuplicateCtrl.DeleteLastKnownRestSubsIdBasedOnMd5sum(restSubscription.lastReqMd5sum)
+ c.restDuplicateCtrl.DeleteLastKnownRestSubsIdBasedOnMd5sum(restSubscription.lastReqMd5sum)
c.registry.DeleteRESTSubscription(&restSubId)
c.RemoveRESTSubscriptionFromDb(restSubId)
}()