X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fxapp%2Fdb.go;h=6591e04699c98f2c7cafb50933b6a7bf3193f687;hb=f22b458846a20a4a9fcafb49e3195ab44a16840e;hp=b6ad9fce69646ad04b77d2bbe3c0452206295034;hpb=ad2e640256c82ebb4701566d1dd5aa6999fb31ce;p=ric-plt%2Fxapp-frame.git diff --git a/pkg/xapp/db.go b/pkg/xapp/db.go index b6ad9fc..6591e04 100755 --- a/pkg/xapp/db.go +++ b/pkg/xapp/db.go @@ -20,13 +20,9 @@ package xapp import ( - 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" rnibreader "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader" sdl "gerrit.o-ran-sc.org/r/ric-plt/sdlgo" - uenibprotobuf "gerrit.o-ran-sc.org/r/ric-plt/ue-nib/uenibprotobuf" - uenibreader "gerrit.o-ran-sc.org/r/ric-plt/ue-nib/uenibreader" - uenibwriter "gerrit.o-ran-sc.org/r/ric-plt/ue-nib/uenibwriter" rnibwriter "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/rnib" "sync" "time" @@ -47,24 +43,11 @@ type SDLClient struct { ready bool } -// Alias -type EventCategory = uenibreader.EventCategory -type EventCallback = uenibreader.EventCallback -type MeasResultNR = uenibprotobuf.MeasResultNR -type MeasQuantityResults = uenibprotobuf.MeasResultNR_MeasQuantityResults -type MeasResultServMO = uenibprotobuf.MeasResults_MeasResultServMO -type MeasResults = uenibprotobuf.MeasResults - -type UENIBClient struct { - reader *uenibreader.Reader - writer *uenibwriter.Writer -} - // Alias type RNIBNodeType = rnibentities.Node_Type type RNIBGlobalNbId = rnibentities.GlobalNbId type RNIBNodebInfo = rnibentities.NodebInfo -type RNIBIRNibError = rnibcommon.IRNibError +type RNIBIRNibError = error type RNIBCells = rnibentities.Cells type RNIBNbIdentity = rnibentities.NbIdentity type RNIBCellType = rnibentities.Cell_Type @@ -83,6 +66,7 @@ type RNIBServedNRCellInformation = rnibentities.ServedNRCellInformation type RNIBNrNeighbourInformation = rnibentities.NrNeighbourInformation type RNIBClient struct { + db *sdl.SdlInstance reader rnibreader.RNibReader writer rnibwriter.RNibWriter } @@ -181,74 +165,55 @@ func (c *SDLClient) GetStat() (t SDLStatistics) { return } -func NewUENIBClient() *UENIBClient { - return &UENIBClient{ - reader: uenibreader.NewReader(), - writer: uenibwriter.NewWriter(), - } -} - -func (u *UENIBClient) StoreUeMeasurement(gNbId string, gNbUeX2ApId string, data *uenibprotobuf.MeasResults) error { - return u.writer.UpdateUeMeasurement(gNbId, gNbUeX2ApId, data) -} - -func (u *UENIBClient) CreateUeContext(gNbId string, gNbUeX2ApId string) error { - return u.writer.UeContextAddComplete(gNbId, gNbUeX2ApId) -} - -func (u *UENIBClient) ReleaseUeContext(gNbId string, gNbUeX2ApId string) error { - return u.writer.RemoveUeContext(gNbId, gNbUeX2ApId) -} - -func (u *UENIBClient) ReadUeMeasurement(gNbId string, gNbUeX2ApId string) (*uenibprotobuf.MeasResults, error) { - return u.reader.GetUeMeasurement(gNbId, gNbUeX2ApId) -} - -func (u *UENIBClient) SubscribeEvents(gNbIDs []string, eventCategories []EventCategory, cb EventCallback) error { - return u.reader.SubscribeEvents(gNbIDs, eventCategories, cb) -} - 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) Subscribe(cb func(string, ...string), channel string) error { + return r.db.SubscribeChannel(cb, channel) +} + +func (r *RNIBClient) StoreAndPublish(channel string, event string, pairs ...interface{}) error { + return r.db.SetAndPublish([]string{channel, event}, pairs...) +} + 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() +func (r *RNIBClient) GetListGnbIds() ([]*RNIBNbIdentity, RNIBIRNibError) { + return rnibreader.GetRNibReader(r.db).GetListGnbIds() } -func (r *RNIBClient) GetListEnbIds() (*[]*RNIBNbIdentity, RNIBIRNibError) { - return rnibreader.GetRNibReader().GetListEnbIds() +func (r *RNIBClient) GetListEnbIds() ([]*RNIBNbIdentity, RNIBIRNibError) { + 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) }