chia7712 commented on code in PR #762:
URL: https://github.com/apache/yunikorn-core/pull/762#discussion_r1436128330


##########
pkg/webservice/handlers.go:
##########
@@ -354,7 +354,8 @@ func getNodesDAO(entries []*objects.Node) 
[]*dao.NodeDAOInfo {
 // getNodeUtilisation loads the node utilisation based on the dominant 
resource used
 // for the default partition. Dominant resource is defined as the highest 
utilised resource
 // type on the root queue based on the registered resources.
-// Use the default partition until we get YUNIKORN-2088 fixed
+// Only check the default partition
+// Deprecated - To be removed in 1.7.0. Replaced with getNodesUtilisations

Review Comment:
   Should it be removed in next major release?



##########
pkg/webservice/dao/node_util.go:
##########
@@ -18,6 +18,12 @@
 
 package dao
 
+type PartitionNodesUtilDAOInfo struct {
+       ClusterId     string              `json:"clusterId,omitempty"`

Review Comment:
   Is it possible that we have empty cluster id?



##########
pkg/webservice/handlers.go:
##########
@@ -418,6 +420,80 @@ func getNodesUtilJSON(partition 
*scheduler.PartitionContext, name string) *dao.N
        }
 }
 
+func getNodeUtilisations(w http.ResponseWriter, r *http.Request) {
+       writeHeaders(w)
+       var result []*dao.PartitionNodesUtilDAOInfo
+       for _, part := range schedulerContext.GetPartitionMapClone() {
+               partitionNodesUtilJSON := getPartitionNodesUtilJSON(part)
+               result = append(result, partitionNodesUtilJSON)
+       }
+
+       if err := json.NewEncoder(w).Encode(result); err != nil {
+               buildJSONErrorResponse(w, err.Error(), 
http.StatusInternalServerError)
+       }
+}
+
+// getPartitionNodesUtilJSON retrieves the utilization of all resource types 
for nodes within a specific partition.
+func getPartitionNodesUtilJSON(partition *scheduler.PartitionContext) 
*dao.PartitionNodesUtilDAOInfo {
+       type UtilizationBucket struct {
+               NodeCount []int      // 10 buckets, each bucket contains number 
of nodes
+               NodeList  [][]string // 10 buckets, each bucket contains node 
name list
+       }
+       resourceBuckets := make(map[string]*UtilizationBucket) // key is 
resource type, value is UtilizationBucket
+
+       // put nodes to buckets
+       for _, node := range partition.GetNodes() {

Review Comment:
   just curios. IIRC, the order of `partition.GetNodes` is not specified (as it 
is based on map). Could it be a potential issue?



##########
pkg/webservice/dao/node_util.go:
##########
@@ -18,6 +18,12 @@
 
 package dao
 
+type PartitionNodesUtilDAOInfo struct {
+       ClusterId     string              `json:"clusterId,omitempty"`
+       Partition     string              `json:"partition,omitempty"`

Review Comment:
   ditto



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to