use of org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule 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 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 in project hadoop by apache.
the class CapacityScheduler method updatePlacementRules.
private void updatePlacementRules() throws IOException {
List<PlacementRule> placementRules = new ArrayList<>();
// Initialize UserGroupMappingPlacementRule
// TODO, need make this defineable by configuration.
UserGroupMappingPlacementRule ugRule = getUserGroupMappingPlacementRule();
if (null != ugRule) {
placementRules.add(ugRule);
}
rmContext.getQueuePlacementManager().updateRules(placementRules);
}
Aggregations