use of org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule.QueueMapping in project hadoop by apache.
the class TestUserGroupMappingPlacementRule method testMapping.
@Test
public void testMapping() throws YarnException {
// simple base case for mapping user to queue
verifyQueueMapping(new QueueMapping(MappingType.USER, "a", "q1"), "a", "q1");
verifyQueueMapping(new QueueMapping(MappingType.GROUP, "agroup", "q1"), "a", "q1");
verifyQueueMapping(new QueueMapping(MappingType.USER, "%user", "q2"), "a", "q2");
verifyQueueMapping(new QueueMapping(MappingType.USER, "%user", "%user"), "a", "a");
verifyQueueMapping(new QueueMapping(MappingType.USER, "%user", "%primary_group"), "a", "agroup");
verifyQueueMapping(new QueueMapping(MappingType.GROUP, "asubgroup1", "q1"), "a", "q1");
// specify overwritten, and see if user specified a queue, and it will be
// overridden
verifyQueueMapping(new QueueMapping(MappingType.USER, "user", "q1"), "user", "q2", "q1", true);
// if overwritten not specified, it should be which user specified
verifyQueueMapping(new QueueMapping(MappingType.USER, "user", "q1"), "user", "q2", "q2", false);
}
use of org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule.QueueMapping in project hadoop by apache.
the class TestQueueMappings method testQueueMappingTrimSpaces.
@Test
public void testQueueMappingTrimSpaces() throws IOException {
// space trimming
conf.set(CapacitySchedulerConfiguration.QUEUE_MAPPING, " u : a : " + Q1);
cs.reinitialize(conf, null);
checkQMapping(new QueueMapping(MappingType.USER, "a", Q1));
}
use of org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule.QueueMapping in project hadoop by apache.
the class TestQueueMappings method checkQMapping.
private void checkQMapping(QueueMapping expected) throws IOException {
UserGroupMappingPlacementRule rule = (UserGroupMappingPlacementRule) cs.getRMContext().getQueuePlacementManager().getPlacementRules().get(0);
QueueMapping queueMapping = rule.getQueueMappings().get(0);
Assert.assertEquals(queueMapping, expected);
}
use of org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule.QueueMapping in project hadoop by apache.
the class CapacityScheduler method getUserGroupMappingPlacementRule.
@VisibleForTesting
public UserGroupMappingPlacementRule getUserGroupMappingPlacementRule() throws IOException {
try {
readLock.lock();
boolean overrideWithQueueMappings = conf.getOverrideWithQueueMappings();
LOG.info("Initialized queue mappings, override: " + overrideWithQueueMappings);
// Get new user/group mappings
List<QueueMapping> newMappings = conf.getQueueMappings();
// check if mappings refer to valid queues
for (QueueMapping mapping : newMappings) {
String mappingQueue = mapping.getQueue();
if (!mappingQueue.equals(UserGroupMappingPlacementRule.CURRENT_USER_MAPPING) && !mappingQueue.equals(UserGroupMappingPlacementRule.PRIMARY_GROUP_MAPPING)) {
CSQueue queue = getQueue(mappingQueue);
if (queue == null || !(queue instanceof LeafQueue)) {
throw new IOException("mapping contains invalid or non-leaf queue " + mappingQueue);
}
}
}
// initialize groups if mappings are present
if (newMappings.size() > 0) {
Groups groups = new Groups(conf);
return new UserGroupMappingPlacementRule(overrideWithQueueMappings, newMappings, groups);
}
return null;
} finally {
readLock.unlock();
}
}
use of org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule.QueueMapping in project hadoop by apache.
the class CapacitySchedulerConfiguration method getQueueMappings.
/**
* Get user/group mappings to queues.
*
* @return user/groups mappings or null on illegal configs
*/
public List<QueueMapping> getQueueMappings() {
List<QueueMapping> mappings = new ArrayList<QueueMapping>();
Collection<String> mappingsString = getTrimmedStringCollection(QUEUE_MAPPING);
for (String mappingValue : mappingsString) {
String[] mapping = getTrimmedStringCollection(mappingValue, ":").toArray(new String[] {});
if (mapping.length != 3 || mapping[1].length() == 0 || mapping[2].length() == 0) {
throw new IllegalArgumentException("Illegal queue mapping " + mappingValue);
}
QueueMapping m;
try {
QueueMapping.MappingType mappingType;
if (mapping[0].equals("u")) {
mappingType = QueueMapping.MappingType.USER;
} else if (mapping[0].equals("g")) {
mappingType = QueueMapping.MappingType.GROUP;
} else {
throw new IllegalArgumentException("unknown mapping prefix " + mapping[0]);
}
m = new QueueMapping(mappingType, mapping[1], mapping[2]);
} catch (Throwable t) {
throw new IllegalArgumentException("Illegal queue mapping " + mappingValue);
}
if (m != null) {
mappings.add(m);
}
}
return mappings;
}
Aggregations