RNIB version upgrade
Change-Id: If3c771e7c459237b92e8a3769b7a22f3edab03a7
Signed-off-by: Mohamed Abukar <abukar.mohamed@nokia.com>
diff --git a/go.mod b/go.mod
old mode 100755
new mode 100644
index 078e930..2cbbc5d
--- a/go.mod
+++ b/go.mod
@@ -5,10 +5,10 @@
require (
gerrit.o-ran-sc.org/r/com/golog v0.0.1
gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.4.2
- gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.21
- gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.21
- gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.21
- gerrit.o-ran-sc.org/r/ric-plt/sdlgo v0.3.1
+ gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.35
+ gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.35
+ gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.35
+ gerrit.o-ran-sc.org/r/ric-plt/sdlgo v0.5.0
github.com/fsnotify/fsnotify v1.4.7
github.com/go-openapi/errors v0.19.3
github.com/go-openapi/loads v0.19.4
@@ -17,7 +17,7 @@
github.com/go-openapi/strfmt v0.19.4
github.com/go-openapi/swag v0.19.7
github.com/go-openapi/validate v0.19.6
- github.com/golang/protobuf v1.3.2
+ github.com/golang/protobuf v1.3.4
github.com/gorilla/mux v1.7.1
github.com/jessevdk/go-flags v1.4.0
github.com/prometheus/client_golang v0.9.3
@@ -30,10 +30,10 @@
replace gerrit.o-ran-sc.org/r/com/golog => gerrit.o-ran-sc.org/r/com/golog.git v0.0.0-20190604083303-aaffc8ebe3f1
-replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common => gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.21
+replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common => gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.35
-replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities => gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.21
+replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities => gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.35
-replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader => gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.21
+replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader => gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.35
replace gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm => gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.4.2
diff --git a/go.sum b/go.sum
index bd298ca..2d010ed 100644
--- a/go.sum
+++ b/go.sum
@@ -9,10 +9,22 @@
gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.4.2/go.mod h1:AdEWKtERGvOQy9ybLhyhrb9w9LLVn8i9xzTwoR5n4BY=
gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.21 h1:eK9nUZOTMJ/EnMpH9bkWtMgOvCn3u4+PNCb9gu10s6w=
gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.21/go.mod h1:QJ1uPPZosGbhxUWpUpeM5fLqFHdnWTrVnvW2DgyOCes=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.25 h1:msB3b7s+KoNdzSOKZPgymoMJEpA84fSTWBDCgvbUKaE=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.25/go.mod h1:QJ1uPPZosGbhxUWpUpeM5fLqFHdnWTrVnvW2DgyOCes=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.35 h1:TGXHb4DNY8on+ej4S9VUnk2HibIC/5chDy64OE+bQBQ=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.35/go.mod h1:QJ1uPPZosGbhxUWpUpeM5fLqFHdnWTrVnvW2DgyOCes=
gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.21 h1:PQ/Mu2ol+8Oh/0BqCWWhPlVVoRCg5dQDEGm4+Opp5w4=
gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.21/go.mod h1:GXiXLz4ORBeIr0FLIbzENRykgh3Po5uPkX2jICxnRF0=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.25 h1:W9CayjJzo3r0MrgDODBg4YwIEJ/VZc4BWqfK2qWX7jg=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.25/go.mod h1:Fh23KkroYw5CRBh39WzZzxpKSkpQWL3scdzGnMngLo8=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.35 h1:tkM3yE8UzmuH4nf9TqAmiNBSuIZ2CtcMRH2eBIYIzpQ=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.35/go.mod h1:G+4sUBMbLfQ+RrGS65U15tKmbnP+/1b5oLTPmMfyfT4=
gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.21 h1:N3UbqJ9WqC8JEz/TwHHwZwCFAW6VTlZLpD5lnbdD+Y8=
gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.21/go.mod h1:SQBZLy1HP94i1vQ3y730wGFsrHqZtgPaEkzPgtqBNw0=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.25 h1:mxLhqHxp4yeo01sT3GrGVa7chaedOd7cj00Q2TK3xJM=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.25/go.mod h1:gfLVMDJ1W5uwTphc74b70SGXqBHYjo2v2ZdtroX5pFs=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.35 h1:LcxnUUDwsCzYEISKmkjkyYfg/lnLt8ofkPiGK69vNIA=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.35/go.mod h1:2bSaXTpECbZieB8bMnubTqMwF3n+mMBxlTaAXvcduNg=
gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.5.2 h1:UK7awyRKIkVdokWvvkYvazlg3EWIfMnIqCcJxTnLlDA=
gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.5.2/go.mod h1:y2WhrCvdLkAKdH+ySdHSOSehACJkTMyZghCGVcqoZzc=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
@@ -121,6 +133,8 @@
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.4 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk=
+github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
diff --git a/pkg/rnib/rNibWriter.go b/pkg/rnib/rNibWriter.go
index 74855d6..74fb557 100755
--- a/pkg/rnib/rNibWriter.go
+++ b/pkg/rnib/rNibWriter.go
@@ -21,15 +21,11 @@
"fmt"
rnibcommon "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
rnibentities "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
- "gerrit.o-ran-sc.org/r/ric-plt/sdlgo"
"github.com/golang/protobuf/proto"
)
-var writerPool *rnibcommon.Pool
-
type rNibWriterInstance struct {
- sdl *ISdlInstance
- namespace string
+ sdl rnibcommon.ISdlInstance
}
/*
@@ -40,44 +36,22 @@
}
/*
-Init initializes the infrastructure required for the RNibWriter instance
+GetRNibWriter returns reference to RNibWriter
*/
-func InitWriter(namespace string, poolSize int) {
- initWriterPool(poolSize,
- func() interface{} {
- var sdlI ISdlInstance = sdlgo.NewSdlInstance(namespace, sdlgo.NewDatabase())
- return &rNibWriterInstance{sdl: &sdlI, namespace: namespace}
- },
- func(obj interface{}) {
- (*obj.(*rNibWriterInstance).sdl).Close()
- })
-}
-/*
-InitPool initializes the writer's instances pool
-*/
-func initWriterPool(poolSize int, newObj func() interface{}, destroyObj func(interface{})) {
- writerPool = rnibcommon.NewPool(poolSize, newObj, destroyObj)
-}
-
-/*
-GetRNibWriter returns RNibWriter instance from the pool
-*/
-func GetRNibWriter() RNibWriter {
- return writerPool.Get().(RNibWriter)
+func GetRNibWriter(sdl rnibcommon.ISdlInstance) RNibWriter {
+ return &rNibWriterInstance{sdl: sdl}
}
/*
SaveNodeb saves nodeB entity data in the redis DB according to the specified data model
*/
func (w *rNibWriterInstance) SaveNodeb(nbIdentity *rnibentities.NbIdentity, entity *rnibentities.NodebInfo) error {
-
isNotEmptyIdentity := isNotEmpty(nbIdentity)
if isNotEmptyIdentity && entity.GetNodeType() == rnibentities.Node_UNKNOWN {
return rnibcommon.NewValidationError(fmt.Sprintf("#rNibWriter.saveNodeB - Unknown responding node type, entity: %v", entity))
}
- defer writerPool.Put(w)
data, err := proto.Marshal(entity)
if err != nil {
return rnibcommon.NewInternalError(err)
@@ -98,30 +72,44 @@
}
if entity.GetEnb() != nil {
- pairs, rNibErr = appendEnbCells(nbIdentity, entity.GetEnb().GetServedCells(), pairs)
+ pairs, rNibErr = appendEnbCells(nbIdentity.InventoryName, entity.GetEnb().GetServedCells(), pairs)
if rNibErr != nil {
return rNibErr
}
}
if entity.GetGnb() != nil {
- pairs, rNibErr = appendGnbCells(nbIdentity, entity.GetGnb().GetServedNrCells(), pairs)
+ pairs, rNibErr = appendGnbCells(nbIdentity.InventoryName, entity.GetGnb().GetServedNrCells(), pairs)
if rNibErr != nil {
return rNibErr
}
}
- err = (*w.sdl).Set(pairs)
+ err = w.sdl.Set(pairs)
if err != nil {
return rnibcommon.NewInternalError(err)
}
+
+ ranNameIdentity := &rnibentities.NbIdentity{InventoryName: nbIdentity.InventoryName}
+
if isNotEmptyIdentity {
- nbIdData, err := proto.Marshal(nbIdentity)
+ nbIdData, err := proto.Marshal(ranNameIdentity)
if err != nil {
return rnibcommon.NewInternalError(err)
}
- err = (*w.sdl).AddMember(entity.GetNodeType().String(), nbIdData)
+ err = w.sdl.RemoveMember(rnibentities.Node_UNKNOWN.String(), nbIdData)
if err != nil {
return rnibcommon.NewInternalError(err)
}
+ } else {
+ nbIdentity = ranNameIdentity
+ }
+
+ nbIdData, err := proto.Marshal(nbIdentity)
+ if err != nil {
+ return rnibcommon.NewInternalError(err)
+ }
+ err = w.sdl.AddMember(entity.GetNodeType().String(), nbIdData)
+ if err != nil {
+ return rnibcommon.NewInternalError(err)
}
return nil
}
@@ -130,10 +118,9 @@
Close closes writer's pool
*/
func CloseWriter() {
- writerPool.Close()
}
-func appendEnbCells(nbIdentity *rnibentities.NbIdentity, cells []*rnibentities.ServedCellInfo, pairs []interface{}) ([]interface{}, error) {
+func appendEnbCells(inventoryName string, cells []*rnibentities.ServedCellInfo, pairs []interface{}) ([]interface{}, error) {
for _, cell := range cells {
cellEntity := rnibentities.Cell{Type: rnibentities.Cell_LTE_CELL, Cell: &rnibentities.Cell_ServedCellInfo{ServedCellInfo: cell}}
cellData, err := proto.Marshal(&cellEntity)
@@ -145,7 +132,7 @@
return pairs, rNibErr
}
pairs = append(pairs, key, cellData)
- key, rNibErr = rnibcommon.ValidateAndBuildCellNamePciKey(nbIdentity.InventoryName, cell.GetPci())
+ key, rNibErr = rnibcommon.ValidateAndBuildCellNamePciKey(inventoryName, cell.GetPci())
if rNibErr != nil {
return pairs, rNibErr
}
@@ -154,7 +141,7 @@
return pairs, nil
}
-func appendGnbCells(nbIdentity *rnibentities.NbIdentity, cells []*rnibentities.ServedNRCell, pairs []interface{}) ([]interface{}, error) {
+func appendGnbCells(inventoryName string, cells []*rnibentities.ServedNRCell, pairs []interface{}) ([]interface{}, error) {
for _, cell := range cells {
cellEntity := rnibentities.Cell{Type: rnibentities.Cell_NR_CELL, Cell: &rnibentities.Cell_ServedNrCell{ServedNrCell: cell}}
cellData, err := proto.Marshal(&cellEntity)
@@ -166,7 +153,7 @@
return pairs, rNibErr
}
pairs = append(pairs, key, cellData)
- key, rNibErr = rnibcommon.ValidateAndBuildCellNamePciKey(nbIdentity.InventoryName, cell.GetServedNrCellInformation().GetNrPci())
+ key, rNibErr = rnibcommon.ValidateAndBuildCellNamePciKey(inventoryName, cell.GetServedNrCellInformation().GetNrPci())
if rNibErr != nil {
return pairs, rNibErr
}
diff --git a/pkg/xapp/db.go b/pkg/xapp/db.go
old mode 100644
new mode 100755
index 495239f..afb52b5
--- a/pkg/xapp/db.go
+++ b/pkg/xapp/db.go
@@ -66,6 +66,7 @@
type RNIBNrNeighbourInformation = rnibentities.NrNeighbourInformation
type RNIBClient struct {
+ db *sdl.SdlInstance
reader rnibreader.RNibReader
writer rnibwriter.RNibWriter
}
@@ -165,46 +166,46 @@
}
func NewRNIBClient(ns string) *RNIBClient {
- rnibreader.Init("e2Manager", 1)
- rnibwriter.InitWriter("e2Manager", 1)
+ s := sdl.NewSdlInstance("e2Manager", sdl.NewDatabase())
return &RNIBClient{
+ db: s,
reader: nil,
writer: nil,
}
}
func (r *RNIBClient) GetNodeb(invName string) (*RNIBNodebInfo, RNIBIRNibError) {
- return rnibreader.GetRNibReader().GetNodeb(invName)
+ return rnibreader.GetRNibReader(r.db).GetNodeb(invName)
}
func (r *RNIBClient) GetNodebByGlobalNbId(t RNIBNodeType, gid *RNIBGlobalNbId) (*RNIBNodebInfo, RNIBIRNibError) {
- return rnibreader.GetRNibReader().GetNodebByGlobalNbId(t, gid)
+ return rnibreader.GetRNibReader(r.db).GetNodebByGlobalNbId(t, gid)
}
func (r *RNIBClient) GetCellList(invName string) (*RNIBCells, RNIBIRNibError) {
- return rnibreader.GetRNibReader().GetCellList(invName)
+ return rnibreader.GetRNibReader(r.db).GetCellList(invName)
}
func (r *RNIBClient) GetListGnbIds() ([]*RNIBNbIdentity, RNIBIRNibError) {
- return rnibreader.GetRNibReader().GetListGnbIds()
+ return rnibreader.GetRNibReader(r.db).GetListGnbIds()
}
func (r *RNIBClient) GetListEnbIds() ([]*RNIBNbIdentity, RNIBIRNibError) {
- return rnibreader.GetRNibReader().GetListEnbIds()
+ return rnibreader.GetRNibReader(r.db).GetListEnbIds()
}
func (r *RNIBClient) GetCountGnbList() (int, RNIBIRNibError) {
- return rnibreader.GetRNibReader().GetCountGnbList()
+ return rnibreader.GetRNibReader(r.db).GetCountGnbList()
}
func (r *RNIBClient) GetCell(invName string, pci uint32) (*RNIBCell, RNIBIRNibError) {
- return rnibreader.GetRNibReader().GetCell(invName, pci)
+ return rnibreader.GetRNibReader(r.db).GetCell(invName, pci)
}
func (r *RNIBClient) GetCellById(cellType RNIBCellType, cellId string) (*RNIBCell, RNIBIRNibError) {
- return rnibreader.GetRNibReader().GetCellById(cellType, cellId)
+ return rnibreader.GetRNibReader(r.db).GetCellById(cellType, cellId)
}
func (r *RNIBClient) SaveNodeb(nbIdentity *RNIBNbIdentity, entity *RNIBNodebInfo) RNIBIRNibError {
- return rnibwriter.GetRNibWriter().SaveNodeb(nbIdentity, entity)
+ return rnibwriter.GetRNibWriter(r.db).SaveNodeb(nbIdentity, entity)
}