From: naman.gupta Date: Thu, 9 Mar 2023 08:25:45 +0000 (+0530) Subject: Added timer & change status to connected state. X-Git-Tag: 6.0.2~14 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F95%2F10695%2F2;p=ric-plt%2Fe2mgr.git Added timer & change status to connected state. Added timer for e2 reset handling & changing status to connected state after timeout. Signed-off-by: naman.gupta Change-Id: I979adcc64ddb3b5d1a486242acc0a3295c653325 --- diff --git a/E2Manager/configuration/configuration.go b/E2Manager/configuration/configuration.go index 8582edd..56b9d1e 100644 --- a/E2Manager/configuration/configuration.go +++ b/E2Manager/configuration/configuration.go @@ -22,8 +22,9 @@ package configuration import ( "errors" "fmt" - "github.com/spf13/viper" "strconv" + + "github.com/spf13/viper" ) type RnibWriterConfig struct { @@ -53,6 +54,7 @@ type Configuration struct { KeepAliveResponseTimeoutMs int KeepAliveDelayMs int E2TInstanceDeletionTimeoutMs int + E2ResetTimeOutSec int GlobalRicId struct { RicId string Mcc string @@ -85,6 +87,8 @@ func ParseConfiguration() *Configuration { config.KeepAliveResponseTimeoutMs = viper.GetInt("keepAliveResponseTimeoutMs") config.KeepAliveDelayMs = viper.GetInt("KeepAliveDelayMs") config.E2TInstanceDeletionTimeoutMs = viper.GetInt("e2tInstanceDeletionTimeoutMs") + //E2ResetTimeOutSec : timeout expiry threshold required for handling reset and thus the time for which the nodeb is under reset connection state. + config.E2ResetTimeOutSec = viper.GetInt("e2ResetTimeOutSec") config.populateGlobalRicIdConfig(viper.Sub("globalRicId")) config.populateRnibWriterConfig(viper.Sub("rnibWriter")) return &config @@ -229,7 +233,7 @@ func validateRicId(ricId string) error { func (c *Configuration) String() string { return fmt.Sprintf("{logging.logLevel: %s, http.port: %d, rmr: { port: %d, maxMsgSize: %d}, routingManager.baseUrl: %s, "+ "notificationResponseBuffer: %d, bigRedButtonTimeoutSec: %d, maxRnibConnectionAttempts: %d, "+ - "rnibRetryIntervalMs: %d, keepAliveResponseTimeoutMs: %d, keepAliveDelayMs: %d, e2tInstanceDeletionTimeoutMs: %d, "+ + "rnibRetryIntervalMs: %d, keepAliveResponseTimeoutMs: %d, keepAliveDelayMs: %d, e2tInstanceDeletionTimeoutMs: %d,e2ResetTimeOutSec: %d,"+ "globalRicId: { ricId: %s, mcc: %s, mnc: %s}, rnibWriter: { stateChangeMessageChannel: %s, ranManipulationChannel: %s}", c.Logging.LogLevel, c.Http.Port, @@ -243,6 +247,7 @@ func (c *Configuration) String() string { c.KeepAliveResponseTimeoutMs, c.KeepAliveDelayMs, c.E2TInstanceDeletionTimeoutMs, + c.E2ResetTimeOutSec, c.GlobalRicId.RicId, c.GlobalRicId.Mcc, c.GlobalRicId.Mnc, diff --git a/E2Manager/configuration/configuration_test.go b/E2Manager/configuration/configuration_test.go index 01a0a83..d7d5970 100644 --- a/E2Manager/configuration/configuration_test.go +++ b/E2Manager/configuration/configuration_test.go @@ -20,11 +20,12 @@ package configuration import ( - "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v2" "io/ioutil" "os" "testing" + + "github.com/stretchr/testify/assert" + "gopkg.in/yaml.v2" ) func TestParseConfigurationSuccess(t *testing.T) { @@ -38,6 +39,7 @@ func TestParseConfigurationSuccess(t *testing.T) { assert.Equal(t, 4500, config.KeepAliveResponseTimeoutMs) assert.Equal(t, 1500, config.KeepAliveDelayMs) assert.Equal(t, 15000, config.E2TInstanceDeletionTimeoutMs) + assert.Equal(t, 10, config.E2ResetTimeOutSec) assert.NotNil(t, config.GlobalRicId) assert.Equal(t, "AACCE", config.GlobalRicId.RicId) assert.Equal(t, "310", config.GlobalRicId.Mcc) @@ -239,7 +241,7 @@ func TestRnibWriterConfigNotFoundFailure(t *testing.T) { "logging": map[string]interface{}{"logLevel": "info"}, "http": map[string]interface{}{"port": 3800}, "routingManager": map[string]interface{}{"baseUrl": "http://localhost:8080/ric/v1/handles/"}, - "globalRicId": map[string]interface{}{"mcc": 327, "mnc": 94, "ricId": "AACCE"}, + "globalRicId": map[string]interface{}{"mcc": 327, "mnc": 94, "ricId": "AACCE"}, } buf, err := yaml.Marshal(yamlMap) if err != nil { diff --git a/E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler.go b/E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler.go index a800fef..76a0b1a 100644 --- a/E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler.go +++ b/E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler.go @@ -19,10 +19,13 @@ package rmrmsghandlers import ( + "e2mgr/configuration" "e2mgr/logger" "e2mgr/models" "e2mgr/services" "e2mgr/utils" + "time" + "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities" ) @@ -31,12 +34,14 @@ const E2ResetRequestLogInfoElapsedTime = "#E2ResetRequestNotificationHandler.Han type E2ResetRequestNotificationHandler struct { logger *logger.Logger rnibDataService services.RNibDataService + config *configuration.Configuration } -func NewE2ResetRequestNotificationHandler(logger *logger.Logger, rnibDataService services.RNibDataService) *E2ResetRequestNotificationHandler { +func NewE2ResetRequestNotificationHandler(logger *logger.Logger, rnibDataService services.RNibDataService, config *configuration.Configuration) *E2ResetRequestNotificationHandler { return &E2ResetRequestNotificationHandler{ logger: logger, rnibDataService: rnibDataService, + config: config, } } @@ -66,6 +71,19 @@ func (e *E2ResetRequestNotificationHandler) Handle(request *models.NotificationR e.logger.Debugf("#E2ResetRequestNotificationHandler.Handle - nodeB entity under reset state. RanName %s, ConnectionStatus %s", nodebInfo.RanName, nodebInfo.ConnectionStatus) e.logger.Infof(E2ResetRequestLogInfoElapsedTime, utils.ElapsedTime(request.StartTime)) + + e.waitfortimertimeout(request) + + nodebInfo.ConnectionStatus = entities.ConnectionStatus_CONNECTED + + err = e.rnibDataService.UpdateNodebInfoAndPublish(nodebInfo) + + if err != nil { + e.logger.Errorf("#E2ResetRequestNotificationHandler.Handle - failed to update connection status of nodeB entity. RanName: %s. Error: %s", request.RanName, err.Error()) + } + + e.logger.Debugf("#E2ResetRequestNotificationHandler.Handle - nodeB entity connected state. RanName %s, ConnectionStatus %s", nodebInfo.RanName, nodebInfo.ConnectionStatus) + } func (e *E2ResetRequestNotificationHandler) getNodebInfo(ranName string) (*entities.NodebInfo, error) { @@ -77,3 +95,15 @@ func (e *E2ResetRequestNotificationHandler) getNodebInfo(ranName string) (*entit } return nodebInfo, err } + +func (e *E2ResetRequestNotificationHandler) waitfortimertimeout(request *models.NotificationRequest) { + timeout := e.config.E2ResetTimeOutSec + for { + timeElapsed := utils.ElapsedTime(request.StartTime) + e.logger.Infof(E2ResetRequestLogInfoElapsedTime, utils.ElapsedTime(request.StartTime)) + if int(timeElapsed) > timeout { + break + } + time.Sleep(time.Duration(timeout/100) * time.Millisecond) + } +} diff --git a/E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler_test.go b/E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler_test.go index 8b15865..c5d8747 100644 --- a/E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler_test.go +++ b/E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler_test.go @@ -25,9 +25,10 @@ import ( "e2mgr/services" "e2mgr/tests" "e2mgr/utils" + "testing" + "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities" "github.com/stretchr/testify/mock" - "testing" ) const ( @@ -45,7 +46,7 @@ func initE2ResetMocks(t *testing.T) (*E2ResetRequestNotificationHandler, *mocks. readerMock := &mocks.RnibReaderMock{} writerMock := &mocks.RnibWriterMock{} rnibDataService := services.NewRnibDataService(logger, config, readerMock, writerMock) - handler := NewE2ResetRequestNotificationHandler(logger, rnibDataService) + handler := NewE2ResetRequestNotificationHandler(logger, rnibDataService, config) return handler, readerMock, writerMock } diff --git a/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go b/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go index 82db437..3d13a30 100644 --- a/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go +++ b/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go @@ -95,7 +95,7 @@ func (provider *NotificationHandlerProvider) Init(logger *logger.Logger, config e2SetupRequestNotificationHandler := rmrmsghandlers.NewE2SetupRequestNotificationHandler(logger, config, e2tInstancesManager, rmrSender, rnibDataService, e2tAssociationManager, ranConnectStatusChangeManager, ranListManager) ricServiceUpdateHandler := rmrmsghandlers.NewRicServiceUpdateHandler(logger, rmrSender, rnibDataService, ranListManager) ricE2nodeConfigUpdateHandler := rmrmsghandlers.NewE2nodeConfigUpdateNotificationHandler(logger, rnibDataService, rmrSender) - e2ResetRequestNotificationHandler := rmrmsghandlers.NewE2ResetRequestNotificationHandler(logger, rnibDataService) + e2ResetRequestNotificationHandler := rmrmsghandlers.NewE2ResetRequestNotificationHandler(logger, rnibDataService, config) provider.Register(rmrCgo.RIC_X2_SETUP_RESP, x2SetupResponseHandler) provider.Register(rmrCgo.RIC_X2_SETUP_FAILURE, x2SetupFailureResponseHandler) diff --git a/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider_test.go b/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider_test.go index 2e3d364..9d6d1ad 100644 --- a/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider_test.go +++ b/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider_test.go @@ -99,6 +99,7 @@ func TestGetNotificationHandlerSuccess(t *testing.T) { {rmrCgo.RIC_X2_RESET, rmrmsghandlers.NewX2ResetRequestNotificationHandler(logger, rnibDataService, ranStatusChangeManager, rmrSender)}, {rmrCgo.RIC_SERVICE_UPDATE, rmrmsghandlers.NewRicServiceUpdateHandler(logger, rmrSender, rnibDataService, ranListManager)}, {rmrCgo.RIC_E2NODE_CONFIG_UPDATE, rmrmsghandlers.NewE2nodeConfigUpdateNotificationHandler(logger, rnibDataService, rmrSender)}, + {rmrCgo.RIC_E2_RESET_REQ, rmrmsghandlers.NewE2ResetRequestNotificationHandler(logger, rnibDataService, config)}, } for _, tc := range testCases { diff --git a/E2Manager/resources/configuration.yaml b/E2Manager/resources/configuration.yaml index 468b6d2..e4bb14c 100644 --- a/E2Manager/resources/configuration.yaml +++ b/E2Manager/resources/configuration.yaml @@ -14,6 +14,7 @@ rnibRetryIntervalMs: 10 keepAliveResponseTimeoutMs: 4500 keepAliveDelayMs: 1500 e2tInstanceDeletionTimeoutMs: 15000 +e2ResetTimeOutSec: 10 globalRicId: ricId: "AACCE" mcc: "310"