YARN-9970. Refactor TestUserGroupMappingPlacementRule#verifyQueueMapping. Contributed by Manikandan R
This commit is contained in:
parent
8c150ed484
commit
805589fc71
@ -0,0 +1,183 @@
|
|||||||
|
/**
|
||||||
|
* 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.placement;
|
||||||
|
|
||||||
|
import org.apache.hadoop.classification.InterfaceAudience.Private;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queue Mapping class to hold the queue mapping information.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Private
|
||||||
|
public class QueueMapping {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builder class for QueueMapping.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static class QueueMappingBuilder {
|
||||||
|
|
||||||
|
private MappingType type;
|
||||||
|
private String source;
|
||||||
|
private String queue;
|
||||||
|
private String parentQueue;
|
||||||
|
|
||||||
|
public QueueMappingBuilder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static QueueMappingBuilder create() {
|
||||||
|
return new QueueMappingBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueueMappingBuilder type(MappingType mappingType) {
|
||||||
|
this.type = mappingType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueueMappingBuilder source(String mappingSource) {
|
||||||
|
this.source = mappingSource;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueueMappingBuilder queue(String mappingQueue) {
|
||||||
|
this.queue = mappingQueue;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueueMappingBuilder parentQueue(String mappingParentQueue) {
|
||||||
|
this.parentQueue = mappingParentQueue;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueueMapping build() {
|
||||||
|
return new QueueMapping(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private QueueMapping(QueueMappingBuilder builder) {
|
||||||
|
this.type = builder.type;
|
||||||
|
this.source = builder.source;
|
||||||
|
this.queue = builder.queue;
|
||||||
|
this.parentQueue = builder.parentQueue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Different types of mapping.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum MappingType {
|
||||||
|
|
||||||
|
USER("u"), GROUP("g");
|
||||||
|
|
||||||
|
private final String type;
|
||||||
|
|
||||||
|
MappingType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
private MappingType type;
|
||||||
|
private String source;
|
||||||
|
private String queue;
|
||||||
|
private String parentQueue;
|
||||||
|
|
||||||
|
private final static String DELIMITER = ":";
|
||||||
|
|
||||||
|
public String getQueue() {
|
||||||
|
return queue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParentQueue() {
|
||||||
|
return parentQueue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasParentQueue() {
|
||||||
|
return parentQueue != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MappingType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result =
|
||||||
|
prime * result + ((parentQueue == null) ? 0 : parentQueue.hashCode());
|
||||||
|
result = prime * result + ((queue == null) ? 0 : queue.hashCode());
|
||||||
|
result = prime * result + ((source == null) ? 0 : source.hashCode());
|
||||||
|
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QueueMapping other = (QueueMapping) obj;
|
||||||
|
if (parentQueue == null) {
|
||||||
|
if (other.parentQueue != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!parentQueue.equals(other.parentQueue)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (queue == null) {
|
||||||
|
if (other.queue != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!queue.equals(other.queue)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (source == null) {
|
||||||
|
if (other.source != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!source.equals(other.source)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (type != other.type) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return type.toString() + DELIMITER + source + DELIMITER
|
||||||
|
+ (parentQueue != null ? parentQueue + "." + queue : queue);
|
||||||
|
}
|
||||||
|
}
|
@ -23,18 +23,14 @@
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience.Private;
|
|
||||||
import org.apache.hadoop.security.Groups;
|
import org.apache.hadoop.security.Groups;
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
|
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule.QueueMapping.MappingType;
|
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping.MappingType;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping.QueueMappingBuilder;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.AutoCreatedLeafQueue;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.AutoCreatedLeafQueue;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
|
||||||
@ -43,6 +39,10 @@
|
|||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueManager;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueManager;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.LeafQueue;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.LeafQueue;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.ManagedParentQueue;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.ManagedParentQueue;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
|
||||||
public class UserGroupMappingPlacementRule extends PlacementRule {
|
public class UserGroupMappingPlacementRule extends PlacementRule {
|
||||||
private static final Logger LOG = LoggerFactory
|
private static final Logger LOG = LoggerFactory
|
||||||
@ -56,91 +56,6 @@ public class UserGroupMappingPlacementRule extends PlacementRule {
|
|||||||
private List<QueueMapping> mappings = null;
|
private List<QueueMapping> mappings = null;
|
||||||
private Groups groups;
|
private Groups groups;
|
||||||
|
|
||||||
@Private
|
|
||||||
public static class QueueMapping {
|
|
||||||
|
|
||||||
public enum MappingType {
|
|
||||||
|
|
||||||
USER("u"), GROUP("g");
|
|
||||||
private final String type;
|
|
||||||
|
|
||||||
private MappingType(String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
MappingType type;
|
|
||||||
String source;
|
|
||||||
String queue;
|
|
||||||
String parentQueue;
|
|
||||||
|
|
||||||
public final static String DELIMITER = ":";
|
|
||||||
|
|
||||||
public QueueMapping(MappingType type, String source, String queue) {
|
|
||||||
this.type = type;
|
|
||||||
this.source = source;
|
|
||||||
this.queue = queue;
|
|
||||||
this.parentQueue = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public QueueMapping(MappingType type, String source,
|
|
||||||
String queue, String parentQueue) {
|
|
||||||
this.type = type;
|
|
||||||
this.source = source;
|
|
||||||
this.queue = queue;
|
|
||||||
this.parentQueue = parentQueue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getQueue() {
|
|
||||||
return queue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getParentQueue() {
|
|
||||||
return parentQueue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasParentQueue() {
|
|
||||||
return parentQueue != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MappingType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSource() {
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return super.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (obj instanceof QueueMapping) {
|
|
||||||
QueueMapping other = (QueueMapping) obj;
|
|
||||||
return (other.type.equals(type) &&
|
|
||||||
other.source.equals(source) &&
|
|
||||||
other.queue.equals(queue));
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return type.toString() + DELIMITER + source + DELIMITER +
|
|
||||||
(parentQueue != null ?
|
|
||||||
parentQueue + "." + queue :
|
|
||||||
queue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserGroupMappingPlacementRule(){
|
public UserGroupMappingPlacementRule(){
|
||||||
this(false, null, null);
|
this(false, null, null);
|
||||||
}
|
}
|
||||||
@ -155,24 +70,24 @@ public UserGroupMappingPlacementRule(boolean overrideWithQueueMappings,
|
|||||||
private ApplicationPlacementContext getPlacementForUser(String user)
|
private ApplicationPlacementContext getPlacementForUser(String user)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
for (QueueMapping mapping : mappings) {
|
for (QueueMapping mapping : mappings) {
|
||||||
if (mapping.type == MappingType.USER) {
|
if (mapping.getType() == MappingType.USER) {
|
||||||
if (mapping.source.equals(CURRENT_USER_MAPPING)) {
|
if (mapping.getSource().equals(CURRENT_USER_MAPPING)) {
|
||||||
if (mapping.queue.equals(CURRENT_USER_MAPPING)) {
|
if (mapping.getQueue().equals(CURRENT_USER_MAPPING)) {
|
||||||
return getPlacementContext(mapping, user);
|
return getPlacementContext(mapping, user);
|
||||||
} else if (mapping.queue.equals(PRIMARY_GROUP_MAPPING)) {
|
} else if (mapping.getQueue().equals(PRIMARY_GROUP_MAPPING)) {
|
||||||
return getPlacementContext(mapping, groups.getGroups(user).get(0));
|
return getPlacementContext(mapping, groups.getGroups(user).get(0));
|
||||||
} else {
|
} else {
|
||||||
return getPlacementContext(mapping);
|
return getPlacementContext(mapping);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (user.equals(mapping.source)) {
|
if (user.equals(mapping.getSource())) {
|
||||||
return getPlacementContext(mapping);
|
return getPlacementContext(mapping);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mapping.type == MappingType.GROUP) {
|
if (mapping.getType() == MappingType.GROUP) {
|
||||||
for (String userGroups : groups.getGroups(user)) {
|
for (String userGroups : groups.getGroups(user)) {
|
||||||
if (userGroups.equals(mapping.source)) {
|
if (userGroups.equals(mapping.getSource())) {
|
||||||
if (mapping.queue.equals(CURRENT_USER_MAPPING)) {
|
if (mapping.getQueue().equals(CURRENT_USER_MAPPING)) {
|
||||||
return getPlacementContext(mapping, user);
|
return getPlacementContext(mapping, user);
|
||||||
}
|
}
|
||||||
return getPlacementContext(mapping);
|
return getPlacementContext(mapping);
|
||||||
@ -220,7 +135,7 @@ private ApplicationPlacementContext getPlacementContext(
|
|||||||
|
|
||||||
private ApplicationPlacementContext getPlacementContext(QueueMapping mapping,
|
private ApplicationPlacementContext getPlacementContext(QueueMapping mapping,
|
||||||
String leafQueueName) {
|
String leafQueueName) {
|
||||||
if (!StringUtils.isEmpty(mapping.parentQueue)) {
|
if (!StringUtils.isEmpty(mapping.getParentQueue())) {
|
||||||
return new ApplicationPlacementContext(leafQueueName,
|
return new ApplicationPlacementContext(leafQueueName,
|
||||||
mapping.getParentQueue());
|
mapping.getParentQueue());
|
||||||
} else{
|
} else{
|
||||||
@ -357,8 +272,12 @@ private static QueueMapping validateAndGetAutoCreatedQueueMapping(
|
|||||||
QueuePlacementRuleUtils.validateQueueMappingUnderParentQueue(
|
QueuePlacementRuleUtils.validateQueueMappingUnderParentQueue(
|
||||||
queueManager.getQueue(queuePath.getParentQueue()),
|
queueManager.getQueue(queuePath.getParentQueue()),
|
||||||
queuePath.getParentQueue(), queuePath.getLeafQueue());
|
queuePath.getParentQueue(), queuePath.getLeafQueue());
|
||||||
return new QueueMapping(mapping.getType(), mapping.getSource(),
|
return QueueMappingBuilder.create()
|
||||||
queuePath.getLeafQueue(), queuePath.getParentQueue());
|
.type(mapping.getType())
|
||||||
|
.source(mapping.getSource())
|
||||||
|
.queue(queuePath.getLeafQueue())
|
||||||
|
.parentQueue(queuePath.getParentQueue())
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -38,8 +38,9 @@
|
|||||||
import org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager;
|
import org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager;
|
||||||
import org.apache.hadoop.yarn.security.AccessType;
|
import org.apache.hadoop.yarn.security.AccessType;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
|
import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping.QueueMappingBuilder;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMappingEntity;
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMappingEntity;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule.QueueMapping;
|
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationSchedulerConfiguration;
|
import org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationSchedulerConfiguration;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerUtils;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerUtils;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.AppPriorityACLConfigurationParser.AppPriorityACLKeyType;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.AppPriorityACLConfigurationParser.AppPriorityACLKeyType;
|
||||||
@ -1128,10 +1129,11 @@ public List<QueueMapping> getQueueMappings() {
|
|||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"unknown mapping prefix " + mapping[0]);
|
"unknown mapping prefix " + mapping[0]);
|
||||||
}
|
}
|
||||||
m = new QueueMapping(
|
m = QueueMappingBuilder.create()
|
||||||
mappingType,
|
.type(mappingType)
|
||||||
mapping[1],
|
.source(mapping[1])
|
||||||
mapping[2]);
|
.queue(mapping[2])
|
||||||
|
.build();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Illegal queue mapping " + mappingValue);
|
"Illegal queue mapping " + mappingValue);
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
|
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
|
import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping.MappingType;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping.QueueMappingBuilder;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
|
||||||
@ -70,11 +72,13 @@ public void testPlaceApplicationWithPlacementRuleChain() throws Exception {
|
|||||||
.getQueuePlacementManager();
|
.getQueuePlacementManager();
|
||||||
|
|
||||||
List<PlacementRule> queuePlacementRules = new ArrayList<>();
|
List<PlacementRule> queuePlacementRules = new ArrayList<>();
|
||||||
UserGroupMappingPlacementRule.QueueMapping userQueueMapping =
|
QueueMapping userQueueMapping = QueueMappingBuilder.create()
|
||||||
new UserGroupMappingPlacementRule.QueueMapping(
|
.type(MappingType.USER)
|
||||||
UserGroupMappingPlacementRule.QueueMapping.MappingType.USER,
|
.source(USER1)
|
||||||
USER1,
|
.queue(
|
||||||
getQueueMapping(PARENT_QUEUE, USER1));
|
getQueueMapping(PARENT_QUEUE,
|
||||||
|
USER1))
|
||||||
|
.build();
|
||||||
|
|
||||||
UserGroupMappingPlacementRule ugRule = new UserGroupMappingPlacementRule(
|
UserGroupMappingPlacementRule ugRule = new UserGroupMappingPlacementRule(
|
||||||
false, Arrays.asList(userQueueMapping), null);
|
false, Arrays.asList(userQueueMapping), null);
|
||||||
|
@ -26,8 +26,9 @@
|
|||||||
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
|
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule.QueueMapping;
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping.MappingType;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule.QueueMapping.MappingType;
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping.QueueMappingBuilder;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.TestUserGroupMappingPlacementRule.QueueMappingTestData.QueueMappingTestDataBuilder;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.SimpleGroupsMapping;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.SimpleGroupsMapping;
|
||||||
import org.apache.hadoop.yarn.util.Records;
|
import org.apache.hadoop.yarn.util.Records;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
@ -43,14 +44,16 @@ public void setup() {
|
|||||||
SimpleGroupsMapping.class, GroupMappingServiceProvider.class);
|
SimpleGroupsMapping.class, GroupMappingServiceProvider.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyQueueMapping(QueueMapping queueMapping, String inputUser,
|
private void verifyQueueMapping(QueueMappingTestData queueMappingTestData)
|
||||||
String expectedQueue) throws YarnException {
|
throws YarnException {
|
||||||
verifyQueueMapping(queueMapping, inputUser,
|
|
||||||
YarnConfiguration.DEFAULT_QUEUE_NAME, expectedQueue, false);
|
QueueMapping queueMapping = queueMappingTestData.queueMapping;
|
||||||
}
|
String inputUser = queueMappingTestData.inputUser;
|
||||||
|
String inputQueue = queueMappingTestData.inputQueue;
|
||||||
|
String expectedQueue = queueMappingTestData.expectedQueue;
|
||||||
|
boolean overwrite = queueMappingTestData.overwrite;
|
||||||
|
String expectedParentQueue = queueMappingTestData.expectedParentQueue;
|
||||||
|
|
||||||
private void verifyQueueMapping(QueueMapping queueMapping, String inputUser,
|
|
||||||
String inputQueue, String expectedQueue, boolean overwrite) throws YarnException {
|
|
||||||
Groups groups = new Groups(conf);
|
Groups groups = new Groups(conf);
|
||||||
UserGroupMappingPlacementRule rule = new UserGroupMappingPlacementRule(
|
UserGroupMappingPlacementRule rule = new UserGroupMappingPlacementRule(
|
||||||
overwrite, Arrays.asList(queueMapping), groups);
|
overwrite, Arrays.asList(queueMapping), groups);
|
||||||
@ -58,53 +61,222 @@ private void verifyQueueMapping(QueueMapping queueMapping, String inputUser,
|
|||||||
ApplicationSubmissionContext.class);
|
ApplicationSubmissionContext.class);
|
||||||
asc.setQueue(inputQueue);
|
asc.setQueue(inputQueue);
|
||||||
ApplicationPlacementContext ctx = rule.getPlacementForApp(asc, inputUser);
|
ApplicationPlacementContext ctx = rule.getPlacementForApp(asc, inputUser);
|
||||||
Assert.assertEquals(expectedQueue,
|
Assert.assertEquals("Queue", expectedQueue,
|
||||||
ctx != null ? ctx.getQueue() : inputQueue);
|
ctx != null ? ctx.getQueue() : inputQueue);
|
||||||
|
if (expectedParentQueue != null) {
|
||||||
|
Assert.assertEquals("Parent Queue", expectedParentQueue,
|
||||||
|
ctx.getParentQueue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMapping() throws YarnException {
|
public void testMapping() throws YarnException {
|
||||||
|
|
||||||
// simple base case for mapping user to queue
|
// simple base case for mapping user to queue
|
||||||
verifyQueueMapping(new QueueMapping(MappingType.USER, "a", "q1"), "a", "q1");
|
verifyQueueMapping(
|
||||||
verifyQueueMapping(new QueueMapping(MappingType.GROUP, "agroup", "q1"),
|
QueueMappingTestDataBuilder.create()
|
||||||
"a", "q1");
|
.queueMapping(QueueMappingBuilder.create()
|
||||||
verifyQueueMapping(new QueueMapping(MappingType.USER, "%user", "q2"), "a",
|
.type(MappingType.USER)
|
||||||
"q2");
|
.source("a")
|
||||||
verifyQueueMapping(new QueueMapping(MappingType.USER, "%user", "%user"),
|
.queue("q1").build())
|
||||||
"a", "a");
|
.inputUser("a")
|
||||||
verifyQueueMapping(new QueueMapping(MappingType.USER, "%user",
|
.expectedQueue("q1")
|
||||||
"%primary_group"), "a", "agroup");
|
.build());
|
||||||
verifyQueueMapping(new QueueMapping(MappingType.GROUP, "asubgroup1", "q1"),
|
verifyQueueMapping(
|
||||||
"a", "q1");
|
QueueMappingTestDataBuilder.create()
|
||||||
|
.queueMapping(QueueMappingBuilder.create()
|
||||||
|
.type(MappingType.GROUP)
|
||||||
|
.source("agroup")
|
||||||
|
.queue("q1").build())
|
||||||
|
.inputUser("a")
|
||||||
|
.expectedQueue("q1")
|
||||||
|
.build());
|
||||||
|
verifyQueueMapping(
|
||||||
|
QueueMappingTestDataBuilder.create()
|
||||||
|
.queueMapping(QueueMappingBuilder.create()
|
||||||
|
.type(MappingType.USER)
|
||||||
|
.source("%user")
|
||||||
|
.queue("q2").build())
|
||||||
|
.inputUser("a")
|
||||||
|
.expectedQueue("q2")
|
||||||
|
.build());
|
||||||
|
|
||||||
|
verifyQueueMapping(
|
||||||
|
QueueMappingTestDataBuilder.create()
|
||||||
|
.queueMapping(QueueMappingBuilder.create()
|
||||||
|
.type(MappingType.USER)
|
||||||
|
.source("%user")
|
||||||
|
.queue("%user").build())
|
||||||
|
.inputUser("a")
|
||||||
|
.expectedQueue("a")
|
||||||
|
.build());
|
||||||
|
verifyQueueMapping(
|
||||||
|
QueueMappingTestDataBuilder.create()
|
||||||
|
.queueMapping(QueueMappingBuilder.create()
|
||||||
|
.type(MappingType.USER)
|
||||||
|
.source("%user")
|
||||||
|
.queue("%primary_group").build())
|
||||||
|
.inputUser("a")
|
||||||
|
.expectedQueue("agroup")
|
||||||
|
.build());
|
||||||
|
|
||||||
|
verifyQueueMapping(
|
||||||
|
QueueMappingTestDataBuilder.create()
|
||||||
|
.queueMapping(QueueMappingBuilder.create()
|
||||||
|
.type(MappingType.GROUP)
|
||||||
|
.source("asubgroup1")
|
||||||
|
.queue("q1").build())
|
||||||
|
.inputUser("a")
|
||||||
|
.expectedQueue("q1")
|
||||||
|
.build());
|
||||||
|
|
||||||
// specify overwritten, and see if user specified a queue, and it will be
|
// specify overwritten, and see if user specified a queue, and it will be
|
||||||
// overridden
|
// overridden
|
||||||
verifyQueueMapping(new QueueMapping(MappingType.USER, "user", "q1"),
|
verifyQueueMapping(
|
||||||
"user", "q2", "q1", true);
|
QueueMappingTestDataBuilder.create()
|
||||||
|
.queueMapping(QueueMappingBuilder.create()
|
||||||
|
.type(MappingType.USER)
|
||||||
|
.source("user")
|
||||||
|
.queue("q1").build())
|
||||||
|
.inputUser("user")
|
||||||
|
.inputQueue("q2")
|
||||||
|
.expectedQueue("q1")
|
||||||
|
.overwrite(true)
|
||||||
|
.build());
|
||||||
|
|
||||||
// if overwritten not specified, it should be which user specified
|
// if overwritten not specified, it should be which user specified
|
||||||
verifyQueueMapping(new QueueMapping(MappingType.USER, "user", "q1"),
|
verifyQueueMapping(
|
||||||
"user", "q2", "q2", false);
|
QueueMappingTestDataBuilder.create()
|
||||||
|
.queueMapping(QueueMappingBuilder.create()
|
||||||
|
.type(MappingType.GROUP)
|
||||||
|
.source("usergroup")
|
||||||
|
.queue("%user")
|
||||||
|
.parentQueue("usergroup")
|
||||||
|
.build())
|
||||||
|
.inputUser("user")
|
||||||
|
.inputQueue("default")
|
||||||
|
.expectedQueue("user")
|
||||||
|
.build());
|
||||||
|
|
||||||
// if overwritten not specified, it should be which user specified
|
// if overwritten not specified, it should be which user specified
|
||||||
verifyQueueMapping(new QueueMapping(MappingType.GROUP, "usergroup",
|
verifyQueueMapping(
|
||||||
"%user", "usergroup"),
|
QueueMappingTestDataBuilder.create()
|
||||||
"user", "default", "user", false);
|
.queueMapping(QueueMappingBuilder.create().
|
||||||
|
type(MappingType.GROUP)
|
||||||
// if overwritten not specified, it should be which user specified
|
.source("usergroup")
|
||||||
verifyQueueMapping(new QueueMapping(MappingType.GROUP, "usergroup",
|
.queue("%user")
|
||||||
"%user", "usergroup"),
|
.parentQueue("usergroup")
|
||||||
"user", "agroup", "user", true);
|
.build())
|
||||||
|
.inputUser("user")
|
||||||
|
.inputQueue("agroup")
|
||||||
|
.expectedQueue("user")
|
||||||
|
.overwrite(true)
|
||||||
|
.build());
|
||||||
|
|
||||||
//If user specific queue is enabled for a specified group under a given
|
//If user specific queue is enabled for a specified group under a given
|
||||||
// parent queue
|
// parent queue
|
||||||
verifyQueueMapping(new QueueMapping(MappingType.GROUP, "agroup",
|
verifyQueueMapping(
|
||||||
"%user", "parent1"),
|
QueueMappingTestDataBuilder.create()
|
||||||
"a", "a");
|
.queueMapping(QueueMappingBuilder.create()
|
||||||
|
.type(MappingType.GROUP)
|
||||||
|
.source("agroup")
|
||||||
|
.queue("%user")
|
||||||
|
.parentQueue("parent1")
|
||||||
|
.build())
|
||||||
|
.inputUser("a")
|
||||||
|
.expectedQueue("a")
|
||||||
|
.build());
|
||||||
|
|
||||||
//If user specific queue is enabled for a specified group without parent
|
//If user specific queue is enabled for a specified group without parent
|
||||||
// queue
|
// queue
|
||||||
verifyQueueMapping(new QueueMapping(MappingType.GROUP, "agroup", "%user"),
|
verifyQueueMapping(
|
||||||
"a", "a");
|
QueueMappingTestDataBuilder.create()
|
||||||
|
.queueMapping(QueueMappingBuilder.create()
|
||||||
|
.type(MappingType.GROUP)
|
||||||
|
.source("agroup")
|
||||||
|
.queue("%user").build())
|
||||||
|
.inputUser("a")
|
||||||
|
.expectedQueue("a")
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queue Mapping test class to prepare the test data.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static final class QueueMappingTestData {
|
||||||
|
|
||||||
|
private QueueMapping queueMapping;
|
||||||
|
private String inputUser;
|
||||||
|
private String inputQueue;
|
||||||
|
private String expectedQueue;
|
||||||
|
private boolean overwrite;
|
||||||
|
private String expectedParentQueue;
|
||||||
|
|
||||||
|
private QueueMappingTestData(QueueMappingTestDataBuilder builder) {
|
||||||
|
this.queueMapping = builder.queueMapping;
|
||||||
|
this.inputUser = builder.inputUser;
|
||||||
|
this.inputQueue = builder.inputQueue;
|
||||||
|
this.expectedQueue = builder.expectedQueue;
|
||||||
|
this.overwrite = builder.overwrite;
|
||||||
|
this.expectedParentQueue = builder.expectedParentQueue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builder class to prepare the Queue Mapping test data.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static class QueueMappingTestDataBuilder {
|
||||||
|
|
||||||
|
private QueueMapping queueMapping = null;
|
||||||
|
private String inputUser = null;
|
||||||
|
private String inputQueue = YarnConfiguration.DEFAULT_QUEUE_NAME;
|
||||||
|
private String expectedQueue = null;
|
||||||
|
private boolean overwrite = false;
|
||||||
|
private String expectedParentQueue = null;
|
||||||
|
|
||||||
|
public QueueMappingTestDataBuilder() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static QueueMappingTestDataBuilder create() {
|
||||||
|
return new QueueMappingTestDataBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueueMappingTestDataBuilder queueMapping(QueueMapping mapping) {
|
||||||
|
this.queueMapping = mapping;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueueMappingTestDataBuilder inputUser(String user) {
|
||||||
|
this.inputUser = user;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueueMappingTestDataBuilder inputQueue(String queue) {
|
||||||
|
this.inputQueue = queue;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueueMappingTestDataBuilder expectedQueue(String outputQueue) {
|
||||||
|
this.expectedQueue = outputQueue;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueueMappingTestDataBuilder overwrite(boolean overwriteMappings) {
|
||||||
|
this.overwrite = overwriteMappings;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueueMappingTestDataBuilder expectedParentQueue(
|
||||||
|
String outputParentQueue) {
|
||||||
|
this.expectedParentQueue = outputParentQueue;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueueMappingTestData build() {
|
||||||
|
return new QueueMappingTestData(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,8 @@
|
|||||||
import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
|
import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.placement
|
import org.apache.hadoop.yarn.server.resourcemanager.placement
|
||||||
.ApplicationPlacementContext;
|
.ApplicationPlacementContext;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.placement
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping;
|
||||||
.UserGroupMappingPlacementRule;
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping.QueueMappingBuilder;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
|
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEventType;
|
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEventType;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ContainerUpdates;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ContainerUpdates;
|
||||||
@ -255,19 +255,19 @@ public static CapacitySchedulerConfiguration setupQueueMappings(
|
|||||||
queuePlacementRules.add(YarnConfiguration.USER_GROUP_PLACEMENT_RULE);
|
queuePlacementRules.add(YarnConfiguration.USER_GROUP_PLACEMENT_RULE);
|
||||||
conf.setQueuePlacementRules(queuePlacementRules);
|
conf.setQueuePlacementRules(queuePlacementRules);
|
||||||
|
|
||||||
List<UserGroupMappingPlacementRule.QueueMapping> existingMappings =
|
List<QueueMapping> existingMappings = conf.getQueueMappings();
|
||||||
conf.getQueueMappings();
|
|
||||||
|
|
||||||
//set queue mapping
|
//set queue mapping
|
||||||
List<UserGroupMappingPlacementRule.QueueMapping> queueMappings =
|
List<QueueMapping> queueMappings = new ArrayList<>();
|
||||||
new ArrayList<>();
|
|
||||||
for (int i = 0; i < userIds.length; i++) {
|
for (int i = 0; i < userIds.length; i++) {
|
||||||
//Set C as parent queue name for auto queue creation
|
//Set C as parent queue name for auto queue creation
|
||||||
UserGroupMappingPlacementRule.QueueMapping userQueueMapping =
|
QueueMapping userQueueMapping = QueueMappingBuilder.create()
|
||||||
new UserGroupMappingPlacementRule.QueueMapping(
|
.type(QueueMapping.MappingType.USER)
|
||||||
UserGroupMappingPlacementRule.QueueMapping.MappingType.USER,
|
.source(USER + userIds[i])
|
||||||
USER + userIds[i],
|
.queue(
|
||||||
getQueueMapping(parentQueue, USER + userIds[i]));
|
getQueueMapping(parentQueue,
|
||||||
|
USER + userIds[i]))
|
||||||
|
.build();
|
||||||
queueMappings.add(userQueueMapping);
|
queueMappings.add(userQueueMapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,12 +282,10 @@ public static CapacitySchedulerConfiguration setupQueueMappings(
|
|||||||
(String parentQueue, CapacitySchedulerConfiguration conf, String
|
(String parentQueue, CapacitySchedulerConfiguration conf, String
|
||||||
leafQueueName) {
|
leafQueueName) {
|
||||||
|
|
||||||
List<UserGroupMappingPlacementRule.QueueMapping> existingMappings =
|
List<QueueMapping> existingMappings = conf.getQueueMappings();
|
||||||
conf.getQueueMappings();
|
|
||||||
|
|
||||||
//set queue mapping
|
//set queue mapping
|
||||||
List<UserGroupMappingPlacementRule.QueueMapping> queueMappings =
|
List<QueueMapping> queueMappings = new ArrayList<>();
|
||||||
new ArrayList<>();
|
|
||||||
|
|
||||||
//setup group mapping
|
//setup group mapping
|
||||||
conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
|
conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
|
||||||
@ -296,11 +294,13 @@ public static CapacitySchedulerConfiguration setupQueueMappings(
|
|||||||
TEST_GROUPUSER +"=" + TEST_GROUP + ";invalid_user=invalid_group");
|
TEST_GROUPUSER +"=" + TEST_GROUP + ";invalid_user=invalid_group");
|
||||||
Groups.getUserToGroupsMappingServiceWithLoadedConfiguration(conf);
|
Groups.getUserToGroupsMappingServiceWithLoadedConfiguration(conf);
|
||||||
|
|
||||||
UserGroupMappingPlacementRule.QueueMapping userQueueMapping =
|
QueueMapping userQueueMapping = QueueMappingBuilder.create()
|
||||||
new UserGroupMappingPlacementRule.QueueMapping(
|
.type(QueueMapping.MappingType.GROUP)
|
||||||
UserGroupMappingPlacementRule.QueueMapping.MappingType.GROUP,
|
.source(TEST_GROUP)
|
||||||
TEST_GROUP,
|
.queue(
|
||||||
getQueueMapping(parentQueue, leafQueueName));
|
getQueueMapping(parentQueue,
|
||||||
|
leafQueueName))
|
||||||
|
.build();
|
||||||
|
|
||||||
queueMappings.add(userQueueMapping);
|
queueMappings.add(userQueueMapping);
|
||||||
existingMappings.addAll(queueMappings);
|
existingMappings.addAll(queueMappings);
|
||||||
@ -482,13 +482,14 @@ protected ApplicationId submitApp(MockRM rm, CSQueue parentQueue,
|
|||||||
return rmApp.getApplicationId();
|
return rmApp.getApplicationId();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<UserGroupMappingPlacementRule.QueueMapping> setupQueueMapping(
|
protected List<QueueMapping> setupQueueMapping(
|
||||||
CapacityScheduler newCS, String user, String parentQueue, String queue) {
|
CapacityScheduler newCS, String user, String parentQueue, String queue) {
|
||||||
List<UserGroupMappingPlacementRule.QueueMapping> queueMappings =
|
List<QueueMapping> queueMappings = new ArrayList<>();
|
||||||
new ArrayList<>();
|
queueMappings.add(QueueMappingBuilder.create()
|
||||||
queueMappings.add(new UserGroupMappingPlacementRule.QueueMapping(
|
.type(QueueMapping.MappingType.USER)
|
||||||
UserGroupMappingPlacementRule.QueueMapping.MappingType.USER, user,
|
.source(user)
|
||||||
getQueueMapping(parentQueue, queue)));
|
.queue(getQueueMapping(parentQueue, queue))
|
||||||
|
.build());
|
||||||
newCS.getConfiguration().setQueueMappings(queueMappings);
|
newCS.getConfiguration().setQueueMappings(queueMappings);
|
||||||
return queueMappings;
|
return queueMappings;
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,10 @@
|
|||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
|
import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.placement.PlacementRule;
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.PlacementRule;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping.MappingType;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping.QueueMappingBuilder;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMappingEntity;
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMappingEntity;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule;
|
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -57,19 +59,19 @@ public static CapacitySchedulerConfiguration setupQueueMappingsForRules(
|
|||||||
|
|
||||||
conf.setQueuePlacementRules(queuePlacementRules);
|
conf.setQueuePlacementRules(queuePlacementRules);
|
||||||
|
|
||||||
List<UserGroupMappingPlacementRule.QueueMapping> existingMappingsForUG =
|
List<QueueMapping> existingMappingsForUG = conf.getQueueMappings();
|
||||||
conf.getQueueMappings();
|
|
||||||
|
|
||||||
//set queue mapping
|
//set queue mapping
|
||||||
List<UserGroupMappingPlacementRule.QueueMapping> queueMappingsForUG =
|
List<QueueMapping> queueMappingsForUG = new ArrayList<>();
|
||||||
new ArrayList<>();
|
|
||||||
for (int i = 0; i < sourceIds.length; i++) {
|
for (int i = 0; i < sourceIds.length; i++) {
|
||||||
//Set C as parent queue name for auto queue creation
|
//Set C as parent queue name for auto queue creation
|
||||||
UserGroupMappingPlacementRule.QueueMapping userQueueMapping =
|
QueueMapping userQueueMapping = QueueMappingBuilder.create()
|
||||||
new UserGroupMappingPlacementRule.QueueMapping(
|
.type(MappingType.USER)
|
||||||
UserGroupMappingPlacementRule.QueueMapping.MappingType.USER,
|
.source(USER + sourceIds[i])
|
||||||
USER + sourceIds[i],
|
.queue(
|
||||||
getQueueMapping(parentQueue, USER + sourceIds[i]));
|
getQueueMapping(parentQueue,
|
||||||
|
USER + sourceIds[i]))
|
||||||
|
.build();
|
||||||
queueMappingsForUG.add(userQueueMapping);
|
queueMappingsForUG.add(userQueueMapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,9 +23,10 @@
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
|
import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping.MappingType;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping.QueueMappingBuilder;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule;
|
import org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule.QueueMapping;
|
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule.QueueMapping.MappingType;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -91,7 +92,12 @@ public void testQueueMappingTrimSpaces() throws IOException {
|
|||||||
// space trimming
|
// space trimming
|
||||||
conf.set(CapacitySchedulerConfiguration.QUEUE_MAPPING, " u : a : " + Q1);
|
conf.set(CapacitySchedulerConfiguration.QUEUE_MAPPING, " u : a : " + Q1);
|
||||||
cs.reinitialize(conf, null);
|
cs.reinitialize(conf, null);
|
||||||
checkQMapping(new QueueMapping(MappingType.USER, "a", Q1));
|
checkQMapping(
|
||||||
|
QueueMappingBuilder.create()
|
||||||
|
.type(MappingType.USER)
|
||||||
|
.source("a")
|
||||||
|
.queue(Q1)
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test (timeout = 60000)
|
@Test (timeout = 60000)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user