org.apache.hadoop.security.GroupMappingServiceProvider Java Examples

The following examples show how to use org.apache.hadoop.security.GroupMappingServiceProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestQueuePlacementPolicy.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testGroupContainsPeriod() throws Exception {
  StringBuffer sb = new StringBuffer();
  sb.append("<queuePlacementPolicy>");
  sb.append("  <rule name='specified' create='false' />");
  sb.append("  <rule name='nestedUserQueue'>");
  sb.append("       <rule name='primaryGroup'/>");
  sb.append("  </rule>");
  sb.append("  <rule name='default' />");
  sb.append("</queuePlacementPolicy>");

  conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
      PeriodGroupsMapping.class, GroupMappingServiceProvider.class);
  // User queue would be created under primary group queue, and the period
  // in the group name should be converted into _dot_
  QueuePlacementPolicy policy = parse(sb.toString());
  assertEquals("root.user1_dot_group.user1",
      policy.assignAppToQueue("root.default", "user1"));

  conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
      SimpleGroupsMapping.class, GroupMappingServiceProvider.class);
}
 
Example #2
Source File: TestJNIGroupsMapping.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private void testForUser(String user) throws Exception {
  GroupMappingServiceProvider g = new ShellBasedUnixGroupsMapping();
  List<String> shellBasedGroups = g.getGroups(user);
  g = new JniBasedUnixGroupsMapping();
  List<String> jniBasedGroups = g.getGroups(user);
  
  String[] shellBasedGroupsArray = shellBasedGroups.toArray(new String[0]);
  Arrays.sort(shellBasedGroupsArray);
  String[] jniBasedGroupsArray = jniBasedGroups.toArray(new String[0]);
  Arrays.sort(jniBasedGroupsArray);
  
  if (!Arrays.equals(shellBasedGroupsArray, jniBasedGroupsArray)) {
    fail("Groups returned by " + 
        ShellBasedUnixGroupsMapping.class.getCanonicalName() + 
        " and " +
        JniBasedUnixGroupsMapping.class.getCanonicalName() + 
        " didn't match for " + user);
  }
}
 
Example #3
Source File: TestQueuePlacementPolicy.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testGroupContainsPeriod() throws Exception {
  StringBuffer sb = new StringBuffer();
  sb.append("<queuePlacementPolicy>");
  sb.append("  <rule name='specified' create='false' />");
  sb.append("  <rule name='nestedUserQueue'>");
  sb.append("       <rule name='primaryGroup'/>");
  sb.append("  </rule>");
  sb.append("  <rule name='default' />");
  sb.append("</queuePlacementPolicy>");

  conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
      PeriodGroupsMapping.class, GroupMappingServiceProvider.class);
  // User queue would be created under primary group queue, and the period
  // in the group name should be converted into _dot_
  QueuePlacementPolicy policy = parse(sb.toString());
  assertEquals("root.user1_dot_group.user1",
      policy.assignAppToQueue("root.default", "user1"));

  conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
      SimpleGroupsMapping.class, GroupMappingServiceProvider.class);
}
 
Example #4
Source File: TestJNIGroupsMapping.java    From big-c with Apache License 2.0 6 votes vote down vote up
private void testForUser(String user) throws Exception {
  GroupMappingServiceProvider g = new ShellBasedUnixGroupsMapping();
  List<String> shellBasedGroups = g.getGroups(user);
  g = new JniBasedUnixGroupsMapping();
  List<String> jniBasedGroups = g.getGroups(user);
  
  String[] shellBasedGroupsArray = shellBasedGroups.toArray(new String[0]);
  Arrays.sort(shellBasedGroupsArray);
  String[] jniBasedGroupsArray = jniBasedGroups.toArray(new String[0]);
  Arrays.sort(jniBasedGroupsArray);
  
  if (!Arrays.equals(shellBasedGroupsArray, jniBasedGroupsArray)) {
    fail("Groups returned by " + 
        ShellBasedUnixGroupsMapping.class.getCanonicalName() + 
        " and " +
        JniBasedUnixGroupsMapping.class.getCanonicalName() + 
        " didn't match for " + user);
  }
}
 
