chia7712 commented on code in PR #854:
URL: https://github.com/apache/yunikorn-core/pull/854#discussion_r1576834358
##########
pkg/scheduler/objects/application.go:
##########
@@ -695,44 +697,60 @@ func (sa *Application) addAllocationAskInternal(ask
*AllocationAsk) {
}
}
-func (sa *Application) UpdateAskRepeat(allocKey string, delta int32)
(*resources.Resource, error) {
+func (sa *Application) AllocateAsk(allocKey string) (*resources.Resource,
error) {
sa.Lock()
defer sa.Unlock()
if ask := sa.requests[allocKey]; ask != nil {
+ return sa.allocateAsk(ask)
+ }
+ return nil, fmt.Errorf("failed to locate ask with key %s", allocKey)
+}
- return sa.updateAskRepeatInternal(ask, delta)
+func (sa *Application) DeallocateAsk(allocKey string) (*resources.Resource,
error) {
+ sa.Lock()
+ defer sa.Unlock()
+ if ask := sa.requests[allocKey]; ask != nil {
+ return sa.deallocateAsk(ask)
}
return nil, fmt.Errorf("failed to locate ask with key %s", allocKey)
}
-func (sa *Application) updateAskRepeatInternal(ask *AllocationAsk, delta
int32) (*resources.Resource, error) {
- // updating with delta does error checking internally
- if !ask.updatePendingAskRepeat(delta) {
- return nil, fmt.Errorf("ask repaeat not updated resulting
repeat less than zero for ask %s on app %s", ask.GetAllocationKey(),
sa.ApplicationID)
+func (sa *Application) allocateAsk(ask *AllocationAsk) (*resources.Resource,
error) {
+ if !ask.allocate() {
+ return nil, fmt.Errorf("unable to allocate previously allocated
ask %s on app %s", ask.GetAllocationKey(), sa.ApplicationID)
+ }
+
+ if ask.GetPriority() >= sa.askMaxPriority {
Review Comment:
Got it. thanks!
--
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]