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

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

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

ZKUtil.parseACLs介绍

[英]Parse comma separated list of ACL entries to secure generated nodes, e.g. sasl:hdfs/host1@MY.DOMAIN:cdrwa,sasl:hdfs/host2@MY.DOMAIN:cdrwa
[中]解析以逗号分隔的ACL条目列表以保护生成的节点,例如:sasl:hdfs/host1@MY.DOMAIN:cdrwa,sasl:hdfs/host2@MY.DOMAIN:cdrwa

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-common

  1. /**
  2. * Utility method to fetch the ZK ACLs from the configuration.
  3. * @throws java.io.IOException if the Zookeeper ACLs configuration file
  4. * cannot be read
  5. */
  6. public static List<ACL> getZKAcls(Configuration conf) throws IOException {
  7. // Parse authentication from configuration.
  8. String zkAclConf = conf.get(CommonConfigurationKeys.ZK_ACL,
  9. CommonConfigurationKeys.ZK_ACL_DEFAULT);
  10. try {
  11. zkAclConf = ZKUtil.resolveConfIndirection(zkAclConf);
  12. return ZKUtil.parseACLs(zkAclConf);
  13. } catch (IOException | ZKUtil.BadAclFormatException e) {
  14. LOG.error("Couldn't read ACLs based on {}",
  15. CommonConfigurationKeys.ZK_ACL);
  16. throw e;
  17. }
  18. }

代码示例来源:origin: apache/kylin

  1. public static List<ACL> getZKAcls() throws Exception {
  2. // Parse ACLs from configuration.
  3. String zkAclConf = KylinConfig.getInstanceFromEnv().getZKAcls();
  4. try {
  5. zkAclConf = ZKUtil.resolveConfIndirection(zkAclConf);
  6. return ZKUtil.parseACLs(zkAclConf);
  7. } catch (Exception e) {
  8. logger.error("Couldn't read ACLs based on 'kylin.env.zookeeper.zk-acl' in kylin.properties");
  9. throw e;
  10. }
  11. }

代码示例来源:origin: org.apache.hadoop/hadoop-common

  1. private void initZK() throws HadoopIllegalArgumentException, IOException,
  2. KeeperException {
  3. zkQuorum = conf.get(ZK_QUORUM_KEY);
  4. int zkTimeout = conf.getInt(ZK_SESSION_TIMEOUT_KEY,
  5. ZK_SESSION_TIMEOUT_DEFAULT);
  6. // Parse ACLs from configuration.
  7. String zkAclConf = conf.get(ZK_ACL_KEY, ZK_ACL_DEFAULT);
  8. zkAclConf = ZKUtil.resolveConfIndirection(zkAclConf);
  9. List<ACL> zkAcls = ZKUtil.parseACLs(zkAclConf);
  10. if (zkAcls.isEmpty()) {
  11. zkAcls = Ids.CREATOR_ALL_ACL;
  12. }
  13. // Parse authentication from configuration.
  14. List<ZKAuthInfo> zkAuths = SecurityUtil.getZKAuthInfos(conf, ZK_AUTH_KEY);
  15. // Sanity check configuration.
  16. Preconditions.checkArgument(zkQuorum != null,
  17. "Missing required configuration '%s' for ZooKeeper quorum",
  18. ZK_QUORUM_KEY);
  19. Preconditions.checkArgument(zkTimeout > 0,
  20. "Invalid ZK session timeout %s", zkTimeout);
  21. int maxRetryNum = conf.getInt(
  22. CommonConfigurationKeys.HA_FC_ELECTOR_ZK_OP_RETRIES_KEY,
  23. CommonConfigurationKeys.HA_FC_ELECTOR_ZK_OP_RETRIES_DEFAULT);
  24. elector = new ActiveStandbyElector(zkQuorum,
  25. zkTimeout, getParentZnode(), zkAcls, zkAuths,
  26. new ElectorCallbacks(), maxRetryNum);
  27. }

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

  1. /**
  2. * Parse an ACL list. This includes configuration indirection
  3. * {@link ZKUtil#resolveConfIndirection(String)}
  4. * @param zkAclConf configuration string
  5. * @return an ACL list
  6. * @throws IOException on a bad ACL parse
  7. */
  8. public List<ACL> parseACLs(String zkAclConf) throws IOException {
  9. try {
  10. return ZKUtil.parseACLs(ZKUtil.resolveConfIndirection(zkAclConf));
  11. } catch (ZKUtil.BadAclFormatException e) {
  12. throw new IOException("Parsing " + zkAclConf + " :" + e, e);
  13. }
  14. }

