• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Groups类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.hadoop.security.Groups的典型用法代码示例。如果您正苦于以下问题:Java Groups类的具体用法?Java Groups怎么用?Java Groups使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Groups类属于org.apache.hadoop.security包,在下文中一共展示了Groups类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testCachePreventsImplRequest

import org.apache.hadoop.security.Groups; //导入依赖的package包/类
@Test
public void testCachePreventsImplRequest() throws Exception {
  // Disable negative cache.
  conf.setLong(
    CommonConfigurationKeys.HADOOP_SECURITY_GROUPS_NEGATIVE_CACHE_SECS, 0);
  Groups groups = new Groups(conf);
  groups.cacheGroupsAdd(Arrays.asList(myGroups));
  groups.refresh();
  FakeGroupMapping.clearBlackList();

  assertEquals(0, FakeGroupMapping.getRequestCount());

  // First call hits the wire
  assertTrue(groups.getGroups("me").size() == 2);
  assertEquals(1, FakeGroupMapping.getRequestCount());

  // Second count hits cache
  assertTrue(groups.getGroups("me").size() == 2);
  assertEquals(1, FakeGroupMapping.getRequestCount());
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:21,代码来源:TestGroupsCaching.java


示例2: testCacheEntriesExpire

import org.apache.hadoop.security.Groups; //导入依赖的package包/类
@Test
public void testCacheEntriesExpire() throws Exception {
  conf.setLong(
    CommonConfigurationKeys.HADOOP_SECURITY_GROUPS_CACHE_SECS, 1);
  FakeTimer timer = new FakeTimer();
  final Groups groups = new Groups(conf, timer);
  groups.cacheGroupsAdd(Arrays.asList(myGroups));
  groups.refresh();
  FakeGroupMapping.clearBlackList();

  // We make an entry
  groups.getGroups("me");
  int startingRequestCount = FakeGroupMapping.getRequestCount();

  timer.advance(20 * 1000);

  // Cache entry has expired so it results in a new fetch
  groups.getGroups("me");
  assertEquals(startingRequestCount + 1, FakeGroupMapping.getRequestCount());
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:21,代码来源:TestGroupsCaching.java


示例3: validateNetgroups

import org.apache.hadoop.security.Groups; //导入依赖的package包/类
/**
 * Validate the netgroups, both group membership and ACL
 * functionality
 *
 * Note: assumes a specific acl setup done by testNetgroups
 *
 * @param groups group to user mapping service
 * @param acl ACL set up in a specific way, see testNetgroups
 */
private void validateNetgroups(Groups groups,
  AccessControlList acl) throws Exception {

  // check that the netgroups are working
  List<String> elvisGroups = groups.getGroups("elvis");
  assertTrue(elvisGroups.contains("@lasVegas"));
  assertTrue(elvisGroups.contains("@memphis"));
  List<String> jerryLeeLewisGroups = groups.getGroups("jerryLeeLewis");
  assertTrue(jerryLeeLewisGroups.contains("@memphis"));

  // allowed because his netgroup is in ACL
  UserGroupInformation elvis = 
    UserGroupInformation.createRemoteUser("elvis");
  assertUserAllowed(elvis, acl);

  // allowed because he's in ACL
  UserGroupInformation carlPerkins = 
    UserGroupInformation.createRemoteUser("carlPerkins");
  assertUserAllowed(carlPerkins, acl);

  // not allowed because he's not in ACL and has no netgroups
  UserGroupInformation littleRichard = 
    UserGroupInformation.createRemoteUser("littleRichard");
  assertUserNotAllowed(littleRichard, acl);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:35,代码来源:TestAccessControlList.java


示例4: QueuePlacementPolicy

import org.apache.hadoop.security.Groups; //导入依赖的package包/类
public QueuePlacementPolicy(List<QueuePlacementRule> rules,
    Map<FSQueueType, Set<String>> configuredQueues, Configuration conf)
    throws AllocationConfigurationException {
  for (int i = 0; i < rules.size()-1; i++) {
    if (rules.get(i).isTerminal()) {
      throw new AllocationConfigurationException("Rules after rule "
          + i + " in queue placement policy can never be reached");
    }
  }
  if (!rules.get(rules.size()-1).isTerminal()) {
    throw new AllocationConfigurationException(
        "Could get past last queue placement rule without assigning");
  }
  this.rules = rules;
  this.configuredQueues = configuredQueues;
  groups = new Groups(conf);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:QueuePlacementPolicy.java


示例5: getQueueForApp

import org.apache.hadoop.security.Groups; //导入依赖的package包/类
@Override
protected String getQueueForApp(String requestedQueue, String user,
    Groups groups, Map<FSQueueType, Set<String>> configuredQueues)
    throws IOException {
  List<String> groupNames = groups.getGroups(user);
  for (int i = 1; i < groupNames.size(); i++) {
    String group = cleanName(groupNames.get(i));
    if (configuredQueues.get(FSQueueType.LEAF).contains("root." + group)
        || configuredQueues.get(FSQueueType.PARENT).contains(
            "root." + group)) {
      return "root." + group;
    }
  }
  
  return "";
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:QueuePlacementRule.java


示例6: refreshUserToGroupsMappings

import org.apache.hadoop.security.Groups; //导入依赖的package包/类
@Override
public RefreshUserToGroupsMappingsResponse refreshUserToGroupsMappings(
    RefreshUserToGroupsMappingsRequest request)
    throws YarnException, IOException {
  String argName = "refreshUserToGroupsMappings";
  UserGroupInformation user = checkAcls(argName);

  checkRMStatus(user.getShortUserName(), argName, "refresh user-groups.");

  Groups.getUserToGroupsMappingService(
      getConfiguration(new Configuration(false),
          YarnConfiguration.CORE_SITE_CONFIGURATION_FILE)).refresh();

  RMAuditLogger.logSuccess(user.getShortUserName(), argName, "AdminService");

  return recordFactory.newRecordInstance(
      RefreshUserToGroupsMappingsResponse.class);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:AdminService.java


示例7: setup

import org.apache.hadoop.security.Groups; //导入依赖的package包/类
@Before
public void setup() throws IOException {
  this.conf = new JobConf();
  this.conf.set(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
      NullGroupsProvider.class.getName());
  this.conf.setBoolean(MRConfig.MR_ACLS_ENABLED, true);
  Groups.getUserToGroupsMappingService(conf);
  this.ctx = buildHistoryContext(this.conf);
  WebApp webApp = mock(HsWebApp.class);
  when(webApp.name()).thenReturn("hsmockwebapp");
  this.hsWebServices= new HsWebServices(ctx, conf, webApp);
  this.hsWebServices.setResponse(mock(HttpServletResponse.class));

  Job job = ctx.getAllJobs().values().iterator().next();
  this.jobIdStr = job.getID().toString();
  Task task = job.getTasks().values().iterator().next();
  this.taskIdStr = task.getID().toString();
  this.taskAttemptIdStr =
      task.getAttempts().keySet().iterator().next().toString();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestHsWebServicesAcls.java


示例8: validateNetgroups

import org.apache.hadoop.security.Groups; //导入依赖的package包/类
/**
 * Validate the netgroups, both group membership and ACL
 * functionality
 *
 * Note: assumes a specific acl setup done by testNetgroups
 *
 * @param groups group to user mapping service
 * @param acl ACL set up in a specific way, see testNetgroups
 */
private void validateNetgroups(Groups groups,
  AccessControlList acl) throws Exception {

  // check that the netgroups are working
  List<String> elvisGroups = groups.getGroups("elvis");
  assertTrue(elvisGroups.contains("@lasVegas"));
  assertTrue(elvisGroups.contains("@memphis"));
  List<String> jerryLeeLewisGroups = groups.getGroups("jerryLeeLewis");
  assertTrue(jerryLeeLewisGroups.contains("@memphis"));

  // allowed becuase his netgroup is in ACL
  UserGroupInformation elvis = 
    UserGroupInformation.createRemoteUser("elvis");
  assertUserAllowed(elvis, acl);

  // allowed because he's in ACL
  UserGroupInformation carlPerkins = 
    UserGroupInformation.createRemoteUser("carlPerkins");
  assertUserAllowed(carlPerkins, acl);

  // not allowed because he's not in ACL and has no netgroups
  UserGroupInformation littleRichard = 
    UserGroupInformation.createRemoteUser("littleRichard");
  assertUserNotAllowed(littleRichard, acl);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:TestAccessControlList.java


示例9: refreshUserToGroupsMappings

import org.apache.hadoop.security.Groups; //导入依赖的package包/类
@Override
public RefreshUserToGroupsMappingsResponse refreshUserToGroupsMappings(
    RefreshUserToGroupsMappingsRequest request)
    throws YarnException, IOException {
  String argName = "refreshUserToGroupsMappings";
  UserGroupInformation user = checkAcls(argName);

  if (!isRMActive()) {
    RMAuditLogger.logFailure(user.getShortUserName(), argName,
        adminAcl.toString(), "AdminService",
        "ResourceManager is not active. Can not refresh user-groups.");
    throwStandbyException();
  }

  Groups.getUserToGroupsMappingService(
      getConfiguration(new Configuration(false),
          YarnConfiguration.CORE_SITE_CONFIGURATION_FILE)).refresh();

  RMAuditLogger.logSuccess(user.getShortUserName(), argName, "AdminService");

  return recordFactory.newRecordInstance(
      RefreshUserToGroupsMappingsResponse.class);
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:24,代码来源:AdminService.java


示例10: setupGroupsProvider

import org.apache.hadoop.security.Groups; //导入依赖的package包/类
static void setupGroupsProvider() throws IOException {
  Configuration conf = new Configuration();
  conf.set(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
      MyGroupsProvider.class.getName());
  Groups.getUserToGroupsMappingService(conf);
  MyGroupsProvider.mapping.put(jobSubmitter, Arrays.asList("group1"));
  MyGroupsProvider.mapping.put(viewColleague, Arrays.asList("group2"));
  MyGroupsProvider.mapping.put(modifyColleague, Arrays.asList("group1"));
  MyGroupsProvider.mapping.put(unauthorizedUser, Arrays.asList("evilSociety"));
  MyGroupsProvider.mapping.put(mrAdminGroupMember, Arrays.asList(mrAdminGroup));
  MyGroupsProvider.mapping.put(viewAndModifyColleague, Arrays.asList("group3"));
  MyGroupsProvider.mapping.put(qAdmin, Arrays.asList("group4"));

  mrOwner = UserGroupInformation.getCurrentUser().getShortUserName();
  MyGroupsProvider.mapping.put(mrOwner, Arrays.asList(
      new String[] { "group5", "group6" }));
  
  MyGroupsProvider.mapping.put(jobSubmitter1, Arrays.asList("group7"));
  MyGroupsProvider.mapping.put(jobSubmitter2, Arrays.asList("group7"));
  MyGroupsProvider.mapping.put(jobSubmitter3, Arrays.asList("group7"));

  MyGroupsProvider.mapping.put(mrAdminUser, Arrays.asList("group8"));
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:24,代码来源:TestWebUIAuthorization.java


示例11: PoolPlacementPolicy

import org.apache.hadoop.security.Groups; //导入依赖的package包/类
public PoolPlacementPolicy(List<PoolPlacementRule> rules,
    Set<String> configuredPools, Configuration conf)
    throws AllocationConfigurationException {
  for (int i = 0; i < rules.size()-1; i++) {
    if (rules.get(i).isTerminal()) {
      throw new AllocationConfigurationException("Rules after rule "
          + i + " in pool placement policy can never be reached");
    }
  }
  if (!rules.get(rules.size()-1).isTerminal()) {
    throw new AllocationConfigurationException(
        "Could get past last pool placement rule without assigning");
  }
  this.rules = rules;
  this.configuredPools = configuredPools;
  groups = new Groups(conf);
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:18,代码来源:PoolPlacementPolicy.java


示例12: init

import org.apache.hadoop.security.Groups; //导入依赖的package包/类
@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);
  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);
}
 
开发者ID:yncxcw,项目名称:FlexMap,代码行数:25,代码来源:TestHSAdminServer.java



注:本文中的org.apache.hadoop.security.Groups类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RotateDrawable类代码示例发布时间:2022-05-21
下一篇:
Java BlockJukebox类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap