Loading go-apps/meep-loc-serv/go.mod +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ require ( github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-http-logger v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-loc-serv-notification-client v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-metric-store v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-model v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-redis v0.0.0 Loading go-apps/meep-loc-serv/go.sum +1 −0 Original line number Diff line number Diff line cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/InterDigitalInc/AdvantEDGE v1.4.0 h1:MnzK3dl4hUvfhZ4wYarVmJzE5IMO2Q63dyDkcQtEv1Q= github.com/KromDaniel/jonson v0.0.0-20180630143114-d2f9c3c389db/go.mod h1:RU+6d0CNIRSp6yo1mXLIIrnFa/3LHhvcDVLVJyovptM= github.com/KromDaniel/rejonson v0.0.0-20180822072824-00b5bcf2b351 h1:1u1XrfCBnY+GijnyU6O1k4odp5TnqZQTsp5v7+n/E4Y= github.com/KromDaniel/rejonson v0.0.0-20180822072824-00b5bcf2b351/go.mod h1:HxwfbuElTuGf+/uKZfjJrCnv0BmmpkPJDI7gBwj1KkM= Loading go-apps/meep-loc-serv/sbi/loc-serv-sbi.go +22 −14 Original line number Diff line number Diff line Loading @@ -19,15 +19,12 @@ package sbi import ( "strings" httpLog "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-http-logger" log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger" mod "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-model" mq "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq" ) const moduleName string = "meep-loc-serv-sbi" const redisAddr string = "meep-redis-master.default.svc.cluster.local:6379" const influxAddr string = "http://meep-influxdb.default.svc.cluster.local:8086" type LocServSbi struct { sandboxName string Loading @@ -37,14 +34,20 @@ type LocServSbi struct { updateUserInfoCB func(string, string, string) updateZoneInfoCB func(string, int, int, int) updateAccessPointInfoCB func(string, string, string, string, int) updateScenarioNameCB func(string) cleanUpCB func() } var sbi *LocServSbi // Init - Location Service SBI initialization func Init(sandboxName string, updateUserInfo func(string, string, string), updateZoneInfo func(string, int, int, int), updateAccessPointInfo func(string, string, string, string, int), cleanUp func()) (err error) { func Init(sandboxName string, redisAddr string, updateUserInfo func(string, string, string), updateZoneInfo func(string, int, int, int), updateAccessPointInfo func(string, string, string, string, int), updateScenarioName func(string), cleanUp func()) (err error) { // Create new SBI instance sbi = new(LocServSbi) Loading Loading @@ -75,6 +78,7 @@ func Init(sandboxName string, updateUserInfo func(string, string, string), updat sbi.updateUserInfoCB = updateUserInfo sbi.updateZoneInfoCB = updateZoneInfo sbi.updateAccessPointInfoCB = updateAccessPointInfo sbi.updateScenarioNameCB = updateScenarioName sbi.cleanUpCB = cleanUp // Initialize service Loading Loading @@ -128,16 +132,14 @@ func processActiveScenarioUpdate() { // Sync with active scenario store sbi.activeModel.UpdateScenario() if sbi.activeModel.GetScenarioName() == "" { return } scenarioName := sbi.activeModel.GetScenarioName() sbi.updateScenarioNameCB(scenarioName) uePerNetLocMap := make(map[string]int) uePerZoneMap := make(map[string]int) poaPerZoneMap := make(map[string]int) _ = httpLog.ReInit(moduleName, sbi.sandboxName, sbi.activeModel.GetScenarioName(), redisAddr, influxAddr) // Update UE info ueNameList := sbi.activeModel.GetNodeNames("UE") for _, name := range ueNameList { Loading @@ -159,17 +161,17 @@ func processActiveScenarioUpdate() { uePerNetLocMap[netLoc]++ } // Update POA info poaNameList := sbi.activeModel.GetNodeNames("POA") // Update POA-CELL info poaNameList := sbi.activeModel.GetNodeNames("POA-CELL") for _, name := range poaNameList { ctx := sbi.activeModel.GetNodeContext(name) if ctx == nil { log.Error("Error getting context for POA: " + name) log.Error("Error getting context for POA-CELL: " + name) continue } nodeCtx, ok := ctx.(*mod.NodeContext) if !ok { log.Error("Error casting context for POA: " + name) log.Error("Error casting context for POA-CELL: " + name) continue } zone := nodeCtx.Parents[mod.Zone] Loading @@ -187,3 +189,9 @@ func processActiveScenarioUpdate() { } } } func Stop() (err error) { sbi.mqLocal.UnregisterHandler(sbi.handlerId) return nil } go-apps/meep-loc-serv/server/loc-serv.go +41 −28 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import ( const LocServBasePath = "/location/v1/" const locServKey string = "loc-serv:" const logModuleLocServ string = "meep-loc-serv" const typeZone = "zone" const typeAccessPoint = "accessPoint" Loading Loading @@ -77,8 +78,10 @@ type ZoneStatusCheck struct { } var LOC_SERV_DB = 5 var currentStoreName = "" const redisAddr string = "meep-redis-master.default.svc.cluster.local:6379" var redisAddr string = "meep-redis-master.default.svc.cluster.local:6379" var influxAddr string = "http://meep-influxdb.default.svc.cluster.local:8086" var rc *redis.Connector var hostUrl *url.URL Loading @@ -89,8 +92,10 @@ var baseKey string // Init - Location Service initialization func Init() (err error) { // Retrieve Sandbox name from environment variable sandboxName = strings.TrimSpace(os.Getenv("MEEP_SANDBOX_NAME")) sandboxNameEnv := strings.TrimSpace(os.Getenv("MEEP_SANDBOX_NAME")) if sandboxNameEnv != "" { sandboxName = sandboxNameEnv } if sandboxName == "" { err = errors.New("MEEP_SANDBOX_NAME env variable not set") log.Error(err.Error()) Loading Loading @@ -124,7 +129,7 @@ func Init() (err error) { zoneStatusReInit() //sbi is the sole responsible of updating the userInfo, zoneInfo and apInfo structures return sbi.Init(sandboxName, updateUserInfo, updateZoneInfo, updateAccessPointInfo, cleanUp) return sbi.Init(sandboxName, redisAddr, updateUserInfo, updateZoneInfo, updateAccessPointInfo, updateStoreName, cleanUp) } // Run - Start Location Service Loading @@ -132,6 +137,11 @@ func Run() (err error) { return sbi.Run() } // Stop - Stop RNIS func Stop() (err error) { return sbi.Stop() } func createClient(notifyPath string) (*clientNotifOMA.APIClient, error) { // Create & store client for App REST API subsAppClientCfg := clientNotifOMA.NewConfiguration() Loading Loading @@ -376,20 +386,18 @@ func sendNotification(notifyUrl string, ctx context.Context, subscriptionId stri return } resp, err := client.NotificationsApi.PostTrackingNotification(ctx, subscriptionId, notification) if err != nil { log.Error(err) return } defer resp.Body.Close() jsonNotif, err := json.Marshal(notification) if err != nil { log.Error(err.Error()) } resp, err := client.NotificationsApi.PostTrackingNotification(ctx, subscriptionId, notification) _ = httpLog.LogTx(notifyUrl, "POST", string(jsonNotif), resp, startTime) if err != nil { log.Error(err) return } defer resp.Body.Close() } func sendStatusNotification(notifyUrl string, ctx context.Context, subscriptionId string, notification clientNotifOMA.ZoneStatusNotification) { Loading @@ -401,20 +409,18 @@ func sendStatusNotification(notifyUrl string, ctx context.Context, subscriptionI return } resp, err := client.NotificationsApi.PostZoneStatusNotification(ctx, subscriptionId, notification) if err != nil { log.Error(err) return } defer resp.Body.Close() jsonNotif, err := json.Marshal(notification) if err != nil { log.Error(err.Error()) } resp, err := client.NotificationsApi.PostZoneStatusNotification(ctx, subscriptionId, notification) _ = httpLog.LogTx(notifyUrl, "POST", string(jsonNotif), resp, startTime) if err != nil { log.Error(err) return } defer resp.Body.Close() } func checkNotificationRegisteredZones(oldZoneId string, newZoneId string, oldApId string, newApId string, userId string) { Loading Loading @@ -1115,9 +1121,9 @@ func zoneStatusGetById(w http.ResponseWriter, r *http.Request) { func zoneStatusPost(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") var response ResponseZoneStatusSubscription var response ResponseZoneStatusSubscription2 zoneStatusSub := new(ZoneStatusSubscription) response.ZonalTrafficSubscription = zoneStatusSub response.ZoneStatusSubscription = zoneStatusSub decoder := json.NewDecoder(r.Body) err := decoder.Decode(&zoneStatusSub) Loading Loading @@ -1233,6 +1239,13 @@ func cleanUp() { userSubscriptionMap = map[int]string{} zoneStatusSubscriptionMap = map[int]*ZoneStatusCheck{} updateStoreName("") } func updateStoreName(storeName string) { currentStoreName = storeName _ = httpLog.ReInit(logModuleLocServ, sandboxName, storeName, redisAddr, influxAddr) } func updateUserInfo(address string, zoneId string, accessPointId string) { Loading go-apps/meep-loc-serv/server/loc-serv_test.go 0 → 100644 +2249 −0 File added.Preview size limit exceeded, changes collapsed. Show changes Loading
go-apps/meep-loc-serv/go.mod +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ require ( github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-http-logger v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-loc-serv-notification-client v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-metric-store v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-model v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-redis v0.0.0 Loading
go-apps/meep-loc-serv/go.sum +1 −0 Original line number Diff line number Diff line cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/InterDigitalInc/AdvantEDGE v1.4.0 h1:MnzK3dl4hUvfhZ4wYarVmJzE5IMO2Q63dyDkcQtEv1Q= github.com/KromDaniel/jonson v0.0.0-20180630143114-d2f9c3c389db/go.mod h1:RU+6d0CNIRSp6yo1mXLIIrnFa/3LHhvcDVLVJyovptM= github.com/KromDaniel/rejonson v0.0.0-20180822072824-00b5bcf2b351 h1:1u1XrfCBnY+GijnyU6O1k4odp5TnqZQTsp5v7+n/E4Y= github.com/KromDaniel/rejonson v0.0.0-20180822072824-00b5bcf2b351/go.mod h1:HxwfbuElTuGf+/uKZfjJrCnv0BmmpkPJDI7gBwj1KkM= Loading
go-apps/meep-loc-serv/sbi/loc-serv-sbi.go +22 −14 Original line number Diff line number Diff line Loading @@ -19,15 +19,12 @@ package sbi import ( "strings" httpLog "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-http-logger" log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger" mod "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-model" mq "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq" ) const moduleName string = "meep-loc-serv-sbi" const redisAddr string = "meep-redis-master.default.svc.cluster.local:6379" const influxAddr string = "http://meep-influxdb.default.svc.cluster.local:8086" type LocServSbi struct { sandboxName string Loading @@ -37,14 +34,20 @@ type LocServSbi struct { updateUserInfoCB func(string, string, string) updateZoneInfoCB func(string, int, int, int) updateAccessPointInfoCB func(string, string, string, string, int) updateScenarioNameCB func(string) cleanUpCB func() } var sbi *LocServSbi // Init - Location Service SBI initialization func Init(sandboxName string, updateUserInfo func(string, string, string), updateZoneInfo func(string, int, int, int), updateAccessPointInfo func(string, string, string, string, int), cleanUp func()) (err error) { func Init(sandboxName string, redisAddr string, updateUserInfo func(string, string, string), updateZoneInfo func(string, int, int, int), updateAccessPointInfo func(string, string, string, string, int), updateScenarioName func(string), cleanUp func()) (err error) { // Create new SBI instance sbi = new(LocServSbi) Loading Loading @@ -75,6 +78,7 @@ func Init(sandboxName string, updateUserInfo func(string, string, string), updat sbi.updateUserInfoCB = updateUserInfo sbi.updateZoneInfoCB = updateZoneInfo sbi.updateAccessPointInfoCB = updateAccessPointInfo sbi.updateScenarioNameCB = updateScenarioName sbi.cleanUpCB = cleanUp // Initialize service Loading Loading @@ -128,16 +132,14 @@ func processActiveScenarioUpdate() { // Sync with active scenario store sbi.activeModel.UpdateScenario() if sbi.activeModel.GetScenarioName() == "" { return } scenarioName := sbi.activeModel.GetScenarioName() sbi.updateScenarioNameCB(scenarioName) uePerNetLocMap := make(map[string]int) uePerZoneMap := make(map[string]int) poaPerZoneMap := make(map[string]int) _ = httpLog.ReInit(moduleName, sbi.sandboxName, sbi.activeModel.GetScenarioName(), redisAddr, influxAddr) // Update UE info ueNameList := sbi.activeModel.GetNodeNames("UE") for _, name := range ueNameList { Loading @@ -159,17 +161,17 @@ func processActiveScenarioUpdate() { uePerNetLocMap[netLoc]++ } // Update POA info poaNameList := sbi.activeModel.GetNodeNames("POA") // Update POA-CELL info poaNameList := sbi.activeModel.GetNodeNames("POA-CELL") for _, name := range poaNameList { ctx := sbi.activeModel.GetNodeContext(name) if ctx == nil { log.Error("Error getting context for POA: " + name) log.Error("Error getting context for POA-CELL: " + name) continue } nodeCtx, ok := ctx.(*mod.NodeContext) if !ok { log.Error("Error casting context for POA: " + name) log.Error("Error casting context for POA-CELL: " + name) continue } zone := nodeCtx.Parents[mod.Zone] Loading @@ -187,3 +189,9 @@ func processActiveScenarioUpdate() { } } } func Stop() (err error) { sbi.mqLocal.UnregisterHandler(sbi.handlerId) return nil }
go-apps/meep-loc-serv/server/loc-serv.go +41 −28 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import ( const LocServBasePath = "/location/v1/" const locServKey string = "loc-serv:" const logModuleLocServ string = "meep-loc-serv" const typeZone = "zone" const typeAccessPoint = "accessPoint" Loading Loading @@ -77,8 +78,10 @@ type ZoneStatusCheck struct { } var LOC_SERV_DB = 5 var currentStoreName = "" const redisAddr string = "meep-redis-master.default.svc.cluster.local:6379" var redisAddr string = "meep-redis-master.default.svc.cluster.local:6379" var influxAddr string = "http://meep-influxdb.default.svc.cluster.local:8086" var rc *redis.Connector var hostUrl *url.URL Loading @@ -89,8 +92,10 @@ var baseKey string // Init - Location Service initialization func Init() (err error) { // Retrieve Sandbox name from environment variable sandboxName = strings.TrimSpace(os.Getenv("MEEP_SANDBOX_NAME")) sandboxNameEnv := strings.TrimSpace(os.Getenv("MEEP_SANDBOX_NAME")) if sandboxNameEnv != "" { sandboxName = sandboxNameEnv } if sandboxName == "" { err = errors.New("MEEP_SANDBOX_NAME env variable not set") log.Error(err.Error()) Loading Loading @@ -124,7 +129,7 @@ func Init() (err error) { zoneStatusReInit() //sbi is the sole responsible of updating the userInfo, zoneInfo and apInfo structures return sbi.Init(sandboxName, updateUserInfo, updateZoneInfo, updateAccessPointInfo, cleanUp) return sbi.Init(sandboxName, redisAddr, updateUserInfo, updateZoneInfo, updateAccessPointInfo, updateStoreName, cleanUp) } // Run - Start Location Service Loading @@ -132,6 +137,11 @@ func Run() (err error) { return sbi.Run() } // Stop - Stop RNIS func Stop() (err error) { return sbi.Stop() } func createClient(notifyPath string) (*clientNotifOMA.APIClient, error) { // Create & store client for App REST API subsAppClientCfg := clientNotifOMA.NewConfiguration() Loading Loading @@ -376,20 +386,18 @@ func sendNotification(notifyUrl string, ctx context.Context, subscriptionId stri return } resp, err := client.NotificationsApi.PostTrackingNotification(ctx, subscriptionId, notification) if err != nil { log.Error(err) return } defer resp.Body.Close() jsonNotif, err := json.Marshal(notification) if err != nil { log.Error(err.Error()) } resp, err := client.NotificationsApi.PostTrackingNotification(ctx, subscriptionId, notification) _ = httpLog.LogTx(notifyUrl, "POST", string(jsonNotif), resp, startTime) if err != nil { log.Error(err) return } defer resp.Body.Close() } func sendStatusNotification(notifyUrl string, ctx context.Context, subscriptionId string, notification clientNotifOMA.ZoneStatusNotification) { Loading @@ -401,20 +409,18 @@ func sendStatusNotification(notifyUrl string, ctx context.Context, subscriptionI return } resp, err := client.NotificationsApi.PostZoneStatusNotification(ctx, subscriptionId, notification) if err != nil { log.Error(err) return } defer resp.Body.Close() jsonNotif, err := json.Marshal(notification) if err != nil { log.Error(err.Error()) } resp, err := client.NotificationsApi.PostZoneStatusNotification(ctx, subscriptionId, notification) _ = httpLog.LogTx(notifyUrl, "POST", string(jsonNotif), resp, startTime) if err != nil { log.Error(err) return } defer resp.Body.Close() } func checkNotificationRegisteredZones(oldZoneId string, newZoneId string, oldApId string, newApId string, userId string) { Loading Loading @@ -1115,9 +1121,9 @@ func zoneStatusGetById(w http.ResponseWriter, r *http.Request) { func zoneStatusPost(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") var response ResponseZoneStatusSubscription var response ResponseZoneStatusSubscription2 zoneStatusSub := new(ZoneStatusSubscription) response.ZonalTrafficSubscription = zoneStatusSub response.ZoneStatusSubscription = zoneStatusSub decoder := json.NewDecoder(r.Body) err := decoder.Decode(&zoneStatusSub) Loading Loading @@ -1233,6 +1239,13 @@ func cleanUp() { userSubscriptionMap = map[int]string{} zoneStatusSubscriptionMap = map[int]*ZoneStatusCheck{} updateStoreName("") } func updateStoreName(storeName string) { currentStoreName = storeName _ = httpLog.ReInit(logModuleLocServ, sandboxName, storeName, redisAddr, influxAddr) } func updateUserInfo(address string, zoneId string, accessPointId string) { Loading
go-apps/meep-loc-serv/server/loc-serv_test.go 0 → 100644 +2249 −0 File added.Preview size limit exceeded, changes collapsed. Show changes