+ //TODO handle subscription toward e2term insiged RemoveFromSubscription / hide handleSubscriptionDelete in it?
+ //c.registry.RemoveFromSubscription(subs, trans, 5*time.Second)
+}
+
+//-------------------------------------------------------------------
+// SUBS CREATE Handling
+//-------------------------------------------------------------------
+func (c *Control) handleSubscriptionCreate(subs *Subscription, parentTrans *TransactionXapp) {
+
+ var removeSubscriptionFromDb bool = false
+ trans := c.tracker.NewSubsTransaction(subs)
+ subs.WaitTransactionTurn(trans)
+ defer subs.ReleaseTransactionTurn(trans)
+ defer trans.Release()
+
+ xapp.Logger.Debug("SUBS-SubReq: Handling %s ", idstring(nil, trans, subs, parentTrans))
+
+ subRfMsg, valid := subs.GetCachedResponse()
+ if subRfMsg == nil && valid == true {
+ event := c.sendE2TSubscriptionRequest(subs, trans, parentTrans)
+ switch event.(type) {
+ case *e2ap.E2APSubscriptionResponse:
+ subRfMsg, valid = subs.SetCachedResponse(event, true)
+ subs.SubRespRcvd = true
+ case *e2ap.E2APSubscriptionFailure:
+ removeSubscriptionFromDb = true
+ subRfMsg, valid = subs.SetCachedResponse(event, false)
+ xapp.Logger.Info("SUBS-SubReq: internal delete due failure event(%s) %s", typeofSubsMessage(event), idstring(nil, trans, subs, parentTrans))
+ c.sendE2TSubscriptionDeleteRequest(subs, trans, parentTrans)
+ case *SubmgrRestartTestEvent:
+ // This simulates that no response has been received and after restart subscriptions are restored from db
+ xapp.Logger.Debug("Test restart flag is active. Dropping this transaction to test restart case")
+ return
+ default:
+ xapp.Logger.Info("SUBS-SubReq: internal delete due default event(%s) %s", typeofSubsMessage(event), idstring(nil, trans, subs, parentTrans))
+ removeSubscriptionFromDb = true
+ subRfMsg, valid = subs.SetCachedResponse(nil, false)
+ c.sendE2TSubscriptionDeleteRequest(subs, trans, parentTrans)
+ }
+ xapp.Logger.Debug("SUBS-SubReq: Handling (e2t response %s) %s", typeofSubsMessage(subRfMsg), idstring(nil, trans, subs, parentTrans))
+ } else {
+ xapp.Logger.Debug("SUBS-SubReq: Handling (cached response %s) %s", typeofSubsMessage(subRfMsg), idstring(nil, trans, subs, parentTrans))