Example #5
Source File: TestFairScheduler.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testNestedUserQueue() throws IOException {
  conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);
  conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
      SimpleGroupsMapping.class, GroupMappingServiceProvider.class);
  PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
  out.println("<?xml version=\"1.0\"?>");
  out.println("<allocations>");
  out.println("<queue name=\"user1group\" type=\"parent\">");
  out.println("<minResources>1024mb,0vcores,0gcores</minResources>");
  out.println("</queue>");
  out.println("<queuePlacementPolicy>");
  out.println("<rule name=\"specified\" create=\"false\" />");
  out.println("<rule name=\"nestedUserQueue\">");
  out.println("     <rule name=\"primaryGroup\" create=\"false\" />");
  out.println("</rule>");
  out.println("<rule name=\"default\" />");
  out.println("</queuePlacementPolicy>");
  out.println("</allocations>");
  out.close();

  scheduler.init(conf);
  scheduler.start();
  scheduler.reinitialize(conf, resourceManager.getRMContext());
  RMApp rmApp1 = new MockRMApp(0, 0, RMAppState.NEW);

  FSLeafQueue user1Leaf = scheduler.assignToQueue(rmApp1, "root.default",
      "user1");

  assertEquals("root.user1group.user1", user1Leaf.getName());
}
 
Example #6
Source File: TestFairScheduler.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testSteadyFairShareWithQueueCreatedRuntime() throws Exception {
  conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
      SimpleGroupsMapping.class, GroupMappingServiceProvider.class);
  conf.set(FairSchedulerConfiguration.USER_AS_DEFAULT_QUEUE, "true");
  scheduler.init(conf);
  scheduler.start();
  scheduler.reinitialize(conf, resourceManager.getRMContext());

  // Add one node
  RMNode node1 =
      MockNodes
          .newNodeInfo(1, Resources.createResource(6144), 1, "127.0.0.1");
  NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1);
  scheduler.handle(nodeEvent1);
  assertEquals(6144, scheduler.getClusterResource().getMemory());
  assertEquals(6144, scheduler.getQueueManager().getRootQueue()
      .getSteadyFairShare().getMemory());
  assertEquals(6144, scheduler.getQueueManager()
      .getLeafQueue("default", false).getSteadyFairShare().getMemory());

  // Submit one application
  ApplicationAttemptId appAttemptId1 = createAppAttemptId(1, 1);
  createApplicationWithAMResource(appAttemptId1, "default", "user1", null);
  assertEquals(3072, scheduler.getQueueManager()
      .getLeafQueue("default", false).getSteadyFairShare().getMemory());
  assertEquals(3072, scheduler.getQueueManager()
      .getLeafQueue("user1", false).getSteadyFairShare().getMemory());
}
 
Example #7
Source File: TestHSAdminServer.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Before
public void init() throws HadoopIllegalArgumentException, IOException {
  conf = new JobConf();
  conf.set(JHAdminConfig.JHS_ADMIN_ADDRESS, "0.0.0.0:0");
  conf.setClass("hadoop.security.group.mapping", MockUnixGroupsMapping.class,
      GroupMappingServiceProvider.class);
  conf.setLong("hadoop.security.groups.cache.secs", groupRefreshTimeoutSec);
  conf.setBoolean(
        CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION,
        securityEnabled);
  Groups.getUserToGroupsMappingService(conf);
  jobHistoryService = mock(JobHistory.class);
  alds = mock(AggregatedLogDeletionService.class);

  hsAdminServer = new HSAdminServer(alds, jobHistoryService) {

    @Override
    protected Configuration createConf() {
      return conf;
    }
  };
  hsAdminServer.init(conf);
  hsAdminServer.start();
  conf.setSocketAddr(JHAdminConfig.JHS_ADMIN_ADDRESS,
      hsAdminServer.clientRpcServer.getListenerAddress());
  hsAdminClient = new HSAdmin(conf);
}
 
