if readSubsFromDb == "true" {
// Read subscriptions from db
- c.ReadE2Subscriptions()
- c.ReadRESTSubscriptions()
+ err := c.ReadE2Subscriptions()
+ if err != nil {
+ xapp.Logger.Error("ReadE2Subscriptions() failed %s", err.Error())
+ }
+ err = c.ReadRESTSubscriptions()
+ if err != nil {
+ xapp.Logger.Error("ReadRESTSubscriptions() failed %s", err.Error())
+ }
}
go xapp.Subscription.Listen(c.RESTSubscriptionHandler, c.RESTQueryHandler, c.RESTSubscriptionDeleteHandler)
}
func (c *Control) SymptomDataHandler(w http.ResponseWriter, r *http.Request) {
- subscriptions, _ := c.registry.QueryHandler()
+ subscriptions, err := c.registry.QueryHandler()
+ if err != nil {
+ xapp.Logger.Error("QueryHandler() failed %s", err.Error())
+ }
+
xapp.Resource.SendSymptomDataJson(w, r, subscriptions, "platform/subscriptions.json")
}
for restSubId, restSubscription := range restSubscriptions {
restSubscription.SubReqOngoing = false
restSubscription.SubDelReqOngoing = false
- c.WriteRESTSubscriptionToSdl(restSubId, restSubscription)
+ err := c.WriteRESTSubscriptionToSdl(restSubId, restSubscription)
+ if err != nil {
+ xapp.Logger.Error("WriteRESTSubscriptionToSdl() failed:%s", err.Error())
+ }
}
c.registry.restSubscriptions = restSubscriptions
return nil
}
}
- xapp.Logger.Error("XAPP-SubReq E2 subscription failed %s", idstring(err, trans, subs))
- c.registry.RemoveFromSubscription(subs, trans, waitRouteCleanup_ms, c)
+ xapp.Logger.Error("XAPP-SubReq E2 subscription failed: %s", idstring(err, trans, subs))
+ err2 := c.registry.RemoveFromSubscription(subs, trans, waitRouteCleanup_ms, c)
+ if err2 != nil {
+ xapp.Logger.Error("RemoveFromSubscription failed: %s", err2.Error())
+ }
return nil, &errorInfo, err
}
}
c.UpdateCounter(cRestSubFailNotifToXapp)
- xapp.Subscription.Notify(resp, *clientEndpoint)
+ err = xapp.Subscription.Notify(resp, *clientEndpoint)
+ if err != nil {
+ xapp.Logger.Error("xapp.Subscription.Notify failed %s", err.Error())
+ }
// E2 is down. Delete completely processed request safely now
if c.e2IfState.IsE2ConnectionUp(&restSubscription.Meid) == false && restSubscription.SubReqOngoing == false {
xapp.Logger.Debug("Sending successful REST notification: ErrorCause:%s, ErrorSource:%s, TimeoutType:%s, to Endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s",
errorInfo.ErrorCause, errorInfo.ErrorSource, errorInfo.TimeoutType, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans))
c.UpdateCounter(cRestSubNotifToXapp)
- xapp.Subscription.Notify(resp, *clientEndpoint)
+ err := xapp.Subscription.Notify(resp, *clientEndpoint)
+ if err != nil {
+ xapp.Logger.Error("xapp.Subscription.Notify failed %s", err.Error())
+ }
// E2 is down. Delete completely processed request safely now
if c.e2IfState.IsE2ConnectionUp(&restSubscription.Meid) == false && restSubscription.SubReqOngoing == false {
xapp.Logger.Debug("XAPP-SubDelReq: Handling event %s ", idstring(nil, trans, subs))
- c.registry.RemoveFromSubscription(subs, trans, waitRouteCleanup_ms, c)
+ err = c.registry.RemoveFromSubscription(subs, trans, waitRouteCleanup_ms, c)
+ if err != nil {
+ xapp.Logger.Error("XAPP-SubDelReq %s:", idstring(fmt.Errorf("RemoveFromSubscription faliled"), trans, subs))
+ }
return xAppEventInstanceID, nil
}
if err == nil {
trans.Release()
c.UpdateCounter(cSubRespToXapp)
- c.rmrSendToXapp("", subs, trans)
+ err := c.rmrSendToXapp("", subs, trans)
+ if err != nil {
+ xapp.Logger.Error("rmrSendToXapp() failed:%s", err.Error())
+ }
return
}
case *e2ap.E2APSubscriptionFailure:
trans.Mtype, trans.Payload, err = c.e2ap.PackSubscriptionDeleteResponse(subDelRespMsg)
if err == nil {
c.UpdateCounter(cSubDelRespToXapp)
- c.rmrSendToXapp("", subs, trans)
+ err := c.rmrSendToXapp("", subs, trans)
+ if err != nil {
+ xapp.Logger.Error("rmrSendToXapp() failed:%s", err.Error())
+ }
}
}
if err != nil {
valid = false
c.sendE2TSubscriptionDeleteRequest(subs, trans, parentTrans)
+
}
// Now RemoveFromSubscription in here to avoid race conditions (mostly concerns delete)
if valid == false {
- c.registry.RemoveFromSubscription(subs, parentTrans, waitRouteCleanupTime, c)
+ err = c.registry.RemoveFromSubscription(subs, parentTrans, waitRouteCleanupTime, c)
+ if err != nil {
+ xapp.Logger.Error("RemoveFromSubscription() failed:%s", err.Error())
+ }
}
parentTrans.SendEvent(subRfMsg, 0)
} else {
c.UpdateCounter(cSubReReqToE2)
}
- c.rmrSendToE2T(desc, subs, trans)
+ err := c.rmrSendToE2T(desc, subs, trans)
+ if err != nil {
+ xapp.Logger.Error("rmrSendToE2T() failed:%s", err.Error())
+ }
+
if subs.DoNotWaitSubResp == false {
event, timedOut = trans.WaitEvent(e2SubscriptionDirectives.E2TimeoutTimerValue)
if timedOut {
} else {
c.UpdateCounter(cSubDelReReqToE2)
}
- c.rmrSendToE2T(desc, subs, trans)
+ err := c.rmrSendToE2T(desc, subs, trans)
+ if err != nil {
+ xapp.Logger.Error("SUBS-SubDelReq: rmrSendToE2T failure: %s", idstring(err, trans, subs, parentTrans))
+ }
event, timedOut = trans.WaitEvent(e2tSubDelReqTime)
if timedOut {
c.UpdateCounter(cSubDelReqTimerExpiry)
//-------------------------------------------------------------------
// handle from E2T Subscription Delete Response
//-------------------------------------------------------------------
-func (c *Control) handleE2TSubscriptionDeleteResponse(params *xapp.RMRParams) (err error) {
+func (c *Control) handleE2TSubscriptionDeleteResponse(params *xapp.RMRParams) {
xapp.Logger.Debug("MSG from E2T: %s", params.String())
c.UpdateCounter(cSubDelRespFromE2)
subDelRespMsg, err := c.e2ap.UnpackSubscriptionDeleteResponse(params.Payload)
// This can be used to remove all subscriptions db from
if s == "emptydb" {
xapp.Logger.Debug("RemoveAllSubscriptionsFromSdl() called")
- c.RemoveAllSubscriptionsFromSdl()
- c.RemoveAllRESTSubscriptionsFromSdl()
+ err := c.RemoveAllSubscriptionsFromSdl()
+ if err != nil {
+ xapp.Logger.Error("RemoveAllSubscriptionsFromSdl() RemoveAllSubscriptionsFromSdl() failure: %s", err.Error())
+ }
+ err = c.RemoveAllRESTSubscriptionsFromSdl()
+ if err != nil {
+ xapp.Logger.Error("RemoveAllRESTSubscriptionsFromSdl() RemoveAllSubscriptionsFromSdl() failure: %s", err.Error())
+ }
return
}
// Get all REST Subscriptions in subscription manager
xapp.Logger.Debug("GetAllRestSubscriptions() called")
- w.Write(c.registry.GetAllRestSubscriptionsJson())
+ _, err := w.Write(c.registry.GetAllRestSubscriptionsJson())
+ if err != nil {
+ xapp.Logger.Error("GetAllRestSubscriptions() w.Write failure: %s", err.Error())
+ }
}
func (c *Control) GetAllE2Nodes(w http.ResponseWriter, r *http.Request) {
ranName := pathParams["ranName"]
xapp.Logger.Debug("GetAllE2NodeRestSubscriptions() ranName=%s", ranName)
if ranName != "" {
- w.Write(c.registry.GetAllE2NodeRestSubscriptionsJson(ranName))
+ _, err := w.Write(c.registry.GetAllE2NodeRestSubscriptionsJson(ranName))
+ if err != nil {
+ xapp.Logger.Error("GetAllE2NodeRestSubscriptions() w.Write failure: %s", err.Error())
+ }
} else {
xapp.Logger.Debug("GetAllE2NodeRestSubscriptions() Invalid path %s", ranName)
w.WriteHeader(400) // Bad request
// Get all xApps in subscription manager
xapp.Logger.Debug("GetAllXapps() called: Req= %v", r.URL.Path)
- w.Write(c.registry.GetAllXappsJson())
+ _, err := w.Write(c.registry.GetAllXappsJson())
+ if err != nil {
+ xapp.Logger.Error("GetAllXapps() w.Write failure: %s", err.Error())
+ }
}
func (c *Control) GetAllXappRestSubscriptions(w http.ResponseWriter, r *http.Request) {
xappServiceName := pathParams["xappServiceName"]
xapp.Logger.Debug("GetAllXappRestSubscriptions() xappServiceName=%s", xappServiceName)
if xappServiceName != "" {
- w.Write(c.registry.GetAllXappRestSubscriptionsJson(xappServiceName))
+ _, err := w.Write(c.registry.GetAllXappRestSubscriptionsJson(xappServiceName))
+ if err != nil {
+ xapp.Logger.Error("GetAllXappRestSubscriptions() w.Write failure: %s", err.Error())
+ }
} else {
xapp.Logger.Debug("GetAllXappRestSubscriptions() Invalid path %s", xappServiceName)
w.WriteHeader(400) // Bad request
if err != nil {
w.WriteHeader(404) // Not found
} else {
- w.Write(e2Subscriptions)
+ _, err := w.Write(e2Subscriptions)
+ if err != nil {
+ xapp.Logger.Error("GetE2Subscriptions() w.Write failure: %s", err.Error())
+ }
}
}