代码示例来源:origin: io.hops/hadoop-yarn-registry

  1. /**
  2. * Parse an ACL list. This includes configuration indirection
  3. * {@link ZKUtil#resolveConfIndirection(String)}
  4. * @param zkAclConf configuration string
  5. * @return an ACL list
  6. * @throws IOException on a bad ACL parse
  7. */
  8. public List<ACL> parseACLs(String zkAclConf) throws IOException {
  9. try {
  10. return ZKUtil.parseACLs(ZKUtil.resolveConfIndirection(zkAclConf));
  11. } catch (ZKUtil.BadAclFormatException e) {
  12. throw new IOException("Parsing " + zkAclConf + " :" + e, e);
  13. }
  14. }

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

  1. /**
  2. * Utility method to fetch the ZK ACLs from the configuration
  3. */
  4. public static List<ACL> getZKAcls(Configuration conf) throws Exception {
  5. // Parse authentication from configuration.
  6. String zkAclConf =
  7. conf.get(YarnConfiguration.RM_ZK_ACL,
  8. YarnConfiguration.DEFAULT_RM_ZK_ACL);
  9. try {
  10. zkAclConf = ZKUtil.resolveConfIndirection(zkAclConf);
  11. return ZKUtil.parseACLs(zkAclConf);
  12. } catch (Exception e) {
  13. LOG.error("Couldn't read ACLs based on " + YarnConfiguration.RM_ZK_ACL);
  14. throw e;
  15. }
  16. }

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

  1. /**
  2. * Utility method to fetch the ZK ACLs from the configuration
  3. */
  4. public static List<ACL> getZKAcls(Configuration conf) throws Exception {
  5. // Parse authentication from configuration.
  6. String zkAclConf =
  7. conf.get(YarnConfiguration.RM_ZK_ACL,
  8. YarnConfiguration.DEFAULT_RM_ZK_ACL);
  9. try {
  10. zkAclConf = ZKUtil.resolveConfIndirection(zkAclConf);
  11. return ZKUtil.parseACLs(zkAclConf);
  12. } catch (Exception e) {
  13. LOG.error("Couldn't read ACLs based on " + YarnConfiguration.RM_ZK_ACL);
  14. throw e;
  15. }
  16. }

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

  1. public List<ACL> getZkAcls() throws LlamaException {
  2. // Parse authentication from configuration.
  3. String zkAclConf = conf.get(ZK_ACL, ZK_ACL_DEFAULT);
  4. try {
  5. zkAclConf = ZKUtil.resolveConfIndirection(zkAclConf);
  6. return ZKUtil.parseACLs(zkAclConf);
  7. } catch (Exception e) {
  8. throw new LlamaException(e, ErrorCode.ILLEGAL_ARGUMENT,
  9. "Couldn't read ACLs based on ", ZK_ACL);
  10. }
  11. }

代码示例来源:origin: org.apache.kylin/kylin-storage-hbase

  1. public static List<ACL> getZKAcls() throws Exception {
  2. // Parse ACLs from configuration.
  3. String zkAclConf = KylinConfig.getInstanceFromEnv().getZKAcls();
  4. try {
  5. zkAclConf = ZKUtil.resolveConfIndirection(zkAclConf);
  6. return ZKUtil.parseACLs(zkAclConf);
  7. } catch (Exception e) {
  8. logger.error("Couldn't read ACLs based on 'kylin.env.zookeeper.zk-acl' in kylin.properties");
  9. throw e;
  10. }
  11. }

