RT records are sent in a group rather than individually. Group is configurable 75/3275/1
authorwahidw <abdulwahid.w@nokia.com>
Wed, 15 Apr 2020 10:48:50 +0000 (10:48 +0000)
committerwahidw <abdulwahid.w@nokia.com>
Wed, 15 Apr 2020 10:50:05 +0000 (10:50 +0000)
Change-Id: Icefcb9bc2566e3c2658b5db544fbdc5b1e32d4f6
Signed-off-by: wahidw <abdulwahid.w@nokia.com>
RELNOTES
container-tag.yaml
go.mod
pkg/sbi/nngpush.go

index a4726b0..65fff99 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -1,3 +1,6 @@
+### v0.5.6-2
+* RT records are sent in a group rather than individually. Group is configurabl 
+
 ### v0.5.6-1
 * Moving to ubuntu 18 and fixing UT's
 
index 92585c6..e6b8e13 100644 (file)
@@ -2,4 +2,4 @@
 # By default this file is in the docker build directory,
 # but the location can configured in the JJB template.
 ---
-tag: 0.5.6-1
+tag: 0.5.6-2
diff --git a/go.mod b/go.mod
index 7fbb010..3ddb41e 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module routing-manager
 go 1.12.1
 
 require (
-       gerrit.o-ran-sc.org/r/ric-plt/xapp-frame v0.4.6
+       gerrit.o-ran-sc.org/r/ric-plt/xapp-frame v0.4.7
        github.com/ghodss/yaml v1.0.0
        github.com/go-openapi/errors v0.19.3
        github.com/go-openapi/loads v0.19.4
@@ -18,6 +18,6 @@ require (
 
 replace gerrit.o-ran-sc.org/r/ric-plt/sdlgo => gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.5.2
 
-replace gerrit.o-ran-sc.org/r/ric-plt/xapp-frame => gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.4.6
+replace gerrit.o-ran-sc.org/r/ric-plt/xapp-frame => gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.4.7
 
 replace gerrit.o-ran-sc.org/r/com/golog => gerrit.o-ran-sc.org/r/com/golog.git v0.0.1
index 677a80c..0bb14c3 100644 (file)
@@ -35,25 +35,24 @@ import (
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
        "routing-manager/pkg/rtmgr"
        "strconv"
-       "time"
+       //"time"
        "fmt"
 )
 
 type NngPush struct {
        Sbi
-       rcChan    chan *xapp.RMRParams
+       rcChan chan *xapp.RMRParams
 }
 
 type RMRParams struct {
-        *xapp.RMRParams
+       *xapp.RMRParams
 }
 
-
 func (params *RMRParams) String() string {
-        var b bytes.Buffer
-        sum := md5.Sum(params.Payload)
-        fmt.Fprintf(&b, "params(Src=%s Mtype=%d SubId=%d Xid=%s Meid=%s Paylens=%d/%d Payhash=%x)", params.Src, params.Mtype, params.SubId, params.Xid, params.Meid.RanName, params.PayloadLen, len(params.Payload), sum)
-        return b.String()
+       var b bytes.Buffer
+       sum := md5.Sum(params.Payload)
+       fmt.Fprintf(&b, "params(Src=%s Mtype=%d SubId=%d Xid=%s Meid=%s Paylens=%d/%d Payhash=%x)", params.Src, params.Mtype, params.SubId, params.Xid, params.Meid.RanName, params.PayloadLen, len(params.Payload), sum)
+       return b.String()
 }
 
 func NewNngPush() *NngPush {
@@ -74,10 +73,10 @@ func (c *NngPush) AddEndpoint(ep *rtmgr.Endpoint) error {
        xapp.Logger.Debug("Invoked sbi.AddEndpoint")
        endpoint := ep.Ip + ":" + strconv.Itoa(DefaultNngPipelineSocketNumber)
        ep.Whid = int(xapp.Rmr.Openwh(endpoint))
-       if ep.Whid < 0   {
+       if ep.Whid < 0 {
                return errors.New("can't open warmhole connection for endpoint:" + ep.Uuid + " due to invalid Wormhole ID: " + string(ep.Whid))
-       }else {
-               xapp.Logger.Debug("Wormhole ID is %v and EP is %v",ep.Whid,endpoint)
+       } else {
+               xapp.Logger.Debug("Wormhole ID is %v and EP is %v", ep.Whid, endpoint)
        }
 
        return nil
@@ -109,20 +108,39 @@ func (c *NngPush) DistributeAll(policies *[]string) error {
 func (c *NngPush) send(ep *rtmgr.Endpoint, policies *[]string) {
        xapp.Logger.Debug("Push policy to endpoint: " + ep.Uuid)
 
+       var policy = []byte{}
+       cumulative_policy := 0
+       count := 0
+       maxrecord := xapp.Config.GetInt("maxrecord")
+       if maxrecord == 0 {
+               maxrecord = 10
+       }
+
        for _, pe := range *policies {
-               params := &RMRParams{&xapp.RMRParams{}}
-               params.Mtype = 20
-               params.PayloadLen = len([]byte(pe))
-               params.Payload =[]byte(pe)
-               params.Mbuf = nil
-               params.Whid = ep.Whid
-               time.Sleep(1 * time.Millisecond)
-               xapp.Rmr.SendMsg(params.RMRParams)
+               b := []byte(pe)
+               for j := 0; j < len(b); j++ {
+                       policy = append(policy, b[j])
+               }
+               count++
+               cumulative_policy++
+               if count == maxrecord || cumulative_policy == len(*policies) {
+                       params := &RMRParams{&xapp.RMRParams{}}
+                       params.Mtype = 20
+                       params.PayloadLen = len(policy)
+                       params.Payload = []byte(policy)
+                       params.Mbuf = nil
+                       params.Whid = ep.Whid
+                       xapp.Rmr.SendMsg(params.RMRParams)
+                       count = 0
+                       policy = nil
+                       xapp.Logger.Debug("Sent message with payload len = %d", params.PayloadLen)
+               }
        }
+
        xapp.Logger.Info("NNG PUSH to endpoint " + ep.Uuid + ": OK (# of Entries:" + strconv.Itoa(len(*policies)) + ")")
 }
 
-func (c *NngPush) CreateEndpoint(payload string) (*rtmgr.Endpoint){
+func (c *NngPush) CreateEndpoint(payload string) *rtmgr.Endpoint {
        return c.createEndpoint(payload, c)
 }
 
@@ -134,4 +152,3 @@ func (c *NngPush) DistributeToEp(policies *[]string, ep *rtmgr.Endpoint) error {
 
        return nil
 }
-