Loading go-apps/meep-tm/server/bwm/bwm.go +74 −17 Original line number Diff line number Diff line Loading @@ -75,9 +75,16 @@ type BwAllocInfoResp struct { AppName []string BwInfoList []BwInfo } type SessionFilterPostResp struct { SessionFilterList []BwInfoSessionFilter SessionMatch bool } type SessionFilterResp struct { SessionFilterList []BwInfoSessionFilter SessionMatch bool AllocationId string AllocationIdMatch bool } var localityEnabled bool Loading Loading @@ -965,31 +972,26 @@ func bandwidthAllocationPost(w http.ResponseWriter, r *http.Request) { if *bwInfo.RequestType == 1 { response := &SessionFilterResp{ response := &SessionFilterPostResp{ SessionMatch: false, SessionFilterList: make([]BwInfoSessionFilter, len(bwInfo.SessionFilter)), } // for _, sessionFilterValue := range bwInfo.SessionFilter { // response.SessionFilterList = append(response.SessionFilterList, sessionFilterValue) // } response.SessionFilterList = bwInfo.SessionFilter // Get all Bandwidth Allocation Info from DB keyMatchStr := baseKey + "bw_alloc:*" err = rc.ForEachJSONEntry(keyMatchStr, populateSessionFilter, response) err = rc.ForEachJSONEntry(keyMatchStr, populateSessionFilterPost, response) if err != nil { log.Error("Unable to fetch allocation buffer from redis") errHandlerProblemDetails(w, "Unable to fetch allocation buffer from redis", http.StatusInternalServerError) log.Error("Unable to fetch allocation resource from redis") errHandlerProblemDetails(w, "Unable to fetch allocation resource from redis", http.StatusInternalServerError) return } else { } if response.SessionMatch { log.Error("multiple sessions match sessionFilter") errHandlerProblemDetails(w, "multiple sessions match sessionFilter", http.StatusBadRequest) return } } switch bwInfo.AllocationDirection { Loading Loading @@ -1348,8 +1350,8 @@ func bandwidthAllocationPut(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, string(jsonResponse)) } func populateSessionFilter(key string, jsonInfo string, response interface{}) error { resp := response.(*SessionFilterResp) func populateSessionFilterPost(key string, jsonInfo string, response interface{}) error { resp := response.(*SessionFilterPostResp) if resp == nil { return errors.New("Response not defined") } Loading @@ -1367,9 +1369,33 @@ func populateSessionFilter(key string, jsonInfo string, response interface{}) er } } } } return nil } func populateSessionFilter(key string, jsonInfo string, response interface{}) error { resp := response.(*SessionFilterResp) if resp == nil { return errors.New("Response not defined") } var bwInfo BwInfo err := json.Unmarshal([]byte(jsonInfo), &bwInfo) if err != nil { return err } if len(bwInfo.SessionFilter) > 0 { for _, singleSessionInput := range resp.SessionFilterList { for _, singleSessionStored := range bwInfo.SessionFilter { if reflect.DeepEqual(singleSessionInput, singleSessionStored) { resp.SessionMatch = true if resp.AllocationId == bwInfo.AllocationId { resp.AllocationIdMatch = true } } } } } return nil } Loading Loading @@ -1697,6 +1723,37 @@ func validateUpdateRequestType(bwInfoInput *BwInfo, bwInfoStored *BwInfo, w http // validate the requested changes within session specific allocation } else { log.Info("Request type is now change to session specific allocation") response := &SessionFilterResp{ SessionMatch: false, SessionFilterList: make([]BwInfoSessionFilter, len(bwInfoInput.SessionFilter)), AllocationId: "", AllocationIdMatch: false, } response.SessionFilterList = bwInfoInput.SessionFilter response.AllocationId = bwInfoInput.AllocationId // Get all Bandwidth Allocation Info from DB keyMatchStr := baseKey + "bw_alloc:*" err := rc.ForEachJSONEntry(keyMatchStr, populateSessionFilter, response) if err != nil { log.Error("Unable to fetch allocation resource from redis") errHandlerProblemDetails(w, "Unable to fetch allocation resource from redis", http.StatusInternalServerError) return err } if response.SessionMatch { if response.AllocationIdMatch { log.Info("Same sessionFilter requested to update") return nil } else { log.Error("multiple sessions match sessionFilter") errHandlerProblemDetails(w, "multiple sessions match sessionFilter", http.StatusBadRequest) return err } } switch bwInfoInput.AllocationDirection { //downlink Loading Loading
go-apps/meep-tm/server/bwm/bwm.go +74 −17 Original line number Diff line number Diff line Loading @@ -75,9 +75,16 @@ type BwAllocInfoResp struct { AppName []string BwInfoList []BwInfo } type SessionFilterPostResp struct { SessionFilterList []BwInfoSessionFilter SessionMatch bool } type SessionFilterResp struct { SessionFilterList []BwInfoSessionFilter SessionMatch bool AllocationId string AllocationIdMatch bool } var localityEnabled bool Loading Loading @@ -965,31 +972,26 @@ func bandwidthAllocationPost(w http.ResponseWriter, r *http.Request) { if *bwInfo.RequestType == 1 { response := &SessionFilterResp{ response := &SessionFilterPostResp{ SessionMatch: false, SessionFilterList: make([]BwInfoSessionFilter, len(bwInfo.SessionFilter)), } // for _, sessionFilterValue := range bwInfo.SessionFilter { // response.SessionFilterList = append(response.SessionFilterList, sessionFilterValue) // } response.SessionFilterList = bwInfo.SessionFilter // Get all Bandwidth Allocation Info from DB keyMatchStr := baseKey + "bw_alloc:*" err = rc.ForEachJSONEntry(keyMatchStr, populateSessionFilter, response) err = rc.ForEachJSONEntry(keyMatchStr, populateSessionFilterPost, response) if err != nil { log.Error("Unable to fetch allocation buffer from redis") errHandlerProblemDetails(w, "Unable to fetch allocation buffer from redis", http.StatusInternalServerError) log.Error("Unable to fetch allocation resource from redis") errHandlerProblemDetails(w, "Unable to fetch allocation resource from redis", http.StatusInternalServerError) return } else { } if response.SessionMatch { log.Error("multiple sessions match sessionFilter") errHandlerProblemDetails(w, "multiple sessions match sessionFilter", http.StatusBadRequest) return } } switch bwInfo.AllocationDirection { Loading Loading @@ -1348,8 +1350,8 @@ func bandwidthAllocationPut(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, string(jsonResponse)) } func populateSessionFilter(key string, jsonInfo string, response interface{}) error { resp := response.(*SessionFilterResp) func populateSessionFilterPost(key string, jsonInfo string, response interface{}) error { resp := response.(*SessionFilterPostResp) if resp == nil { return errors.New("Response not defined") } Loading @@ -1367,9 +1369,33 @@ func populateSessionFilter(key string, jsonInfo string, response interface{}) er } } } } return nil } func populateSessionFilter(key string, jsonInfo string, response interface{}) error { resp := response.(*SessionFilterResp) if resp == nil { return errors.New("Response not defined") } var bwInfo BwInfo err := json.Unmarshal([]byte(jsonInfo), &bwInfo) if err != nil { return err } if len(bwInfo.SessionFilter) > 0 { for _, singleSessionInput := range resp.SessionFilterList { for _, singleSessionStored := range bwInfo.SessionFilter { if reflect.DeepEqual(singleSessionInput, singleSessionStored) { resp.SessionMatch = true if resp.AllocationId == bwInfo.AllocationId { resp.AllocationIdMatch = true } } } } } return nil } Loading Loading @@ -1697,6 +1723,37 @@ func validateUpdateRequestType(bwInfoInput *BwInfo, bwInfoStored *BwInfo, w http // validate the requested changes within session specific allocation } else { log.Info("Request type is now change to session specific allocation") response := &SessionFilterResp{ SessionMatch: false, SessionFilterList: make([]BwInfoSessionFilter, len(bwInfoInput.SessionFilter)), AllocationId: "", AllocationIdMatch: false, } response.SessionFilterList = bwInfoInput.SessionFilter response.AllocationId = bwInfoInput.AllocationId // Get all Bandwidth Allocation Info from DB keyMatchStr := baseKey + "bw_alloc:*" err := rc.ForEachJSONEntry(keyMatchStr, populateSessionFilter, response) if err != nil { log.Error("Unable to fetch allocation resource from redis") errHandlerProblemDetails(w, "Unable to fetch allocation resource from redis", http.StatusInternalServerError) return err } if response.SessionMatch { if response.AllocationIdMatch { log.Info("Same sessionFilter requested to update") return nil } else { log.Error("multiple sessions match sessionFilter") errHandlerProblemDetails(w, "multiple sessions match sessionFilter", http.StatusBadRequest) return err } } switch bwInfoInput.AllocationDirection { //downlink Loading