代码示例来源:origin: io.hops/hadoop-common

  1. List<ACL> zkAcls = ZKUtil.parseACLs(zkAclConf);
  2. if (zkAcls.isEmpty()) {
  3. zkAcls = Ids.CREATOR_ALL_ACL;

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

  1. List<ACL> zkAcls = ZKUtil.parseACLs(zkAclConf);
  2. if (zkAcls.isEmpty()) {
  3. zkAcls = Ids.CREATOR_ALL_ACL;

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

  1. @Test
  2. public void testNullACL() {
  3. List<ACL> result = ZKUtil.parseACLs(null);
  4. assertTrue(result.isEmpty());
  5. }

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

  1. @Test
  2. public void testNullACL() {
  3. List<ACL> result = ZKUtil.parseACLs(null);
  4. assertTrue(result.isEmpty());
  5. }

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

  1. @Test
  2. public void testEmptyACL() {
  3. List<ACL> result = ZKUtil.parseACLs("");
  4. assertTrue(result.isEmpty());
  5. }

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

  1. @Test
  2. public void testEmptyACL() {
  3. List<ACL> result = ZKUtil.parseACLs("");
  4. assertTrue(result.isEmpty());
  5. }

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

  1. List<ACL> zkAcls = ZKUtil.parseACLs(zkAclConf);
  2. if (zkAcls.isEmpty()) {
  3. zkAcls = Ids.CREATOR_ALL_ACL;

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

  1. private static void badAcl(String acls, String expectedErr) {
  2. try {
  3. ZKUtil.parseACLs(acls);
  4. fail("Should have failed to parse '" + acls + "'");
  5. } catch (BadAclFormatException e) {
  6. assertEquals(expectedErr, e.getMessage());
  7. }
  8. }

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

  1. private static void badAcl(String acls, String expectedErr) {
  2. try {
  3. ZKUtil.parseACLs(acls);
  4. fail("Should have failed to parse '" + acls + "'");
  5. } catch (BadAclFormatException e) {
  6. assertEquals(expectedErr, e.getMessage());
  7. }
  8. }

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

  1. @Test
  2. public void testGoodACLs() {
  3. List<ACL> result = ZKUtil.parseACLs(
  4. "sasl:hdfs/host1@MY.DOMAIN:cdrwa, sasl:hdfs/host2@MY.DOMAIN:ca");
  5. ACL acl0 = result.get(0);
  6. assertEquals(Perms.CREATE | Perms.DELETE | Perms.READ |
  7. Perms.WRITE | Perms.ADMIN, acl0.getPerms());
  8. assertEquals("sasl", acl0.getId().getScheme());
  9. assertEquals("hdfs/host1@MY.DOMAIN", acl0.getId().getId());
  10. ACL acl1 = result.get(1);
  11. assertEquals(Perms.CREATE | Perms.ADMIN, acl1.getPerms());
  12. assertEquals("sasl", acl1.getId().getScheme());
  13. assertEquals("hdfs/host2@MY.DOMAIN", acl1.getId().getId());
  14. }

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

  1. @Test
  2. public void testGoodACLs() {
  3. List<ACL> result = ZKUtil.parseACLs(
  4. "sasl:hdfs/host1@MY.DOMAIN:cdrwa, sasl:hdfs/host2@MY.DOMAIN:ca");
  5. ACL acl0 = result.get(0);
  6. assertEquals(Perms.CREATE | Perms.DELETE | Perms.READ |
  7. Perms.WRITE | Perms.ADMIN, acl0.getPerms());
  8. assertEquals("sasl", acl0.getId().getScheme());
  9. assertEquals("hdfs/host1@MY.DOMAIN", acl0.getId().getId());
  10. ACL acl1 = result.get(1);
  11. assertEquals(Perms.CREATE | Perms.ADMIN, acl1.getPerms());
  12. assertEquals("sasl", acl1.getId().getScheme());
  13. assertEquals("hdfs/host2@MY.DOMAIN", acl1.getId().getId());
  14. }

相关文章