2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================================
24 rtmgrclient "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client"
25 rtmgrhandle "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client/handle"
26 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
27 httptransport "github.com/go-openapi/runtime/client"
28 "github.com/go-openapi/strfmt"
29 "github.com/spf13/viper"
35 var subReqTime time.Duration = 5 * time.Second
36 var subDelReqTime time.Duration = 5 * time.Second
37 var maxSubReqTryCount uint64 = 2 // Initial try + retry
38 var maxSubDelReqTryCount uint64 = 2 // Initial try + retry
43 rtmgrClient *RtmgrClient
46 rmrSendMutex sync.Mutex
66 xapp.Logger.Info("SUBMGR")
68 viper.SetEnvPrefix("submgr")
69 viper.AllowEmptyEnv(true)
70 seedSN = uint16(viper.GetInt("seed_sn"))
72 rand.Seed(time.Now().UnixNano())
73 seedSN = uint16(rand.Intn(65535))
78 xapp.Logger.Info("SUBMGR: Initial Sequence Number: %v", seedSN)
81 func NewControl() *Control {
82 registry := new(Registry)
83 registry.Initialize(seedSN)
85 tracker := new(Tracker)
88 timerMap := new(TimerMap)
91 transport := httptransport.New(viper.GetString("rtmgr.HostAddr")+":"+viper.GetString("rtmgr.port"), viper.GetString("rtmgr.baseUrl"), []string{"http"})
92 client := rtmgrclient.New(transport, strfmt.Default)
93 handle := rtmgrhandle.NewProvideXappSubscriptionHandleParamsWithTimeout(10 * time.Second)
94 deleteHandle := rtmgrhandle.NewDeleteXappSubscriptionHandleParamsWithTimeout(10 * time.Second)
95 rtmgrClient := RtmgrClient{client, handle, deleteHandle}
97 return &Control{e2ap: new(E2ap),
99 rtmgrClient: &rtmgrClient,
106 func (c *Control) Run() {
110 func (c *Control) rmrSend(params *xapp.RMRParams) (err error) {
113 for ; i <= 10 && status == false; i++ {
114 c.rmrSendMutex.Lock()
115 status = xapp.Rmr.Send(params, false)
116 c.rmrSendMutex.Unlock()
118 xapp.Logger.Info("rmr.Send() failed. Retry count %v, Mtype: %v, SubId: %v, Xid %s", i, params.Mtype, params.SubId, params.Xid)
119 time.Sleep(500 * time.Millisecond)
123 err = errors.New("rmr.Send() failed")
124 xapp.Rmr.Free(params.Mbuf)
129 func (c *Control) rmrReplyToSender(params *xapp.RMRParams) (err error) {
134 func (c *Control) Consume(msg *xapp.RMRParams) (err error) {
137 case xapp.RICMessageTypes["RIC_SUB_REQ"]:
138 go c.handleSubscriptionRequest(msg)
139 case xapp.RICMessageTypes["RIC_SUB_RESP"]:
140 go c.handleSubscriptionResponse(msg)
141 case xapp.RICMessageTypes["RIC_SUB_FAILURE"]:
142 go c.handleSubscriptionFailure(msg)
143 case xapp.RICMessageTypes["RIC_SUB_DEL_REQ"]:
144 go c.handleSubscriptionDeleteRequest(msg)
145 case xapp.RICMessageTypes["RIC_SUB_DEL_RESP"]:
146 go c.handleSubscriptionDeleteResponse(msg)
147 case xapp.RICMessageTypes["RIC_SUB_DEL_FAILURE"]:
148 go c.handleSubscriptionDeleteFailure(msg)
150 xapp.Logger.Info("Unknown Message Type '%d', discarding", msg.Mtype)
155 func (c *Control) handleSubscriptionRequest(params *xapp.RMRParams) {
156 xapp.Logger.Info("SubReq received from Src: %s, Mtype: %v, SubId: %v, Xid: %s, Meid: %v", params.Src, params.Mtype, params.SubId, params.Xid, params.Meid)
157 xapp.Rmr.Free(params.Mbuf)
160 /* Reserve a sequence number and set it in the payload */
161 subs := c.registry.ReserveSubscription()
163 xapp.Logger.Error("SubReq: Failed to reserve sequence number. Dropping this msg. SubId: %v, Xid: %s", params.SubId, params.Xid)
167 params.SubId = int(subs.Seq)
168 err := c.e2ap.SetSubscriptionRequestSequenceNumber(params.Payload, subs.Seq)
170 xapp.Logger.Error("SubReq: Unable to get Sequence Number from Payload. Dropping this msg. Err: %v, SubId: %v, Xid: %s, Payload %X", err, params.SubId, params.Xid, params.Payload)
171 c.registry.releaseSequenceNumber(subs.Seq)
175 srcAddr, srcPort, err := c.rtmgrClient.SplitSource(params.Src)
177 xapp.Logger.Error("SubReq: Failed to update routing-manager. Dropping this msg. Err: %s, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
178 c.registry.releaseSequenceNumber(subs.Seq)
182 // Create transatcion record for every subscription request
183 var forwardRespToXapp bool = true
184 var responseReceived bool = false
185 transaction, err := c.tracker.TrackTransaction(subs.Seq, CREATE, *srcAddr, *srcPort, params, responseReceived, forwardRespToXapp)
187 xapp.Logger.Error("SubReq: Failed to create transaction record. Dropping this msg. Err: %v SubId: %v, Xid: %s", err, params.SubId, params.Xid)
188 c.registry.releaseSequenceNumber(subs.Seq)
192 // Update routing manager about the new subscription
193 subRouteAction := transaction.SubRouteInfo()
194 xapp.Logger.Info("SubReq: Starting routing manager update. SubId: %v, Xid: %s", params.SubId, params.Xid)
196 err = c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
198 xapp.Logger.Error("SubReq: Failed to update routing manager. Dropping this msg. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
199 c.registry.releaseSequenceNumber(subs.Seq)
203 // Setting new subscription ID in the RMR header
204 xapp.Logger.Info("SubReq: Forwarding SubReq to E2T: Mtype: %v, SubId: %v, Xid %s, Meid %v", params.Mtype, params.SubId, params.Xid, params.Meid)
205 err = c.rmrSend(params)
207 xapp.Logger.Error("SubReq: Failed to send request to E2T %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
209 c.timerMap.StartTimer("RIC_SUB_REQ", int(subs.Seq), subReqTime, FirstTry, c.handleSubscriptionRequestTimer)
210 xapp.Logger.Debug("SubReq: Debugging transaction table = %v", c.tracker.transactionTable)
214 func (c *Control) handleSubscriptionResponse(params *xapp.RMRParams) {
215 xapp.Logger.Info("SubResp received from Src: %s, Mtype: %v, SubId: %v, Meid: %v", params.Src, params.Mtype, params.SubId, params.Meid)
216 xapp.Rmr.Free(params.Mbuf)
219 payloadSeqNum, err := c.e2ap.GetSubscriptionResponseSequenceNumber(params.Payload)
221 xapp.Logger.Error("SubResp: Unable to get Sequence Number from Payload. Dropping this msg. Err: %v, SubId: %v, Xid: %s, Payload %X", err, params.SubId, params.Xid, params.Payload)
224 xapp.Logger.Info("SubResp: Received payloadSeqNum: %v", payloadSeqNum)
226 if !c.registry.IsValidSequenceNumber(payloadSeqNum) {
227 xapp.Logger.Error("SubResp: Unknown payloadSeqNum. Dropping this msg. PayloadSeqNum: %v, SubId: %v", payloadSeqNum, params.SubId)
231 c.timerMap.StopTimer("RIC_SUB_REQ", int(payloadSeqNum))
233 transaction, responseReceived, err := c.tracker.CheckResponseReceived(payloadSeqNum, CREATE)
235 xapp.Logger.Info("SubResp: Dropping this msg. Err: %v SubId: %v", err, payloadSeqNum)
239 if responseReceived == true {
240 // Subscription timer already received
243 xapp.Logger.Info("SubResp: SubId: %v, from address: %v:%v.", payloadSeqNum, transaction.Xappkey.Addr, transaction.Xappkey.Port)
245 c.registry.setSubscriptionToConfirmed(payloadSeqNum)
247 params.SubId = int(payloadSeqNum)
248 params.Xid = transaction.OrigParams.Xid
250 xapp.Logger.Info("SubResp: Forwarding Subscription Response to xApp Mtype: %v, SubId: %v, Meid: %v", params.Mtype, params.SubId, params.Meid)
251 err = c.rmrReplyToSender(params)
253 xapp.Logger.Error("SubResp: Failed to send response to xApp. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
256 xapp.Logger.Info("SubResp: SubId: %v, from address: %v:%v. Deleting transaction record", payloadSeqNum, transaction.Xappkey.Addr, transaction.Xappkey.Port)
257 _, err = c.tracker.completeTransaction(payloadSeqNum, CREATE)
259 xapp.Logger.Error("SubResp: Failed to delete transaction record. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
265 func (c *Control) handleSubscriptionFailure(params *xapp.RMRParams) {
266 xapp.Logger.Info("SubFail received from Src: %s, Mtype: %v, SubId: %v, Meid: %v", params.Src, params.Mtype, params.SubId, params.Meid)
267 xapp.Rmr.Free(params.Mbuf)
270 payloadSeqNum, err := c.e2ap.GetSubscriptionFailureSequenceNumber(params.Payload)
272 xapp.Logger.Error("SubFail: Unable to get Sequence Number from Payload. Dropping this msg. Err: %v, SubId: %v, Xid: %s, Payload %X", err, params.SubId, params.Xid, params.Payload)
275 xapp.Logger.Info("SubFail: Received payloadSeqNum: %v", payloadSeqNum)
277 c.timerMap.StopTimer("RIC_SUB_REQ", int(payloadSeqNum))
279 transaction, responseReceived, err := c.tracker.CheckResponseReceived(payloadSeqNum, CREATE)
281 xapp.Logger.Info("SubFail: Dropping this msg. Err: %v SubId: %v", err, payloadSeqNum)
285 if responseReceived == true {
286 // Subscription timer already received
289 xapp.Logger.Info("SubFail: SubId: %v, from address: %v:%v. Forwarding response to xApp", payloadSeqNum, transaction.Xappkey.Addr, transaction.Xappkey.Port)
291 time.Sleep(3 * time.Second)
293 xapp.Logger.Info("SubFail: Starting routing manager update. SubId: %v, Xid: %s", params.SubId, params.Xid)
294 subRouteAction := transaction.SubRouteInfo()
295 err = c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
297 xapp.Logger.Error("SubFail: Failed to update routing manager. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
300 xapp.Logger.Info("SubFail: Deleting transaction record. SubId: %v, Xid: %s", params.SubId, params.Xid)
301 if c.registry.releaseSequenceNumber(payloadSeqNum) {
302 _, err = c.tracker.completeTransaction(payloadSeqNum, CREATE)
304 xapp.Logger.Error("SubFail: Failed to delete transaction record. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
308 xapp.Logger.Error("SubFail: Failed to release sequency number. SubId: %v, Xid: %s", params.SubId, params.Xid)
314 func (c *Control) handleSubscriptionRequestTimer(strId string, nbrId int, tryCount uint64) {
315 subId := uint16(nbrId)
316 xapp.Logger.Info("handleSubTimer: SubReq timer expired. subId: %v, tryCount: %v", subId, tryCount)
318 transaction, responseReceived, err := c.tracker.CheckResponseReceived(subId, CREATE)
320 xapp.Logger.Info("handleSubTimer: Dropping this timer action. Err: %v SubId: %v", err, subId)
324 if responseReceived == true {
325 // Subscription Response or Failure already received
329 if tryCount < maxSubReqTryCount {
330 xapp.Logger.Info("handleSubTimer: Resending SubReq to E2T: Mtype: %v, SubId: %v, Xid %s, Meid %v", transaction.OrigParams.Mtype, transaction.OrigParams.SubId, transaction.OrigParams.Xid, transaction.OrigParams.Meid)
331 // Set possible to handle new response for the subId
332 err = c.tracker.RetryTransaction(subId, CREATE)
334 xapp.Logger.Error("handleSubDelTimer: Failed to retry transaction record. Dropping timer action. Err %v, SubId: %v", err, transaction.OrigParams.SubId)
338 err = c.rmrSend(transaction.OrigParams)
340 xapp.Logger.Error("handleSubTimer: Failed to send request to E2T %v, SubId: %v, Xid: %s", err, transaction.OrigParams.SubId, transaction.OrigParams.Xid)
344 c.timerMap.StartTimer("RIC_SUB_REQ", int(subId), subReqTime, tryCount, c.handleSubscriptionRequestTimer)
348 var subDelReqPayload []byte
349 subDelReqPayload, err = c.e2ap.PackSubscriptionDeleteRequest(transaction.OrigParams.Payload, subId)
351 xapp.Logger.Error("handleSubTimer: Packing SubDelReq failed. Err: %v", err)
355 // Cancel failed subscription
356 var params xapp.RMRParams
357 params.Mtype = 12020 // RIC SUBSCRIPTION DELETE
358 params.SubId = int(subId)
359 params.Xid = transaction.OrigParams.Xid
360 params.Meid = transaction.OrigParams.Meid
361 params.Src = transaction.OrigParams.Src
362 params.PayloadLen = len(subDelReqPayload)
363 params.Payload = subDelReqPayload
366 // Delete CREATE transaction
367 _, err = c.tracker.completeTransaction(subId, CREATE)
369 xapp.Logger.Error("handleSubTimer: Failed to delete create transaction record. Dropping this timer action. Err: %v, SubId: %v, Xid: %s", err, subId, params.Xid)
373 // Create DELETE transaction
374 var forwardRespToXapp bool = false
375 _, err = c.trackDeleteTransaction(¶ms, subId, forwardRespToXapp)
377 xapp.Logger.Error("handleSubTimer: Failed to create delete transaction record. Dropping this timer action. Err: %v, SubId: %v, Xid: %s", err, subId, params.Xid)
381 xapp.Logger.Info("handleSubTimer: Sending SubDelReq to E2T: Mtype: %v, SubId: %v, Meid: %v", params.Mtype, params.SubId, params.Meid)
384 xapp.Logger.Error("handleSubTimer: Failed to send request to E2T %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid)
386 c.timerMap.StartTimer("RIC_SUB_DEL_REQ", int(subId), subDelReqTime, FirstTry, c.handleSubscriptionDeleteRequestTimer)
390 func (act Action) String() string {
391 actions := [...]string{
398 if act < CREATE || act > DELETE {
404 func (act Action) valid() bool {
406 case CREATE, MERGE, DELETE:
413 func (c *Control) handleSubscriptionDeleteRequest(params *xapp.RMRParams) {
414 xapp.Logger.Info("SubDelReq received from Src: %s, Mtype: %v, SubId: %v, Xid: %s, Meid: %v", params.Src, params.Mtype, params.SubId, params.Xid, params.Meid)
415 xapp.Rmr.Free(params.Mbuf)
418 payloadSeqNum, err := c.e2ap.GetSubscriptionDeleteRequestSequenceNumber(params.Payload)
420 xapp.Logger.Error("SubDelReq: Unable to get Sequence Number from Payload. Dropping this msg. Err: %v, SubId: %v, Xid: %s, Payload %X", err, params.SubId, params.Xid, params.Payload)
423 xapp.Logger.Info("SubDelReq: Received payloadSeqNum: %v", payloadSeqNum)
425 if c.registry.IsValidSequenceNumber(payloadSeqNum) {
426 var forwardRespToXapp bool = true
427 _, err = c.trackDeleteTransaction(params, payloadSeqNum, forwardRespToXapp)
429 xapp.Logger.Error("SubDelReq: Failed to create transaction record. Dropping this msg. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
432 c.registry.setSubscriptionToUnConfirmed(payloadSeqNum)
434 xapp.Logger.Error("SubDelReq: Not valid sequence number. Dropping this msg. SubId: %v, Xid: %s", params.SubId, params.Xid)
438 xapp.Logger.Info("SubDelReq: Forwarding Request to E2T. Mtype: %v, SubId: %v, Xid: %s, Meid: %v", params.Mtype, params.SubId, params.Xid, params.Meid)
441 xapp.Logger.Error("SubDelReq: Failed to send request to E2T. Err %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
443 c.timerMap.StartTimer("RIC_SUB_DEL_REQ", int(payloadSeqNum), subDelReqTime, FirstTry, c.handleSubscriptionDeleteRequestTimer)
447 func (c *Control) trackDeleteTransaction(params *xapp.RMRParams, payloadSeqNum uint16, forwardRespToXapp bool) (transaction *Transaction, err error) {
448 srcAddr, srcPort, err := c.rtmgrClient.SplitSource(params.Src)
450 xapp.Logger.Error("Failed to split source address. Err: %s, SubId: %v, Xid: %s", err, payloadSeqNum, params.Xid)
452 var respReceived bool = false
453 transaction, err = c.tracker.TrackTransaction(payloadSeqNum, DELETE, *srcAddr, *srcPort, params, respReceived, forwardRespToXapp)
457 func (c *Control) handleSubscriptionDeleteResponse(params *xapp.RMRParams) (err error) {
458 xapp.Logger.Info("SubDelResp received from Src: %s, Mtype: %v, SubId: %v, Meid: %v", params.Src, params.Mtype, params.SubId, params.Meid)
459 xapp.Rmr.Free(params.Mbuf)
462 payloadSeqNum, err := c.e2ap.GetSubscriptionDeleteResponseSequenceNumber(params.Payload)
464 xapp.Logger.Error("SubDelResp: Unable to get Sequence Number from Payload. Dropping this msg. Err: %v, SubId: %v, Xid: %s, Payload %X", err, params.SubId, params.Xid, params.Payload)
467 xapp.Logger.Info("SubDelResp: Received payloadSeqNum: %v", payloadSeqNum)
469 c.timerMap.StopTimer("RIC_SUB_DEL_REQ", int(payloadSeqNum))
471 transaction, responseReceived, err := c.tracker.CheckResponseReceived(payloadSeqNum, DELETE)
473 xapp.Logger.Info("SubDelResp: Dropping this msg. Err: %v SubId: %v", err, payloadSeqNum)
477 if responseReceived == true {
478 // Subscription Delete timer already received
481 xapp.Logger.Info("SubDelResp: SubId: %v, from address: %v:%v. Forwarding response to xApp", payloadSeqNum, transaction.Xappkey.Addr, transaction.Xappkey.Port)
483 if transaction.ForwardRespToXapp == true {
484 params.SubId = int(payloadSeqNum)
485 params.Xid = transaction.OrigParams.Xid
486 xapp.Logger.Info("Forwarding SubDelResp to xApp: Mtype: %v, SubId: %v, Xid: %v, Meid: %v", params.Mtype, params.SubId, params.Xid, params.Meid)
487 err = c.rmrReplyToSender(params)
489 xapp.Logger.Error("SubDelResp: Failed to send response to xApp. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
492 time.Sleep(3 * time.Second)
495 xapp.Logger.Info("SubDelResp: Starting routing manager update. SubId: %v, Xid: %s", params.SubId, params.Xid)
496 subRouteAction := SubRouteInfo{DELETE, transaction.Xappkey.Addr, transaction.Xappkey.Port, payloadSeqNum}
497 err = c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
499 xapp.Logger.Error("SubDelResp: Failed to update routing manager. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
503 xapp.Logger.Info("SubDelResp: Deleting transaction record. SubId: %v, Xid: %s", params.SubId, params.Xid)
504 if c.registry.releaseSequenceNumber(payloadSeqNum) {
505 _, err = c.tracker.completeTransaction(payloadSeqNum, DELETE)
507 xapp.Logger.Error("SubDelResp: Failed to delete transaction record. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
511 xapp.Logger.Error("SubDelResp: Failed to release sequency number. SubId: %v, Xid: %s", params.SubId, params.Xid)
517 func (c *Control) handleSubscriptionDeleteFailure(params *xapp.RMRParams) {
518 xapp.Logger.Info("SubDelFail received from Src: %s, Mtype: %v, SubId: %v, Meid: %v", params.Src, params.Mtype, params.SubId, params.Meid)
519 xapp.Rmr.Free(params.Mbuf)
522 payloadSeqNum, err := c.e2ap.GetSubscriptionDeleteFailureSequenceNumber(params.Payload)
524 xapp.Logger.Error("SubDelFail: Unable to get Sequence Number from Payload. Dropping this msg. Err: %v, SubId: %v, Xid: %s, Payload %X", err, params.SubId, params.Xid, params.Payload)
527 xapp.Logger.Info("SubDelFail: Received payloadSeqNum: %v", payloadSeqNum)
529 c.timerMap.StopTimer("RIC_SUB_DEL_REQ", int(payloadSeqNum))
531 transaction, responseReceived, err := c.tracker.CheckResponseReceived(payloadSeqNum, DELETE)
533 xapp.Logger.Info("SubDelFail: Dropping this msg. Err: %v SubId: %v", err, payloadSeqNum)
537 if responseReceived == true {
538 // Subscription Delete timer already received
541 xapp.Logger.Info("SubDelFail: SubId: %v, from address: %v:%v. Forwarding response to xApp", payloadSeqNum, transaction.Xappkey.Addr, transaction.Xappkey.Port)
543 if transaction.ForwardRespToXapp == true {
544 var subDelRespPayload []byte
545 subDelRespPayload, err = c.e2ap.PackSubscriptionDeleteResponse(transaction.OrigParams.Payload, payloadSeqNum)
547 xapp.Logger.Error("SubDelFail:Packing SubDelResp failed. Err: %v", err)
551 params.Mtype = 12021 // RIC SUBSCRIPTION DELETE RESPONSE
552 params.SubId = int(payloadSeqNum)
553 params.Xid = transaction.OrigParams.Xid
554 params.Meid = transaction.OrigParams.Meid
555 params.Src = transaction.OrigParams.Src
556 params.PayloadLen = len(subDelRespPayload)
557 params.Payload = subDelRespPayload
559 xapp.Logger.Info("SubDelFail: Forwarding SubDelFail to xApp: Mtype: %v, SubId: %v, Xid: %v, Meid: %v", params.Mtype, params.SubId, params.Xid, params.Meid)
560 err = c.rmrReplyToSender(params)
562 xapp.Logger.Error("SubDelFail: Failed to send SubDelFail to xApp. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
565 time.Sleep(3 * time.Second)
568 xapp.Logger.Info("SubDelFail: Starting routing manager update. SubId: %v, Xid: %s", params.SubId, params.Xid)
569 subRouteAction := SubRouteInfo{DELETE, transaction.Xappkey.Addr, transaction.Xappkey.Port, payloadSeqNum}
570 err = c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
572 xapp.Logger.Error("SubDelFail: Failed to update routing manager. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
576 xapp.Logger.Info("SubDelFail: Deleting transaction record. SubId: %v, Xid: %s", params.SubId, params.Xid)
577 if c.registry.releaseSequenceNumber(payloadSeqNum) {
578 _, err = c.tracker.completeTransaction(payloadSeqNum, DELETE)
580 xapp.Logger.Error("SubDelFail: Failed to delete transaction record. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
584 xapp.Logger.Error("SubDelFail: Failed to release sequency number. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
590 func (c *Control) handleSubscriptionDeleteRequestTimer(strId string, nbrId int, tryCount uint64) {
591 subId := uint16(nbrId)
592 xapp.Logger.Info("handleSubDelTimer: SubDelReq timer expired. subId: %v, tryCount: %v", subId, tryCount)
594 transaction, responseReceived, err := c.tracker.CheckResponseReceived(subId, DELETE)
596 xapp.Logger.Info("handleSubTimer: Dropping this timer action. Err: %v SubId: %v", err, subId)
600 if responseReceived == true {
601 // Subscription Delete Response or Failure already received
605 if tryCount < maxSubDelReqTryCount {
606 xapp.Logger.Info("handleSubDelTimer: Resending SubDelReq to E2T: Mtype: %v, SubId: %v, Xid %s, Meid %v", transaction.OrigParams.Mtype, transaction.OrigParams.SubId, transaction.OrigParams.Xid, transaction.OrigParams.Meid)
607 // Set possible to handle new response for the subId
608 err = c.tracker.RetryTransaction(subId, DELETE)
610 xapp.Logger.Error("handleSubDelTimer: Failed to retry transaction record. Dropping timer action. Err %v, SubId: %v", err, transaction.OrigParams.SubId)
614 err = c.rmrSend(transaction.OrigParams)
616 xapp.Logger.Error("handleSubDelTimer: Failed to send request to E2T %v, SubId: %v, Xid: %s", err, transaction.OrigParams.SubId, transaction.OrigParams.Xid)
620 c.timerMap.StartTimer("RIC_SUB_DEL_REQ", int(subId), subReqTime, tryCount, c.handleSubscriptionDeleteRequestTimer)
624 var params xapp.RMRParams
625 if transaction.ForwardRespToXapp == true {
626 var subDelRespPayload []byte
627 subDelRespPayload, err = c.e2ap.PackSubscriptionDeleteResponse(transaction.OrigParams.Payload, subId)
629 xapp.Logger.Error("handleSubDelTimer: Unable to pack payload. Dropping this timer action. Err: %v, SubId: %v, Xid: %s, Payload %x", err, subId, transaction.OrigParams.Xid, transaction.OrigParams.Payload)
633 params.Mtype = 12021 // RIC SUBSCRIPTION DELETE RESPONSE
634 params.SubId = int(subId)
635 params.Meid = transaction.OrigParams.Meid
636 params.Xid = transaction.OrigParams.Xid
637 params.Src = transaction.OrigParams.Src
638 params.PayloadLen = len(subDelRespPayload)
639 params.Payload = subDelRespPayload
642 xapp.Logger.Info("handleSubDelTimer: Sending SubDelResp to xApp: Mtype: %v, SubId: %v, Xid: %s, Meid: %v", params.Mtype, params.SubId, params.Xid, params.Meid)
643 err = c.rmrReplyToSender(¶ms)
645 xapp.Logger.Error("handleSubDelTimer: Failed to send response to xApp: Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
648 time.Sleep(3 * time.Second)
651 xapp.Logger.Info("handleSubDelTimer: Starting routing manager update. SubId: %v, Xid: %s", subId, params.Xid)
652 subRouteAction := SubRouteInfo{DELETE, transaction.Xappkey.Addr, transaction.Xappkey.Port, subId}
653 err = c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
655 xapp.Logger.Error("handleSubDelTimer: Failed to update routing manager. Err: %v, SubId: %v, Xid: %s", err, subId, params.Xid)
659 xapp.Logger.Info("handleSubDelTimer: Deleting transaction record. SubId: %v, Xid: %s", subId, params.Xid)
660 if c.registry.releaseSequenceNumber(subId) {
661 _, err = c.tracker.completeTransaction(subId, DELETE)
663 xapp.Logger.Error("handleSubDelTimer: Failed to delete transaction record. Err: %v, SubId: %v, Xid: %s", err, subId, params.Xid)
667 xapp.Logger.Error("handleSubDelTimer: Failed to release sequency number. SubId: %v, Xid: %s", subId, params.Xid)