10 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
14 type EnbLoadInformationNotificationHandler struct {
16 rnibDataService services.RNibDataService
17 extractor converters.IEnbLoadInformationExtractor
20 func NewEnbLoadInformationNotificationHandler(logger *logger.Logger, rnibDataService services.RNibDataService, extractor converters.IEnbLoadInformationExtractor) EnbLoadInformationNotificationHandler {
21 return EnbLoadInformationNotificationHandler{
23 rnibDataService: rnibDataService,
28 func elapsed(startTime time.Time) float64 {
29 return float64(time.Since(startTime)) / float64(time.Millisecond)
32 func (h EnbLoadInformationNotificationHandler) Handle(request *models.NotificationRequest) {
34 pdu, err := converters.UnpackX2apPdu(h.logger, e2pdus.MaxAsn1CodecAllocationBufferSize, request.Len, request.Payload, e2pdus.MaxAsn1CodecMessageBufferSize)
37 h.logger.Errorf("#EnbLoadInformationNotificationHandler.Handle - RAN name: %s - Unpack failed. Error: %v", request.RanName, err)
41 h.logger.Debugf("#EnbLoadInformationNotificationHandler.Handle - RAN name: %s - Unpacked message successfully", request.RanName)
43 ranLoadInformation := &entities.RanLoadInformation{LoadTimestamp: uint64(request.StartTime.UnixNano())}
45 err = h.extractor.ExtractAndBuildRanLoadInformation(pdu, ranLoadInformation)
48 h.logger.Errorf("#EnbLoadInformationNotificationHandler.Handle - RAN name: %s - Failed at ExtractAndBuildRanLoadInformation. Error: %v", request.RanName, err)
52 h.logger.Debugf("#EnbLoadInformationNotificationHandler.Handle - RAN name: %s - Successfully done with extracting and building RAN load information. elapsed: %f ms", request.RanName, elapsed(request.StartTime))
54 rnibErr := h.rnibDataService.SaveRanLoadInformation(request.RanName, ranLoadInformation)
57 h.logger.Errorf("#EnbLoadInformationNotificationHandler.Handle - RAN name: %s - Failed saving RAN load information. Error: %v", request.RanName, rnibErr)
61 h.logger.Infof("#EnbLoadInformationNotificationHandler.Handle - RAN name: %s - Successfully saved RAN load information to RNIB. elapsed: %f ms", request.RanName, elapsed(request.StartTime))