szilard-nemeth commented on a change in pull request #3551: URL: https://github.com/apache/hadoop/pull/3551#discussion_r731812871
########## File path: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/QueueAppLifetimeAndLimitSettings.java ########## @@ -0,0 +1,127 @@ +/* + * 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 org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity; + +import org.apache.hadoop.yarn.exceptions.YarnRuntimeException; + +public class QueueAppLifetimeAndLimitSettings { + // -1 indicates lifetime is disabled + private volatile long maxApplicationLifetime = -1; + private volatile long defaultApplicationLifetime = -1; + + // Indicates if this queue's default lifetime was set by a config property, + // either at this level or anywhere in the queue's hierarchy. + private volatile boolean defaultAppLifetimeWasSpecifiedInConfig = false; + + private int maxParallelApps; + + public QueueAppLifetimeAndLimitSettings(CapacitySchedulerConfiguration configuration, + AbstractCSQueue q, String queuePath) { + // Store max parallel apps property + this.maxParallelApps = configuration.getMaxParallelAppsForQueue(queuePath); + this.maxApplicationLifetime = getInheritedMaxAppLifetime(q, configuration); + this.defaultApplicationLifetime = getInheritedDefaultAppLifetime(q, queuePath, configuration, + maxApplicationLifetime); + } + + private long getInheritedMaxAppLifetime(CSQueue q, CapacitySchedulerConfiguration conf) { + CSQueue parentQ = q.getParent(); + long maxAppLifetime = conf.getMaximumLifetimePerQueue(q.getQueuePath()); + + // If q is the root queue, then get max app lifetime from conf. + if (parentQ == null) { + return maxAppLifetime; + } + + // If this is not the root queue, get this queue's max app lifetime + // from the conf. The parent's max app lifetime will be used if it's + // not set for this queue. + // A value of 0 will override the parent's value and means no max lifetime. + // A negative value means that the parent's max should be used. + long parentsMaxAppLifetime = parentQ.getMaximumApplicationLifetime(); + return (maxAppLifetime >= 0) ? maxAppLifetime : parentsMaxAppLifetime; + } + + private long getInheritedDefaultAppLifetime(CSQueue q, + String queuePath, CapacitySchedulerConfiguration conf, long myMaxAppLifetime) { + CSQueue parentQ = q.getParent(); + long defaultAppLifetime = conf.getDefaultLifetimePerQueue(queuePath); + defaultAppLifetimeWasSpecifiedInConfig = Review comment: As per our offline discussion with @9uapaw, this will go with the follow-up jira. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
