X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=E2Manager%2Fservices%2Frnib_data_service.go;h=38b47239554ff532a5a5990e120c355c56c96ee7;hb=c1bbdeaddf6d0d79b66fb55b346c6c6eb717e3d6;hp=8a9189492bf4867c39b3589cee0e6cb99e480172;hpb=e3623cf1310f8c8d2fd9b5842102516b9be3b441;p=ric-plt%2Fe2mgr.git diff --git a/E2Manager/services/rnib_data_service.go b/E2Manager/services/rnib_data_service.go index 8a91894..38b4723 100644 --- a/E2Manager/services/rnib_data_service.go +++ b/E2Manager/services/rnib_data_service.go @@ -1,12 +1,32 @@ +// +// Copyright 2019 AT&T Intellectual Property +// Copyright 2019 Nokia +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This source code is part of the near-RT RIC (RAN Intelligent Controller) +// platform project (RICP). + + package services import ( "e2mgr/configuration" "e2mgr/logger" "e2mgr/rNibWriter" - "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common" "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities" "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader" + "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common" "net" "time" ) @@ -17,6 +37,7 @@ type RNibDataService interface { SaveRanLoadInformation(inventoryName string, ranLoadInformation *entities.RanLoadInformation) error GetNodeb(ranName string) (*entities.NodebInfo, error) GetListNodebIds() ([]*entities.NbIdentity, error) + PingRnib() bool } type rNibDataService struct { @@ -71,7 +92,7 @@ func (w *rNibDataService) SaveRanLoadInformation(inventoryName string, ranLoadIn } func (w *rNibDataService) GetNodeb(ranName string) (*entities.NodebInfo, error) { - w.logger.Infof("#RnibDataService.GetNodeb - ranName: %s", ranName) + w.logger.Infof("#RnibDataService.GetNodeb - RAN name: %s", ranName) var nodeb *entities.NodebInfo = nil @@ -96,6 +117,15 @@ func (w *rNibDataService) GetListNodebIds() ([]*entities.NbIdentity, error) { return nodeIds, err } +func (w *rNibDataService) PingRnib() bool { + err := w.retry("GetListNodebIds", func() (err error) { + _, err = w.rnibReaderProvider().GetListNodebIds() + return + }) + + return !isRnibConnectionError(err) +} + func (w *rNibDataService) retry(rnibFunc string, f func() error) (err error) { attempts := w.maxAttempts @@ -104,7 +134,7 @@ func (w *rNibDataService) retry(rnibFunc string, f func() error) (err error) { if err == nil { return } - if !w.isConnError(err) { + if !isRnibConnectionError(err) { return err } if i >= attempts { @@ -117,8 +147,9 @@ func (w *rNibDataService) retry(rnibFunc string, f func() error) (err error) { } } -func (w *rNibDataService) isConnError(err error) bool { - internalErr, ok := err.(common.InternalError) + +func isRnibConnectionError(err error) bool { + internalErr, ok := err.(*common.InternalError) if !ok { return false }