You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@yunikorn.apache.org by GitBox <gi...@apache.org> on 2020/02/19 21:08:24 UTC
[GitHub] [incubator-yunikorn-core] yangwwei commented on a change in pull
request #89: Core allocation/reservation logic renovation
yangwwei commented on a change in pull request #89: Core allocation/reservation logic renovation
URL: https://github.com/apache/incubator-yunikorn-core/pull/89#discussion_r381544763
##########
File path: pkg/scheduler/scheduling_application.go
##########
@@ -19,22 +19,604 @@
package scheduler
import (
+ "fmt"
+ "math"
+ "strings"
+ "sync"
+ "time"
+
+ "go.uber.org/zap"
+
"github.com/apache/incubator-yunikorn-core/pkg/cache"
"github.com/apache/incubator-yunikorn-core/pkg/common/resources"
+ "github.com/apache/incubator-yunikorn-core/pkg/log"
+ "github.com/apache/incubator-yunikorn-core/pkg/plugins"
+ "github.com/apache/incubator-yunikorn-scheduler-interface/lib/go/si"
)
+var reservationDelay = 2 * time.Second
+
type SchedulingApplication struct {
- ApplicationInfo *cache.ApplicationInfo
- Requests *SchedulingRequests
- MayAllocatedResource *resources.Resource // Maybe allocated, set by scheduler
+ ApplicationInfo *cache.ApplicationInfo
// Private fields need protection
- queue *SchedulingQueue // queue the application is running in
+ queue *SchedulingQueue // queue the application is running in
+ allocating *resources.Resource // allocating resource set by the scheduler
+ pending *resources.Resource // pending resources from asks for the app
+ reservations map[string]*reservation // a map of reservations
+ requests map[string]*schedulingAllocationAsk // a map of asks
+ sortedRequests []*schedulingAllocationAsk
+
+ sync.RWMutex
}
-func NewSchedulingApplication(appInfo *cache.ApplicationInfo) *SchedulingApplication {
+func newSchedulingApplication(appInfo *cache.ApplicationInfo) *SchedulingApplication {
return &SchedulingApplication{
ApplicationInfo: appInfo,
- Requests: NewSchedulingRequests(),
+ allocating: resources.NewResource(),
+ pending: resources.NewResource(),
+ requests: make(map[string]*schedulingAllocationAsk),
+ reservations: make(map[string]*reservation),
+ }
+}
+
+// override reservation delay for tests
+func OverrideReservationDelay(delay time.Duration) {
+ log.Logger().Debug("Test override reservation delay",
+ zap.Duration("delay", delay))
+ reservationDelay = delay
+}
+
+// Return an array of all reservation keys for the app.
+// This will return an empty array if there are no reservations.
+// Visible for tests
+func (sa *SchedulingApplication) GetReservations() []string {
+ sa.RLock()
+ defer sa.RUnlock()
+ keys := make([]string, 0)
+ for key := range sa.reservations {
+ keys = append(keys, key)
+ }
+ return keys
+}
+
+// Return the allocation ask for the key, nil if not found
+func (sa *SchedulingApplication) GetSchedulingAllocationAsk(allocationKey string) *schedulingAllocationAsk {
+ sa.RLock()
+ defer sa.RUnlock()
+ return sa.requests[allocationKey]
+}
+
+// Return the allocated resources for this application
+func (sa *SchedulingApplication) GetAllocatedResource() *resources.Resource {
+ return sa.ApplicationInfo.GetAllocatedResource()
+}
+
+// Return the pending resources for this application
+func (sa *SchedulingApplication) GetPendingResource() *resources.Resource {
+ sa.RLock()
+ defer sa.RUnlock()
+ return sa.pending
+}
+
+// Return the allocating and allocated resources for this application
+func (sa *SchedulingApplication) getUnconfirmedAllocated() *resources.Resource {
Review comment:
allocated is confirmed resource
here it calls (allocated + allocating = unconfirmedAllocated) is a bit misleading. Can we rename this to `getAssumeAllocated`?
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@yunikorn.apache.org
For additional commands, e-mail: dev-help@yunikorn.apache.org