Example #8
Source File: TestFairScheduler.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testNestedUserQueue() throws IOException {
  conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);
  conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
      SimpleGroupsMapping.class, GroupMappingServiceProvider.class);
  PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
  out.println("<?xml version=\"1.0\"?>");
  out.println("<allocations>");
  out.println("<queue name=\"user1group\" type=\"parent\">");
  out.println("<minResources>1024mb,0vcores</minResources>");
  out.println("</queue>");
  out.println("<queuePlacementPolicy>");
  out.println("<rule name=\"specified\" create=\"false\" />");
  out.println("<rule name=\"nestedUserQueue\">");
  out.println("     <rule name=\"primaryGroup\" create=\"false\" />");
  out.println("</rule>");
  out.println("<rule name=\"default\" />");
  out.println("</queuePlacementPolicy>");
  out.println("</allocations>");
  out.close();

  scheduler.init(conf);
  scheduler.start();
  scheduler.reinitialize(conf, resourceManager.getRMContext());
  RMApp rmApp1 = new MockRMApp(0, 0, RMAppState.NEW);

  FSLeafQueue user1Leaf = scheduler.assignToQueue(rmApp1, "root.default",
      "user1");

  assertEquals("root.user1group.user1", user1Leaf.getName());
}
 
Example #9
Source File: TestFairScheduler.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testSteadyFairShareWithQueueCreatedRuntime() throws Exception {
  conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
      SimpleGroupsMapping.class, GroupMappingServiceProvider.class);
  conf.set(FairSchedulerConfiguration.USER_AS_DEFAULT_QUEUE, "true");
  scheduler.init(conf);
  scheduler.start();
  scheduler.reinitialize(conf, resourceManager.getRMContext());

  // Add one node
  RMNode node1 =
      MockNodes
          .newNodeInfo(1, Resources.createResource(6144), 1, "127.0.0.1");
  NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1);
  scheduler.handle(nodeEvent1);
  assertEquals(6144, scheduler.getClusterResource().getMemory());
  assertEquals(6144, scheduler.getQueueManager().getRootQueue()
      .getSteadyFairShare().getMemory());
  assertEquals(6144, scheduler.getQueueManager()
      .getLeafQueue("default", false).getSteadyFairShare().getMemory());

  // Submit one application
  ApplicationAttemptId appAttemptId1 = createAppAttemptId(1, 1);
  createApplicationWithAMResource(appAttemptId1, "default", "user1", null);
  assertEquals(3072, scheduler.getQueueManager()
      .getLeafQueue("default", false).getSteadyFairShare().getMemory());
  assertEquals(3072, scheduler.getQueueManager()
      .getLeafQueue("user1", false).getSteadyFairShare().getMemory());
}
 
Example #10
Source File: TestHSAdminServer.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Before
public void init() throws HadoopIllegalArgumentException, IOException {
  conf = new JobConf();
  conf.set(JHAdminConfig.JHS_ADMIN_ADDRESS, "0.0.0.0:0");
  conf.setClass("hadoop.security.group.mapping", MockUnixGroupsMapping.class,
      GroupMappingServiceProvider.class);
  conf.setLong("hadoop.security.groups.cache.secs", groupRefreshTimeoutSec);
  conf.setBoolean(
        CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION,
        securityEnabled);
  Groups.getUserToGroupsMappingService(conf);
  jobHistoryService = mock(JobHistory.class);
  alds = mock(AggregatedLogDeletionService.class);

  hsAdminServer = new HSAdminServer(alds, jobHistoryService) {

    @Override
    protected Configuration createConf() {
      return conf;
    }
  };
  hsAdminServer.init(conf);
  hsAdminServer.start();
  conf.setSocketAddr(JHAdminConfig.JHS_ADMIN_ADDRESS,
      hsAdminServer.clientRpcServer.getListenerAddress());
  hsAdminClient = new HSAdmin(conf);
}
 
