2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
23 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
30 type EndcX2SetupFailureResponseNotificationHandler struct{}
32 func (src EndcX2SetupFailureResponseNotificationHandler) Handle(logger *logger.Logger, e2Sessions sessions.E2Sessions,
33 request *models.NotificationRequest, messageChannel chan<- *models.NotificationResponse) {
35 e2session, ok := e2Sessions[request.TransactionId]
37 failureResponse, err := unpackEndcX2SetupFailureResponseAndExtract(logger, MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, request.Len, request.Payload, MaxAsn1CodecMessageBufferSize /*message buffer*/)
39 logger.Errorf("#endc_x2Setup_failure_response_notification_handler.Handle - unpack failed. Error: %v", err)
42 printHandlingSetupResponseElapsedTimeInMs(logger, fmt.Sprintf("#endc_x2Setup_failure_response_notification_handler.handle - transactionId %s: Summary: Elapsed time for receiving and handling setup response from E2 terminator", request.TransactionId), request.StartTime)
44 if failureResponse != nil {
45 nb := &entities.NodebInfo{}
46 nbIdentity := &entities.NbIdentity{}
48 nb.ConnectionStatus = entities.ConnectionStatus_CONNECTED_SETUP_FAILED
49 nb.Ip = e2session.Request.RanIp
50 nb.Port = uint32(e2session.Request.RanPort)
51 nb.SetupFailure = failureResponse
52 nb.FailureType = entities.Failure_ENDC_X2_SETUP_FAILURE
53 nbIdentity.InventoryName = e2session.Request.RanName
55 //insert/update database
56 if rNibErr := rNibWriter.GetRNibWriter().SaveNodeb(nbIdentity, nb); rNibErr != nil {
57 logger.Errorf("#endc_x2Setup_failure_response_notification_handler.Handle - transactionId %s: rNibWriter failed to save failure response data. Error: %s", request.TransactionId, rNibErr.Error())
59 logger.Infof("#endc_x2Setup_failure_response_notification_handler.Handle - transactionId %s: saved to rNib", request.TransactionId)
60 if logger.DebugEnabled() {
61 logger.Debugf("#endc_x2Setup_failure_response_notification_handler.Handle - transactionId %s: saved to rNib , value:[%s]", request.TransactionId, fmt.Sprintf("%s %s", nb.ConnectionStatus, failureResponse))
65 printHandlingSetupResponseElapsedTimeInMs(logger, fmt.Sprintf("#endc_x2Setup_failure_response_notification_handler.handle - transactionId %s: Summary: Total roundtrip elapsed time", request.TransactionId), e2session.SessionStart)
66 delete(e2Sessions, request.TransactionId) // Avoid pinning memory (help GC)