10 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
14 type EnbLoadInformationNotificationHandler struct {
15 rnibDataService services.RNibDataService
18 func NewEnbLoadInformationNotificationHandler(rnibDataService services.RNibDataService) EnbLoadInformationNotificationHandler {
19 return EnbLoadInformationNotificationHandler{
20 rnibDataService: rnibDataService,
24 func elapsed(startTime time.Time) float64 {
25 return float64(time.Since(startTime)) / float64(time.Millisecond)
28 func (src EnbLoadInformationNotificationHandler) Handle(logger *logger.Logger, request *models.NotificationRequest, messageChannel chan<- *models.NotificationResponse) {
30 pdu, err := converters.UnpackX2apPdu(logger, e2pdus.MaxAsn1CodecAllocationBufferSize, request.Len, request.Payload, e2pdus.MaxAsn1CodecMessageBufferSize)
33 logger.Errorf("#EnbLoadInformationNotificationHandler.Handle - RAN name: %s - Unpack failed. Error: %v", request.RanName, err)
37 logger.Debugf("#EnbLoadInformationNotificationHandler.Handle - RAN name: %s - Unpacked message successfully", request.RanName)
39 ranLoadInformation := &entities.RanLoadInformation{LoadTimestamp: uint64(request.StartTime.UnixNano())}
41 err = converters.ExtractAndBuildRanLoadInformation(pdu, ranLoadInformation)
44 logger.Errorf("#EnbLoadInformationNotificationHandler.Handle - RAN name: %s - Failed at ExtractAndBuildRanLoadInformation. Error: %v", request.RanName, err)
48 logger.Debugf("#EnbLoadInformationNotificationHandler.Handle - RAN name: %s - Successfully done with extracting and building RAN load information. elapsed: %f ms", request.RanName, elapsed(request.StartTime))
50 rnibErr := src.rnibDataService.SaveRanLoadInformation(request.RanName, ranLoadInformation)
53 logger.Errorf("#EnbLoadInformationNotificationHandler.Handle - RAN name: %s - Failed saving RAN load information. Error: %v", request.RanName, rnibErr)
57 logger.Infof("#EnbLoadInformationNotificationHandler.Handle - RAN name: %s - Successfully saved RAN load information to RNIB. elapsed: %f ms", request.RanName, elapsed(request.StartTime))