Example #11
Source File: TestRMAdminService.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void
    testRefreshUserToGroupsMappingsWithFileSystemBasedConfigurationProvider()
        throws IOException, YarnException {
  configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS,
      "org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");

  String[] defaultTestUserGroups = {"dummy_group1", "dummy_group2"};
  UserGroupInformation ugi = UserGroupInformation.createUserForTesting
      ("dummyUser", defaultTestUserGroups);

  String user = ugi.getUserName();
  List<String> groupWithInit = new ArrayList<String>(2);
   for(int i = 0; i < ugi.getGroupNames().length; i++ ) {
     groupWithInit.add(ugi.getGroupNames()[i]);
   }

  // upload default configurations
  uploadDefaultConfiguration();
  Configuration conf = new Configuration();
  conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
      MockUnixGroupsMapping.class,
      GroupMappingServiceProvider.class);
  uploadConfiguration(conf, "core-site.xml");

  try {
    rm = new MockRM(configuration);
    rm.init(configuration);
    rm.start();
  } catch (Exception ex) {
    fail("Should not get any exceptions");
  }

  // Make sure RM will use the updated GroupMappingServiceProvider
  List<String> groupBefore =
      new ArrayList<String>(Groups.getUserToGroupsMappingService(
          configuration).getGroups(user));
  Assert.assertTrue(groupBefore.contains("test_group_A")
      && groupBefore.contains("test_group_B")
      && groupBefore.contains("test_group_C") && groupBefore.size() == 3);
  Assert.assertTrue(groupWithInit.size() != groupBefore.size());
  Assert.assertFalse(groupWithInit.contains("test_group_A")
      || groupWithInit.contains("test_group_B")
      || groupWithInit.contains("test_group_C"));

  // update the groups
  MockUnixGroupsMapping.updateGroups();

  rm.adminService
      .refreshUserToGroupsMappings(RefreshUserToGroupsMappingsRequest
          .newInstance());
  List<String> groupAfter =
      Groups.getUserToGroupsMappingService(configuration).getGroups(user);

  // should get the updated groups
  Assert.assertTrue(groupAfter.contains("test_group_D")
      && groupAfter.contains("test_group_E")
      && groupAfter.contains("test_group_F") && groupAfter.size() == 3);

}
 
