Publish Route only once to the endpoint that requests it. Periodic/Event based distri...
[ric-plt/rtmgr.git] / pkg / sbi / nngpush.go
index dbd5d59..4b7f871 100644 (file)
@@ -123,9 +123,6 @@ func (c *RmrPush) DistributeAll(policies *[]string) error {
         for _, ep := range rtmgr.Eps {
                 go c.send_sync(ep,  policies, channel, rmrcallid)
         }
-       for rEp, id := range rtmgr.RmrEp {
-                go c.send_rt_process(rEp,id,policies,rmrcallid)
-        }
 
        rmrcallid++
 
@@ -180,23 +177,24 @@ func (c *RmrPush) send_data(ep *rtmgr.Endpoint, policies *[]string, call_id int)
         params.Timeout = 200
         state, retstr = xapp.Rmr.SendCallMsg(params.RMRParams)
        routestatus := strings.Split(retstr," ")
-        if state != C.RMR_OK && routestatus[0] == "OK" {
+        if state != C.RMR_OK && routestatus[0] != "OK" {
               xapp.Logger.Error("Updating Routes to Endpoint: " + ep.Uuid + " failed, call_id: " + strconv.Itoa(call_id) + " for xapp.Rmr.SendCallMsg " + " Route Update Status: " + routestatus[0])
               return false
         } else {
                xapp.Logger.Info("Update Routes to Endpoint: " + ep.Uuid + " successful, call_id: " + strconv.Itoa(call_id) + ", Payload length: " + strconv.Itoa(params.PayloadLen) + ", Route Update Status: " + routestatus[0] + "(# of Entries:" + strconv.Itoa(len(*policies)))
               return true
         }
+}
 
-        xapp.Logger.Error("Route Update to endpoint: " + ep.Uuid + " failed, call_id: " + strconv.Itoa(call_id) + " xapp.Rmr.SendCallMsg not called")
-        return false
+func (c *RmrPush) CheckEndpoint(payload string)(ep *rtmgr.Endpoint)  {
+       return c.checkEndpoint(payload)
 }
 
-func (c *RmrPush) CreateEndpoint(payload string,rmrsrc string)*rtmgr.Endpoint  {
-       return c.createEndpoint(payload,rmrsrc, c)
+func (c *RmrPush) CreateEndpoint(rmrsrc string)(ep *string,whid int)  {
+       return c.createEndpoint(rmrsrc)
 }
 
-func (c *RmrPush) DistributeToEp(policies *[]string, ep *rtmgr.Endpoint) error {
+func (c *RmrPush) DistributeToEp(policies *[]string, ep string, whid int) error {
        xapp.Logger.Debug("Invoked: sbi.DistributeToEp")
        xapp.Logger.Debug("args: %v", *policies)
 
@@ -204,13 +202,13 @@ func (c *RmrPush) DistributeToEp(policies *[]string, ep *rtmgr.Endpoint) error {
                 rmrdynamiccallid = 201
         }
 
-       go c.send_data(ep, policies,rmrdynamiccallid)
+       go c.sendDynamicRoutes(ep, whid, policies,rmrdynamiccallid)
        rmrdynamiccallid++
 
        return nil
 }
 
-func (c *RmrPush) send_rt_process(ep string,whid int, policies *[]string, call_id int) bool {
+func (c *RmrPush) sendDynamicRoutes(ep string,whid int, policies *[]string, call_id int) bool {
         xapp.Logger.Debug("Invoked send_rt_process to endpoint: " + ep + " call_id: " + strconv.Itoa(call_id) + "whid: " + strconv.Itoa(whid))
         var state int
         var retstr string
@@ -233,15 +231,12 @@ func (c *RmrPush) send_rt_process(ep string,whid int, policies *[]string, call_i
         params.Timeout = 200
         state, retstr = xapp.Rmr.SendCallMsg(params.RMRParams)
         routestatus := strings.Split(retstr," ")
-        if state != C.RMR_OK && routestatus[0] == "OK" {
+        if state != C.RMR_OK && routestatus[0] != "OK" {
                 xapp.Logger.Error("Updating Routes to Endpoint: " + ep + " failed, call_id: " + strconv.Itoa(call_id) + ",whi_id: " + strconv.Itoa(whid) + " for xapp.Rmr.SendCallMsg " + " Route Update Status: " + routestatus[0])
               return false
         } else {
-                xapp.Logger.Info("Update Routes to Endpoint: " + ep + " successful, call_id: " + strconv.Itoa(call_id) + ", Payload length: " + strconv.Itoa(params.PayloadLen) + ",whi_id: " + strconv.Itoa(whid) + ", Route Update Status: " + routestatus[0] + "(# of Entries:" + strconv.Itoa(len(*policies)))
+                xapp.Logger.Info("Update Routes to Endpoint: " + ep + " successful, call_id: " + strconv.Itoa(call_id) + ", Payload length: " + strconv.Itoa(params.PayloadLen) + ",whid: " + strconv.Itoa(whid) + ", Route Update Status: " + routestatus[0] + "(# of Entries:" + strconv.Itoa(len(*policies)))
       return true
         }
-
-        xapp.Logger.Error("Route Update to endpoint: " + ep + " failed, call_id: " + strconv.Itoa(call_id) + ",whi_id: " + strconv.Itoa(whid) + " xapp.Rmr.SendCallMsg not called")
-        return false
 }