Search in sources :

Example 1 with UserGroupMappingPlacementRule

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);
}
Also used : UserGroupMappingPlacementRule(org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule) QueueMapping(org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule.QueueMapping)

Example 2 with UserGroupMappingPlacementRule

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();
    }
}
Also used : Groups(org.apache.hadoop.security.Groups) UserGroupMappingPlacementRule(org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule) QueueMapping(org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule.QueueMapping) IOException(java.io.IOException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with UserGroupMappingPlacementRule

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);
}
Also used : PlacementRule(org.apache.hadoop.yarn.server.resourcemanager.placement.PlacementRule) UserGroupMappingPlacementRule(org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule) UserGroupMappingPlacementRule(org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule) ArrayList(java.util.ArrayList)

Aggregations

UserGroupMappingPlacementRule (org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule)3 QueueMapping (org.apache.hadoop.yarn.server.resourcemanager.placement.UserGroupMappingPlacementRule.QueueMapping)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Groups (org.apache.hadoop.security.Groups)1 PlacementRule (org.apache.hadoop.yarn.server.resourcemanager.placement.PlacementRule)1