Example #12
Source File: TestFairScheduler.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testQueuePlacementWithPolicy() throws Exception {
  conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
      SimpleGroupsMapping.class, GroupMappingServiceProvider.class);
  scheduler.init(conf);
  scheduler.start();
  scheduler.reinitialize(conf, resourceManager.getRMContext());

  ApplicationAttemptId appId;

  List<QueuePlacementRule> rules = new ArrayList<QueuePlacementRule>();
  rules.add(new QueuePlacementRule.Specified().initialize(true, null));
  rules.add(new QueuePlacementRule.User().initialize(false, null));
  rules.add(new QueuePlacementRule.PrimaryGroup().initialize(false, null));
  rules.add(new QueuePlacementRule.SecondaryGroupExistingQueue().initialize(false, null));
  rules.add(new QueuePlacementRule.Default().initialize(true, null));
  Set<String> queues = Sets.newHashSet("root.user1", "root.user3group",
      "root.user4subgroup1", "root.user4subgroup2" , "root.user5subgroup2");
  Map<FSQueueType, Set<String>> configuredQueues = new HashMap<FSQueueType, Set<String>>();
  configuredQueues.put(FSQueueType.LEAF, queues);
  configuredQueues.put(FSQueueType.PARENT, new HashSet<String>());
  scheduler.getAllocationConfiguration().placementPolicy =
      new QueuePlacementPolicy(rules, configuredQueues, conf);
  appId = createSchedulingRequest(1024, "somequeue", "user1");
  assertEquals("root.somequeue", scheduler.getSchedulerApp(appId).getQueueName());
  appId = createSchedulingRequest(1024, "default", "user1");
  assertEquals("root.user1", scheduler.getSchedulerApp(appId).getQueueName());
  appId = createSchedulingRequest(1024, "default", "user3");
  assertEquals("root.user3group", scheduler.getSchedulerApp(appId).getQueueName());
  appId = createSchedulingRequest(1024, "default", "user4");
  assertEquals("root.user4subgroup1", scheduler.getSchedulerApp(appId).getQueueName());
  appId = createSchedulingRequest(1024, "default", "user5");
  assertEquals("root.user5subgroup2", scheduler.getSchedulerApp(appId).getQueueName());
  appId = createSchedulingRequest(1024, "default", "otheruser");
  assertEquals("root.default", scheduler.getSchedulerApp(appId).getQueueName());
  
  // test without specified as first rule
  rules = new ArrayList<QueuePlacementRule>();
  rules.add(new QueuePlacementRule.User().initialize(false, null));
  rules.add(new QueuePlacementRule.Specified().initialize(true, null));
  rules.add(new QueuePlacementRule.Default().initialize(true, null));
  scheduler.getAllocationConfiguration().placementPolicy =
      new QueuePlacementPolicy(rules, configuredQueues, conf);
  appId = createSchedulingRequest(1024, "somequeue", "user1");
  assertEquals("root.user1", scheduler.getSchedulerApp(appId).getQueueName());
  appId = createSchedulingRequest(1024, "somequeue", "otheruser");
  assertEquals("root.somequeue", scheduler.getSchedulerApp(appId).getQueueName());
  appId = createSchedulingRequest(1024, "default", "otheruser");
  assertEquals("root.default", scheduler.getSchedulerApp(appId).getQueueName());
}
 
Example #13
Source File: TestQueuePlacementPolicy.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() {
  conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
      SimpleGroupsMapping.class, GroupMappingServiceProvider.class);
}
 
Example #14
Source File: TestRMAdminService.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void
    testRefreshUserToGroupsMappingsWithFileSystemBasedConfigurationProvider()
        throws IOException, YarnException {
  configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS,
      "org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");

  String[] defaultTestUserGroups = {"dummy_group1", "dummy_group2"};
  UserGroupInformation ugi = UserGroupInformation.createUserForTesting
      ("dummyUser", defaultTestUserGroups);

  String user = ugi.getUserName();
  List<String> groupWithInit = new ArrayList<String>(2);
   for(int i = 0; i < ugi.getGroupNames().length; i++ ) {
     groupWithInit.add(ugi.getGroupNames()[i]);
   }

  // upload default configurations
  uploadDefaultConfiguration();
  Configuration conf = new Configuration();
  conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
      MockUnixGroupsMapping.class,
      GroupMappingServiceProvider.class);
  uploadConfiguration(conf, "core-site.xml");

  try {
    rm = new MockRM(configuration);
    rm.init(configuration);
    rm.start();
  } catch (Exception ex) {
    fail("Should not get any exceptions");
  }

  // Make sure RM will use the updated GroupMappingServiceProvider
  List<String> groupBefore =
      new ArrayList<String>(Groups.getUserToGroupsMappingService(
          configuration).getGroups(user));
  Assert.assertTrue(groupBefore.contains("test_group_A")
      && groupBefore.contains("test_group_B")
      && groupBefore.contains("test_group_C") && groupBefore.size() == 3);
  Assert.assertTrue(groupWithInit.size() != groupBefore.size());
  Assert.assertFalse(groupWithInit.contains("test_group_A")
      || groupWithInit.contains("test_group_B")
      || groupWithInit.contains("test_group_C"));

  // update the groups
  MockUnixGroupsMapping.updateGroups();

  rm.adminService
      .refreshUserToGroupsMappings(RefreshUserToGroupsMappingsRequest
          .newInstance());
  List<String> groupAfter =
      Groups.getUserToGroupsMappingService(configuration).getGroups(user);

  // should get the updated groups
  Assert.assertTrue(groupAfter.contains("test_group_D")
      && groupAfter.contains("test_group_E")
      && groupAfter.contains("test_group_F") && groupAfter.size() == 3);

}
 
