pbacsko commented on a change in pull request #384:
URL: 
https://github.com/apache/incubator-yunikorn-core/pull/384#discussion_r833600994



##########
File path: pkg/scheduler/objects/queue.go
##########
@@ -1292,3 +1299,35 @@ func (sq *Queue) String() string {
        return fmt.Sprintf("{QueuePath: %s, State: %s, StateTime: %x, 
MaxResource: %s}",
                sq.QueuePath, sq.stateMachine.Current(), sq.stateTime, 
sq.maxResource)
 }
+
+func (sq *Queue) incRunningApps() {
+       sq.Lock()
+       defer sq.Unlock()
+       sq.runningApps++
+       if sq.parent != nil {
+               sq.parent.incRunningApps()
+       }
+}
+
+func (sq *Queue) decRunningApps() {
+       sq.Lock()
+       defer sq.Unlock()
+       sq.runningApps--
+       if sq.parent != nil {
+               sq.parent.decRunningApps()
+       }
+}
+
+func (sq *Queue) canRun() bool {
+       sq.RLock()
+       defer sq.RUnlock()
+
+       if sq.maxRunningApps == 0 {
+               return true
+       }
+       ok := sq.runningApps < sq.maxRunningApps
+       if sq.parent != nil {

Review comment:
       Just an idea:
   If `ok` is false, it means that the limit is reached and printing a message 
is useful.
   I suggest this change:
   
   ```
   ok := sq.runningApps < sq.maxRunningApps
   if !ok {
     log.Logger().Info("Maximum number of runnable apps reached", 
zap.String("queue", sq.QueuePath))
   }
   ```
   
   or maybe we can return earlier:
   ```
   ok := sq.runningApps < sq.maxRunningApps
   if !ok {
     log.Logger().Info("Maximum number of runnable apps reached", 
zap.String("queue", sq.QueuePath))
     return false
   }
   if sq.parent != nil {
     return sq.parent.canRun()
   }
   return true
   ```




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