X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fsbi%2Fnngpush.go;h=0d9634eab06c3848389507dc7e7f0ac0412a2a9c;hb=HEAD;hp=16545cb27848d0d068826890a5cf926723c3c489;hpb=0770de6e47404e68fc9cbb59263648ac54864aef;p=ric-plt%2Frtmgr.git diff --git a/pkg/sbi/nngpush.go b/pkg/sbi/nngpush.go index 16545cb..0d9634e 100644 --- a/pkg/sbi/nngpush.go +++ b/pkg/sbi/nngpush.go @@ -49,8 +49,8 @@ import ( var rmrcallid = 1 var rmrdynamiccallid = 201 var addendpointct = 1 - -var conn sync.Mutex +var count int +var Conn sync.Mutex type RmrPush struct { Sbi @@ -87,7 +87,8 @@ func (c *RmrPush) Terminate() error { } func (c *RmrPush) AddEndpoint(ep *rtmgr.Endpoint) error { - count := addendpointct + 1 + addendpointct = addendpointct + 1 + count := addendpointct xapp.Logger.Debug("Invoked sbi.AddEndpoint for %s with count = %d", ep.Ip, count) endpoint := ep.Ip + ":" + strconv.Itoa(DefaultRmrPipelineSocketNumber) ep.Whid = int(xapp.Rmr.Openwh(endpoint)) @@ -95,7 +96,7 @@ func (c *RmrPush) AddEndpoint(ep *rtmgr.Endpoint) error { time.Sleep(time.Duration(10) * time.Second) ep.Whid = int(xapp.Rmr.Openwh(endpoint)) if ep.Whid < 0 { - return errors.New("can't open warmhole connection for endpoint:" + ep.Uuid + " due to invalid Wormhole ID: " + string(ep.Whid) + " count: " + strconv.Itoa(count)) + return errors.New("cannot open wormhole connection for endpoint:" + ep.Uuid + " due to invalid Wormhole ID: " + string(ep.Whid) + " count: " + strconv.Itoa(count)) } } else { xapp.Logger.Debug("Wormhole ID is %v and EP is %v", ep.Whid, endpoint) @@ -143,7 +144,7 @@ func (c *RmrPush) DistributeAll(policies *[]string) error { if result[i].status == true { count++ } else { - xapp.Logger.Error("RMR send failed for endpoint %v", result[i].endpoint) + xapp.Logger.Error("RMR sent failed for endpoint %v", result[i].endpoint) } } @@ -159,10 +160,18 @@ func (c *RmrPush) send_sync(ep *rtmgr.Endpoint, policies *[]string, call_id int) xapp.Logger.Debug("Push policy to endpoint: " + ep.Uuid) ret := c.send_data(ep, policies, call_id) - xapp.Logger.Debug("return value is %v", ret) - conn.Lock() + for count = 0; count <= 2 && ret == false; count++ { + time.Sleep(time.Second) + ret := c.send_data(ep, policies, call_id) + if ret == true { + break + } + xapp.Logger.Error("Invoked send_data to try again due to return value : %v", ret) + } + + Conn.Lock() rtmgr.RMRConnStatus[ep.Uuid] = ret - conn.Unlock() + Conn.Unlock() // Handling per connection .. may be updating global map //channel <- EPStatus{ep.Uuid, ret}