+ err := h.rNibDataService.UpdateNodebInfoAndPublish(nodebInfo)
+
+ if err != nil {
+ h.logger.Errorf("#E2SetupRequestNotificationHandler.handleUpdateAndPublishNodebInfo - RAN name: %s - Failed at UpdateNodebInfoAndPublish. error: %s", nodebInfo.RanName, err)
+ return err
+ }
+
+ h.logger.Infof("#E2SetupRequestNotificationHandler.handleUpdateAndPublishNodebInfo - RAN name: %s - Successfully executed UpdateNodebInfoAndPublish", nodebInfo.RanName)
+ return nil
+
+}
+
+func (h *E2SetupRequestNotificationHandler) handleNewRan(ranName string, e2tIpAddress string, setupRequest *models.E2SetupRequestMessage) (*entities.NodebInfo, error) {
+
+ nodebInfo, err := h.buildNodebInfo(ranName, e2tIpAddress, setupRequest)
+ if err != nil {
+ h.logger.Errorf("#E2SetupRequestNotificationHandler.handleNewRan - RAN name: %s - failed building nodebInfo. Error: %s", ranName, err)
+ return nil, err
+ }
+
+ err = h.rNibDataService.SaveNodeb(nodebInfo)
+ if err != nil {
+ h.logger.Errorf("#E2SetupRequestNotificationHandler.handleNewRan - RAN name: %s - failed saving nodebInfo. Error: %s", ranName, err)
+ return nil, err
+ }
+
+ nbIdentity := h.buildNbIdentity(ranName, setupRequest)
+
+ err = h.ranListManager.AddNbIdentity(nodebInfo.GetNodeType(), nbIdentity)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return nodebInfo, nil
+}
+
+func (h *E2SetupRequestNotificationHandler) handleExistingRan(ranName string, nodebInfo *entities.NodebInfo, setupRequest *models.E2SetupRequestMessage) (bool, error) {
+ if nodebInfo.GetConnectionStatus() == entities.ConnectionStatus_DISCONNECTED {
+ delta_in_nano := uint64(time.Now().UnixNano()) - nodebInfo.StatusUpdateTimeStamp
+ //The duration from last Disconnection for which a new request is to be rejected (currently 10 sec)
+ if delta_in_nano < cleanUpDurationNanoSec {
+ h.logger.Errorf("#E2SetupRequestNotificationHandler.Handle - RAN name: %s, connection status: %s - nodeB entity disconnection in progress", ranName, nodebInfo.ConnectionStatus)
+ return false, errors.New("nodeB entity disconnection in progress")
+ }
+ h.logger.Infof("#E2SetupRequestNotificationHandler.Handle - RAN name: %s, connection status: %s - nodeB entity in disconnected state", ranName, nodebInfo.ConnectionStatus)
+ } else if nodebInfo.GetConnectionStatus() == entities.ConnectionStatus_SHUTTING_DOWN {
+ h.logger.Errorf("#E2SetupRequestNotificationHandler.Handle - RAN name: %s, connection status: %s - nodeB entity in incorrect state", ranName, nodebInfo.ConnectionStatus)
+ return false, errors.New("nodeB entity in incorrect state")
+ }
+
+ nodebInfo.SetupFromNetwork = true
+
+ e2NodeConfig := setupRequest.ExtractE2NodeConfigList()
+ if e2NodeConfig == nil {
+ return false, errors.New("Empty E2nodeComponentConfigAddition-List")
+ }
+
+ if nodebInfo.NodeType == entities.Node_ENB {
+ if len(e2NodeConfig) == 0 && len(nodebInfo.GetEnb().GetNodeConfigs()) == 0 {
+ return false, errors.New("Empty E2nodeComponentConfigAddition-List")
+ }
+ nodebInfo.GetEnb().NodeConfigs = e2NodeConfig
+
+ return false, nil
+ }
+
+ if len(e2NodeConfig) == 0 && len(nodebInfo.GetGnb().GetNodeConfigs()) == 0 {
+ return false, errors.New("Empty E2nodeComponentConfigAddition-List")
+ }
+ nodebInfo.GetGnb().NodeConfigs = e2NodeConfig
+
+ setupMessageRanFuncs := setupRequest.ExtractRanFunctionsList()
+
+ if setupMessageRanFuncs == nil || (len(setupMessageRanFuncs) == 0 && len(nodebInfo.GetGnb().RanFunctions) == 0) {
+ return false, nil