Removed Book Keeping of RMR CTL ports. Route Distribution only on demand
Change-Id: If017b52f9bd26d2bf7b13c32eb35b047595dd0ca
Signed-off-by: wahidw <abdulwahid.w@nokia.com>
diff --git a/pkg/nbi/control.go b/pkg/nbi/control.go
index 0ab3f06..e31379d 100644
--- a/pkg/nbi/control.go
+++ b/pkg/nbi/control.go
@@ -136,26 +136,26 @@
xapp.Logger.Info("Update Route Table Request, msg.String() : %s", msg.String())
xapp.Logger.Info("Update Route Table Request, params.Payload : %s", string(params.Payload))
- /*m.Lock()
+ m.Lock()
data, err := sdlEngine.ReadAll(xapp.Config.GetString("rtfile"))
m.Unlock()
if err != nil || data == nil {
xapp.Logger.Error("Cannot get data from sdl interface due to: " + err.Error())
return
- }*/
+ }
- sbiEngine.CreateEndpoint(string(params.Payload),msg.String())
- /*if ep == nil {
+ ep,whid := sbiEngine.CreateEndpoint(string(params.Payload),msg.String())
+ if ep == nil || whid < 0 {
xapp.Logger.Error("Update Routing Table Request can't handle due to end point %s is not avail in complete ep list: ", string(params.Payload))
return
}
policies := rpeEngine.GeneratePolicies(rtmgr.Eps, data)
- err = sbiEngine.DistributeToEp(policies, ep)
+ err = sbiEngine.DistributeToEp(policies, *ep, whid)
if err != nil {
xapp.Logger.Error("Routing table cannot be published due to: " + err.Error())
return
- }*/
+ }
}
func sendRoutesToAll() (err error) {
diff --git a/pkg/rtmgr/rtmgr.go b/pkg/rtmgr/rtmgr.go
index 7276bc8..de7db00 100644
--- a/pkg/rtmgr/rtmgr.go
+++ b/pkg/rtmgr/rtmgr.go
@@ -43,7 +43,6 @@
Subs SubscriptionList
PrsCfg *PlatformRoutes
Mtype MessageTypeList
- RmrEp ProcessMultipleRMR
DynamicRouteList []string
)
diff --git a/pkg/sbi/nngpush.go b/pkg/sbi/nngpush.go
index dbd5d59..1b0bed0 100644
--- a/pkg/sbi/nngpush.go
+++ b/pkg/sbi/nngpush.go
@@ -123,9 +123,6 @@
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++
@@ -192,11 +189,11 @@
return false
}
-func (c *RmrPush) CreateEndpoint(payload string,rmrsrc string)*rtmgr.Endpoint {
+func (c *RmrPush) CreateEndpoint(payload string,rmrsrc string)(ep *string,whid int) {
return c.createEndpoint(payload,rmrsrc, c)
}
-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 +201,13 @@
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
diff --git a/pkg/sbi/nngpush_test.go b/pkg/sbi/nngpush_test.go
index 3acc56b..79821eb 100644
--- a/pkg/sbi/nngpush_test.go
+++ b/pkg/sbi/nngpush_test.go
@@ -131,7 +131,7 @@
var rmrpush = RmrPush{}
resetTestPushDataset(rmrpush, stub.ValidEndpoints)
- err = rmrpush.DistributeToEp(stub.ValidPolicies,rtmgr.Eps["localhost"])
+ err = rmrpush.DistributeToEp(stub.ValidPolicies,"localhost:4561",100)
if err != nil {
t.Errorf("rmrpush.DistributetoEp(policies) was incorrect, got: %v, want: %v.", err, "nil")
}
diff --git a/pkg/sbi/sbi.go b/pkg/sbi/sbi.go
index c576c34..21ff78e 100644
--- a/pkg/sbi/sbi.go
+++ b/pkg/sbi/sbi.go
@@ -176,7 +176,7 @@
}
}
-func (s *Sbi) createEndpoint(payload string,rmrsrc string, sbi Engine) *rtmgr.Endpoint {
+func (s *Sbi) createEndpoint(payload string,rmrsrc string, sbi Engine) (*string,int) {
xapp.Logger.Debug("CreateEndPoint %v", payload)
// stringSlice := strings.Split(payload, " ")
// uuid := stringSlice[0]
@@ -206,9 +206,10 @@
xapp.Logger.Info("Wormhole Id created is %d for EndPoint %s",Whid,srcStringSlice[1])
if Whid > 0 {
- rtmgr.RmrEp[srcStringSlice[1]] = Whid
+// rtmgr.RmrEp[srcStringSlice[1]] = Whid
xapp.Logger.Info("received %s and mapped to Whid = %d",srcStringSlice[1],Whid)
+ return &srcStringSlice[1],Whid
}
- return nil
+ return nil,Whid
}
diff --git a/pkg/sbi/types.go b/pkg/sbi/types.go
index 9e6fe02..e2f14ed 100644
--- a/pkg/sbi/types.go
+++ b/pkg/sbi/types.go
@@ -45,8 +45,8 @@
AddEndpoint(*rtmgr.Endpoint) error
DeleteEndpoint(*rtmgr.Endpoint) error
UpdateEndpoints(*rtmgr.RicComponents)
- CreateEndpoint(string,string)*rtmgr.Endpoint
- DistributeToEp(*[]string, *rtmgr.Endpoint) error
+ CreateEndpoint(string,string)(*string,int)
+ DistributeToEp(*[]string, string, int ) error
}
/*type NngSocket interface {