X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fxapp%2Fxapp.go;h=72a8d321168c0463ea59c54e0542f35c17006c4c;hb=9c523a68520e552d051ca922815aa936c8611894;hp=d08e1cffc55b8ae40dedf0f7fef11199d9dce289;hpb=2fe100b35c1586dba1d7e9856fdec68091c22df0;p=ric-plt%2Fxapp-frame.git diff --git a/pkg/xapp/xapp.go b/pkg/xapp/xapp.go index d08e1cf..72a8d32 100755 --- a/pkg/xapp/xapp.go +++ b/pkg/xapp/xapp.go @@ -48,22 +48,24 @@ type ShutdownCB func() var ( // XApp is an application instance - Rmr *RMRClient - Sdl *SDLClient - SdlStorage *SDLStorage - Rnib *RNIBClient - Resource *Router - Metric *Metrics - Logger *Log - Config Configurator - Subscription *Subscriber - Alarm *AlarmClient - Util *Utils - readyCb ReadyCB - readyCbParams interface{} - shutdownCb ShutdownCB - shutdownFlag int32 - shutdownCnt int32 + Rmr *RMRClient + Sdl *SDLClient + SdlStorage *SDLStorage + Rnib *RNIBClient + Resource *Router + Metric *Metrics + Logger *Log + Config Configurator + Subscription *Subscriber + Alarm *AlarmClient + Util *Utils + readyCb ReadyCB + readyCbParams interface{} + shutdownCb ShutdownCB + shutdownFlag int32 + shutdownCnt int32 + disableAlarmClient bool + isRegistered bool ) var startTime time.Time @@ -80,13 +82,19 @@ func IsReady() bool { return Rmr != nil && Rmr.IsReady() && SdlStorage != nil && SdlStorage.IsReady() } +func IsRegistered() bool { + return isRegistered +} + func SetReadyCB(cb ReadyCB, params interface{}) { readyCb = cb readyCbParams = params } func XappReadyCb(params interface{}) { - Alarm = NewAlarmClient(viper.GetString("moId"), viper.GetString("name")) + if disableAlarmClient == false { + Alarm = NewAlarmClient(viper.GetString("moId"), viper.GetString("name")) + } if readyCb != nil { readyCb(readyCbParams) } @@ -106,6 +114,8 @@ func XappShutdownCb() { if shutdownCb != nil { shutdownCb() } + + isRegistered = false } func registerXapp() { @@ -118,6 +128,7 @@ func registerXapp() { Logger.Debug("Application='%s' is now up and ready, continue with registration ...", viper.GetString("name")) if err := doRegister(); err == nil { + isRegistered = true Logger.Info("Registration done, proceeding with startup ...") break } @@ -317,7 +328,19 @@ func GetIpAddress() (string, error) { return "", fmt.Errorf("Interface (%s) couldn't find ip", ifname) } -func RunWithParams(c MessageConsumer, sdlcheck bool) { +type RunParams struct { + SdlCheck bool + DisableAlarmClient bool +} + +func RunWithRunParams(c MessageConsumer, params RunParams) { + + if params.DisableAlarmClient { + disableAlarmClient = true + } else { + disableAlarmClient = false + } + Rmr = NewRMRClient() Rmr.SetReadyCB(XappReadyCb, nil) @@ -334,7 +357,7 @@ func RunWithParams(c MessageConsumer, sdlcheck bool) { go http.ListenAndServe(host, Resource.router) Logger.Info(fmt.Sprintf("Xapp started, listening on: %s", host)) - if sdlcheck { + if params.SdlCheck { SdlStorage.TestConnection(viper.GetString("controls.db.namespace")) } go registerXapp() @@ -342,6 +365,10 @@ func RunWithParams(c MessageConsumer, sdlcheck bool) { Rmr.Start(c) } +func RunWithParams(c MessageConsumer, sdlcheck bool) { + RunWithRunParams(c, RunParams{SdlCheck: sdlcheck, DisableAlarmClient: false}) +} + func Run(c MessageConsumer) { RunWithParams(c, true) }