org.apache.hadoop.util.ZKUtil.removeSpecificPerms()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中org.apache.hadoop.util.ZKUtil.removeSpecificPerms()方法的一些代码示例,展示了ZKUtil.removeSpecificPerms()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKUtil.removeSpecificPerms()方法的具体详情如下:
包路径:org.apache.hadoop.util.ZKUtil
类名称:ZKUtil
方法名:removeSpecificPerms

ZKUtil.removeSpecificPerms介绍

[英]Helper method to remove a subset of permissions (remove) from a given set (perms).
[中]Helper方法从给定集合(perms)中移除权限子集(remove)。

代码示例

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

  1. @Test
  2. public void testRemoveSpecificPerms() {
  3. int perms = Perms.ALL;
  4. int remove = Perms.CREATE;
  5. int newPerms = ZKUtil.removeSpecificPerms(perms, remove);
  6. assertEquals("Removal failed", 0, newPerms & Perms.CREATE);
  7. }

代码示例来源:origin: ch.cern.hadoop/hadoop-common

  1. @Test
  2. public void testRemoveSpecificPerms() {
  3. int perms = Perms.ALL;
  4. int remove = Perms.CREATE;
  5. int newPerms = ZKUtil.removeSpecificPerms(perms, remove);
  6. assertEquals("Removal failed", 0, newPerms & Perms.CREATE);
  7. }

代码示例来源:origin: com.cloudera.llama/llama

  1. private List<ACL> createAclsForExclusiveReadAccess() throws LlamaException {
  2. List<ACL> acls = new ArrayList<ACL>();
  3. for (ACL acl : conf.getZkAcls()) {
  4. acls.add(new ACL(
  5. ZKUtil.removeSpecificPerms(acl.getPerms(), ZooDefs.Perms.READ),
  6. acl.getId()));
  7. }
  8. Id llamaId;
  9. try {
  10. llamaId =
  11. new Id(authScheme, DigestAuthenticationProvider.generateDigest(
  12. fencingUsername + ":" + fencingPassword));
  13. } catch (NoSuchAlgorithmException e) {
  14. throw new LlamaException(ErrorCode.INTERNAL_ERROR,
  15. "Unable to create username:password digest for ZK");
  16. }
  17. acls.add(new ACL(ZooDefs.Perms.READ, llamaId));
  18. return acls;
  19. }

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-resourcemanager

  1. /**
  2. * Given the {@link Configuration} and {@link ACL}s used (zkAcl) for
  3. * ZooKeeper access, construct the {@link ACL}s for the store's root node.
  4. * In the constructed {@link ACL}, all the users allowed by zkAcl are given
  5. * rwa access, while the current RM has exclude create-delete access.
  6. *
  7. * To be called only when HA is enabled and the configuration doesn't set ACL
  8. * for the root node.
  9. */
  10. @VisibleForTesting
  11. @Private
  12. @Unstable
  13. protected List<ACL> constructZkRootNodeACL(
  14. Configuration conf, List<ACL> sourceACLs) throws NoSuchAlgorithmException {
  15. List<ACL> zkRootNodeAcl = new ArrayList<ACL>();
  16. for (ACL acl : sourceACLs) {
  17. zkRootNodeAcl.add(new ACL(
  18. ZKUtil.removeSpecificPerms(acl.getPerms(), CREATE_DELETE_PERMS),
  19. acl.getId()));
  20. }
  21. zkRootNodeUsername = HAUtil.getConfValueForRMInstance(
  22. YarnConfiguration.RM_ADDRESS,
  23. YarnConfiguration.DEFAULT_RM_ADDRESS, conf);
  24. Id rmId = new Id(zkRootNodeAuthScheme,
  25. DigestAuthenticationProvider.generateDigest(
  26. zkRootNodeUsername + ":" + zkRootNodePassword));
  27. zkRootNodeAcl.add(new ACL(CREATE_DELETE_PERMS, rmId));
  28. return zkRootNodeAcl;
  29. }

代码示例来源:origin: com.github.jiayuhan-it/hadoop-yarn-server-resourcemanager

  1. /**
  2. * Given the {@link Configuration} and {@link ACL}s used (zkAcl) for
  3. * ZooKeeper access, construct the {@link ACL}s for the store's root node.
  4. * In the constructed {@link ACL}, all the users allowed by zkAcl are given
  5. * rwa access, while the current RM has exclude create-delete access.
  6. *
  7. * To be called only when HA is enabled and the configuration doesn't set ACL
  8. * for the root node.
  9. */
  10. @VisibleForTesting
  11. @Private
  12. @Unstable
  13. protected List<ACL> constructZkRootNodeACL(
  14. Configuration conf, List<ACL> sourceACLs) throws NoSuchAlgorithmException {
  15. List<ACL> zkRootNodeAcl = new ArrayList<ACL>();
  16. for (ACL acl : sourceACLs) {
  17. zkRootNodeAcl.add(new ACL(
  18. ZKUtil.removeSpecificPerms(acl.getPerms(), CREATE_DELETE_PERMS),
  19. acl.getId()));
  20. }
  21. zkRootNodeUsername = HAUtil.getConfValueForRMInstance(
  22. YarnConfiguration.RM_ADDRESS,
  23. YarnConfiguration.DEFAULT_RM_ADDRESS, conf);
  24. Id rmId = new Id(zkRootNodeAuthScheme,
  25. DigestAuthenticationProvider.generateDigest(
  26. zkRootNodeUsername + ":" + zkRootNodePassword));
  27. zkRootNodeAcl.add(new ACL(CREATE_DELETE_PERMS, rmId));
  28. return zkRootNodeAcl;
  29. }

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

  1. ZKUtil.removeSpecificPerms(acl.getPerms(), CREATE_DELETE_PERMS),
  2. acl.getId()));

相关文章