Example #15
Source File: TestFairScheduler.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testQueuePlacementWithPolicy() throws Exception {
  conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
      SimpleGroupsMapping.class, GroupMappingServiceProvider.class);
  scheduler.init(conf);
  scheduler.start();
  scheduler.reinitialize(conf, resourceManager.getRMContext());

  ApplicationAttemptId appId;

  List<QueuePlacementRule> rules = new ArrayList<QueuePlacementRule>();
  rules.add(new QueuePlacementRule.Specified().initialize(true, null));
  rules.add(new QueuePlacementRule.User().initialize(false, null));
  rules.add(new QueuePlacementRule.PrimaryGroup().initialize(false, null));
  rules.add(new QueuePlacementRule.SecondaryGroupExistingQueue().initialize(false, null));
  rules.add(new QueuePlacementRule.Default().initialize(true, null));
  Set<String> queues = Sets.newHashSet("root.user1", "root.user3group",
      "root.user4subgroup1", "root.user4subgroup2" , "root.user5subgroup2");
  Map<FSQueueType, Set<String>> configuredQueues = new HashMap<FSQueueType, Set<String>>();
  configuredQueues.put(FSQueueType.LEAF, queues);
  configuredQueues.put(FSQueueType.PARENT, new HashSet<String>());
  scheduler.getAllocationConfiguration().placementPolicy =
      new QueuePlacementPolicy(rules, configuredQueues, conf);
  appId = createSchedulingRequest(1024, "somequeue", "user1");
  assertEquals("root.somequeue", scheduler.getSchedulerApp(appId).getQueueName());
  appId = createSchedulingRequest(1024, "default", "user1");
  assertEquals("root.user1", scheduler.getSchedulerApp(appId).getQueueName());
  appId = createSchedulingRequest(1024, "default", "user3");
  assertEquals("root.user3group", scheduler.getSchedulerApp(appId).getQueueName());
  appId = createSchedulingRequest(1024, "default", "user4");
  assertEquals("root.user4subgroup1", scheduler.getSchedulerApp(appId).getQueueName());
  appId = createSchedulingRequest(1024, "default", "user5");
  assertEquals("root.user5subgroup2", scheduler.getSchedulerApp(appId).getQueueName());
  appId = createSchedulingRequest(1024, "default", "otheruser");
  assertEquals("root.default", scheduler.getSchedulerApp(appId).getQueueName());
  
  // test without specified as first rule
  rules = new ArrayList<QueuePlacementRule>();
  rules.add(new QueuePlacementRule.User().initialize(false, null));
  rules.add(new QueuePlacementRule.Specified().initialize(true, null));
  rules.add(new QueuePlacementRule.Default().initialize(true, null));
  scheduler.getAllocationConfiguration().placementPolicy =
      new QueuePlacementPolicy(rules, configuredQueues, conf);
  appId = createSchedulingRequest(1024, "somequeue", "user1");
  assertEquals("root.user1", scheduler.getSchedulerApp(appId).getQueueName());
  appId = createSchedulingRequest(1024, "somequeue", "otheruser");
  assertEquals("root.somequeue", scheduler.getSchedulerApp(appId).getQueueName());
  appId = createSchedulingRequest(1024, "default", "otheruser");
  assertEquals("root.default", scheduler.getSchedulerApp(appId).getQueueName());
}
 
Example #16
Source File: TestQueuePlacementPolicy.java    From big-c with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() {
  conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
      SimpleGroupsMapping.class, GroupMappingServiceProvider.class);
}