sunilgovind commented on a change in pull request #224:
URL: 
https://github.com/apache/incubator-yunikorn-core/pull/224#discussion_r531666986



##########
File path: pkg/webservice/handlers.go
##########
@@ -521,3 +522,49 @@ func updateConfiguration(conf string) (string, error) {
        }
        return "", fmt.Errorf("config plugin not found")
 }
+
+func getQueueApplications(w http.ResponseWriter, r *http.Request) {
+       vars := mux.Vars(r)
+       writeHeaders(w)
+       if len(vars) != 2 {
+               http.Error(w, "Mandatory parameters are missing in URL path. 
Please check the usage documentation", http.StatusBadRequest)
+               return
+       }
+       var queueName = vars["queue"]
+       if len(queueName) == 0 {
+               http.Error(w, "Queue is missing in URL path. Please check the 
usage documentation", http.StatusBadRequest)
+               return
+       }
+       queueErr := validateQueue(queueName)
+       if queueErr != nil {
+               http.Error(w, queueErr.Error(), http.StatusBadRequest)
+               return
+       }
+       var partitionExists = false
+       var queueExists = false
+       var appsDao []*dao.ApplicationDAOInfo
+       lists := schedulerContext.GetPartitionMapClone()
+       for _, partition := range lists {
+               if partition.Name == vars["partition"] {
+                       partitionExists = true
+                       appList := partition.GetApplications()
+                       for _, app := range appList {
+                               if strings.EqualFold(queueName, 
app.GetQueueName()) {
+                                       queueExists = true
+                                       appsDao = append(appsDao, 
getApplicationJSON(app))
+                               }
+                       }
+               }
+       }
+       if !partitionExists {

Review comment:
       Do we need to loop to find the partition exists or not?

##########
File path: pkg/webservice/handlers.go
##########
@@ -521,3 +522,49 @@ func updateConfiguration(conf string) (string, error) {
        }
        return "", fmt.Errorf("config plugin not found")
 }
+
+func getQueueApplications(w http.ResponseWriter, r *http.Request) {
+       vars := mux.Vars(r)
+       writeHeaders(w)
+       if len(vars) != 2 {
+               http.Error(w, "Mandatory parameters are missing in URL path. 
Please check the usage documentation", http.StatusBadRequest)
+               return
+       }
+       var queueName = vars["queue"]
+       if len(queueName) == 0 {
+               http.Error(w, "Queue is missing in URL path. Please check the 
usage documentation", http.StatusBadRequest)
+               return
+       }
+       queueErr := validateQueue(queueName)
+       if queueErr != nil {
+               http.Error(w, queueErr.Error(), http.StatusBadRequest)
+               return
+       }
+       var partitionExists = false
+       var queueExists = false
+       var appsDao []*dao.ApplicationDAOInfo
+       lists := schedulerContext.GetPartitionMapClone()
+       for _, partition := range lists {
+               if partition.Name == vars["partition"] {
+                       partitionExists = true
+                       appList := partition.GetApplications()

Review comment:
       Is it safe to loop application here?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to