2 // Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved.
\r
4 // Licensed under the Apache License, Version 2.0 (the "License");
\r
5 // you may not use this file except in compliance with the License.
\r
6 // You may obtain a copy of the License at
\r
8 // http://www.apache.org/licenses/LICENSE-2.0
\r
10 // Unless required by applicable law or agreed to in writing, software
\r
11 // distributed under the License is distributed on an "AS IS" BASIS,
\r
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 // See the License for the specific language governing permissions and
\r
14 // limitations under the License.
\r
16 // This source code is part of the near-RT RIC (RAN Intelligent Controller)
\r
17 // platform project (RICP).
\r
19 package rmrmsghandlers
\r
22 "e2mgr/configuration"
\r
29 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
\r
32 const E2ResetRequestLogInfoElapsedTime = "#E2ResetRequestNotificationHandler.Handle - Summary: elapsed time for receiving and handling reset request message from E2 terminator: %f ms"
\r
34 type E2ResetRequestNotificationHandler struct {
\r
35 logger *logger.Logger
\r
36 rnibDataService services.RNibDataService
\r
37 config *configuration.Configuration
\r
40 func NewE2ResetRequestNotificationHandler(logger *logger.Logger, rnibDataService services.RNibDataService, config *configuration.Configuration) *E2ResetRequestNotificationHandler {
\r
41 return &E2ResetRequestNotificationHandler{
\r
43 rnibDataService: rnibDataService,
\r
48 func (e *E2ResetRequestNotificationHandler) Handle(request *models.NotificationRequest) {
\r
50 e.logger.Infof("#E2ResetRequestNotificationHandler.Handle - RAN name: %s - received E2_Reset. Payload: %x", request.RanName, request.Payload)
\r
52 e.logger.Debugf("#E2ResetRequestNotificationHandler.Handle - RIC_E2_Node_Reset parsed successfully ")
\r
54 nodebInfo, err := e.getNodebInfo(request.RanName)
\r
56 e.logger.Errorf("#E2ResetRequestNotificationHandler.Handle - failed to retrieve nodeB entity. RanName: %s. Error: %s", request.RanName, err.Error())
\r
57 e.logger.Infof(E2ResetRequestLogInfoElapsedTime, utils.ElapsedTime(request.StartTime))
\r
61 e.logger.Debugf("#E2ResetRequestNotificationHandler.Handle - nodeB entity retrieved. RanName %s, ConnectionStatus %s", nodebInfo.RanName, nodebInfo.ConnectionStatus)
\r
63 nodebInfo.ConnectionStatus = entities.ConnectionStatus_UNDER_RESET
\r
65 err = e.rnibDataService.UpdateNodebInfoAndPublish(nodebInfo)
\r
68 e.logger.Errorf("#E2ResetRequestNotificationHandler.Handle - failed to update connection status of nodeB entity. RanName: %s. Error: %s", request.RanName, err.Error())
\r
71 e.logger.Debugf("#E2ResetRequestNotificationHandler.Handle - nodeB entity under reset state. RanName %s, ConnectionStatus %s", nodebInfo.RanName, nodebInfo.ConnectionStatus)
\r
73 e.logger.Infof(E2ResetRequestLogInfoElapsedTime, utils.ElapsedTime(request.StartTime))
\r
75 e.waitfortimertimeout(request)
\r
77 nodebInfo.ConnectionStatus = entities.ConnectionStatus_CONNECTED
\r
79 err = e.rnibDataService.UpdateNodebInfoAndPublish(nodebInfo)
\r
82 e.logger.Errorf("#E2ResetRequestNotificationHandler.Handle - failed to update connection status of nodeB entity. RanName: %s. Error: %s", request.RanName, err.Error())
\r
85 e.logger.Debugf("#E2ResetRequestNotificationHandler.Handle - nodeB entity connected state. RanName %s, ConnectionStatus %s", nodebInfo.RanName, nodebInfo.ConnectionStatus)
\r
89 func (e *E2ResetRequestNotificationHandler) getNodebInfo(ranName string) (*entities.NodebInfo, error) {
\r
91 nodebInfo, err := e.rnibDataService.GetNodeb(ranName)
\r
93 e.logger.Errorf("#E2ResetRequestNotificationHandler.Handle - failed to retrieve nodeB entity. RanName: %s. Error: %s", ranName, err.Error())
\r
96 return nodebInfo, err
\r
99 func (e *E2ResetRequestNotificationHandler) waitfortimertimeout(request *models.NotificationRequest) {
\r
100 timeout := e.config.E2ResetTimeOutSec
\r
102 timeElapsed := utils.ElapsedTime(request.StartTime)
\r
103 e.logger.Infof(E2ResetRequestLogInfoElapsedTime, utils.ElapsedTime(request.StartTime))
\r
104 if int(timeElapsed) > timeout {
\r
107 time.Sleep(time.Duration(timeout/100) * time.Millisecond)
\r