You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@yunikorn.apache.org by GitBox <gi...@apache.org> on 2022/09/30 05:30:15 UTC

[GitHub] [yunikorn-core] wilfred-s commented on a diff in pull request #439: [YUNIKORN-1326] Develop tracker module.

wilfred-s commented on code in PR #439:
URL: https://github.com/apache/yunikorn-core/pull/439#discussion_r984194906


##########
pkg/scheduler/ugm/group_tracker.go:
##########
@@ -0,0 +1,87 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package ugm
+
+import (
+	"sync"
+
+	"github.com/apache/yunikorn-core/pkg/common/resources"
+)
+
+type GroupTracker struct {
+	groupName    string
+	applications map[string]bool
+	queue        *QueueTracker
+
+	sync.RWMutex
+}
+
+func NewGroupTracker(group string) *GroupTracker {
+	queueTracker := NewQueueTracker("root")
+	groupTracker := &GroupTracker{
+		groupName:    group,
+		applications: make(map[string]bool),
+		queue:        queueTracker,
+	}
+	return groupTracker
+}
+
+func (gt *GroupTracker) increaseTrackedResource(queuePath, applicationID string, usage *resources.Resource) error {
+	gt.Lock()
+	defer gt.Unlock()
+	gt.applications[applicationID] = true
+	return gt.queue.increaseTrackedResource(queuePath, applicationID, usage)
+}
+
+func (gt *GroupTracker) decreaseTrackedResource(queuePath, applicationID string, usage *resources.Resource, removeApp bool) error {
+	if removeApp {
+		gt.Lock()
+		defer gt.Unlock()
+		delete(gt.applications, applicationID)
+	}

Review Comment:
   I agree this is a difference in behaviour we need to be very careful with. Multiple decreases can occur at the same time but only one increase



-- 
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: reviews-unsubscribe@yunikorn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org