yangwwei commented on a change in pull request #108: [YUNIKORN-47] Support node 
update action
URL: 
https://github.com/apache/incubator-yunikorn-core/pull/108#discussion_r398175840
 
 

 ##########
 File path: pkg/cache/node_info.go
 ##########
 @@ -109,6 +112,40 @@ func (ni *NodeInfo) GetCapacity() *resources.Resource {
        return ni.totalResource.Clone()
 }
 
+func (ni *NodeInfo) SetCapacity(newCapacity *resources.Resource) {
+       ni.lock.Lock()
+       defer ni.lock.Unlock()
+       if resources.Equals(ni.totalResource, newCapacity) {
+               log.Logger().Info("skip updating capacity, not changed")
+               return
+       }
+
+       ni.totalResource = newCapacity
+       ni.availableResource = ni.totalResource.Clone()
+       ni.availableResource.SubFrom(ni.allocatedResource)
+       ni.availableResource.SubFrom(ni.occupiedResource)
 
 Review comment:
   Make sense to me.
   I moved to code to:
   
   ```
   // refresh node available resource based on the latest allocated and 
occupied resources.
   // this call assumes the caller already acquires the lock.
   func (ni *NodeInfo) refreshAvailableResource() {
        ni.availableResource = ni.totalResource.Clone()
        ni.availableResource.SubFrom(ni.allocatedResource)
        ni.availableResource.SubFrom(ni.occupiedResource)
   }
   ```

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@yunikorn.apache.org
For additional commands, e-mail: dev-h...@yunikorn.apache.org

Reply via email to