Java Code Examples for org.apache.hadoop.util.ZKUtil#BadAclFormatException

The following examples show how to use org.apache.hadoop.util.ZKUtil#BadAclFormatException . 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: TestZKRMStateStoreZKClientConnections.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 20000)
public void testInvalidZKAclConfiguration() {
  TestZKClient zkClientTester = new TestZKClient();
  YarnConfiguration conf = new YarnConfiguration();
  conf.set(YarnConfiguration.RM_ZK_ACL, "randomstring&*");
  try {
    zkClientTester.getRMStateStore(conf);
    fail("ZKRMStateStore created with bad ACL");
  } catch (ZKUtil.BadAclFormatException bafe) {
    // expected behavior
  } catch (Exception e) {
    String error = "Incorrect exception on BadAclFormat";
    LOG.error(error, e);
    fail(error);
  }
}
 
Example 2
Source File: TestZKRMStateStoreZKClientConnections.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 20000)
public void testInvalidZKAclConfiguration() {
  TestZKClient zkClientTester = new TestZKClient();
  YarnConfiguration conf = new YarnConfiguration();
  conf.set(YarnConfiguration.RM_ZK_ACL, "randomstring&*");
  try {
    zkClientTester.getRMStateStore(conf);
    fail("ZKRMStateStore created with bad ACL");
  } catch (ZKUtil.BadAclFormatException bafe) {
    // expected behavior
  } catch (Exception e) {
    String error = "Incorrect exception on BadAclFormat";
    LOG.error(error, e);
    fail(error);
  }
}
 
Example 3
Source File: RegistrySecurity.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Parse an ACL list. This includes configuration indirection
 * {@link ZKUtil#resolveConfIndirection(String)}
 * @param zkAclConf configuration string
 * @return an ACL list
 * @throws IOException on a bad ACL parse
 */
public List<ACL> parseACLs(String zkAclConf) throws IOException {
  try {
    return ZKUtil.parseACLs(ZKUtil.resolveConfIndirection(zkAclConf));
  } catch (ZKUtil.BadAclFormatException e) {
    throw new IOException("Parsing " + zkAclConf + " :" + e, e);
  }
}
 
Example 4
Source File: RegistrySecurity.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Parse an ACL list. This includes configuration indirection
 * {@link ZKUtil#resolveConfIndirection(String)}
 * @param zkAclConf configuration string
 * @return an ACL list
 * @throws IOException on a bad ACL parse
 */
public List<ACL> parseACLs(String zkAclConf) throws IOException {
  try {
    return ZKUtil.parseACLs(ZKUtil.resolveConfIndirection(zkAclConf));
  } catch (ZKUtil.BadAclFormatException e) {
    throw new IOException("Parsing " + zkAclConf + " :" + e, e);
  }
}
 
Example 5
Source File: ZKRMStateStore.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public synchronized void initInternal(Configuration conf) throws Exception {
  zkHostPort = conf.get(YarnConfiguration.RM_ZK_ADDRESS);
  if (zkHostPort == null) {
    throw new YarnRuntimeException("No server address specified for " +
        "zookeeper state store for Resource Manager recovery. " +
        YarnConfiguration.RM_ZK_ADDRESS + " is not configured.");
  }
  numRetries =
      conf.getInt(YarnConfiguration.RM_ZK_NUM_RETRIES,
          YarnConfiguration.DEFAULT_ZK_RM_NUM_RETRIES);
  znodeWorkingPath =
      conf.get(YarnConfiguration.ZK_RM_STATE_STORE_PARENT_PATH,
          YarnConfiguration.DEFAULT_ZK_RM_STATE_STORE_PARENT_PATH);
  zkSessionTimeout =
      conf.getInt(YarnConfiguration.RM_ZK_TIMEOUT_MS,
          YarnConfiguration.DEFAULT_RM_ZK_TIMEOUT_MS);

  if (HAUtil.isHAEnabled(conf)) {
    zkRetryInterval = zkSessionTimeout / numRetries;
  } else {
    zkRetryInterval =
        conf.getLong(YarnConfiguration.RM_ZK_RETRY_INTERVAL_MS,
            YarnConfiguration.DEFAULT_RM_ZK_RETRY_INTERVAL_MS);
  }
  zkResyncWaitTime = zkRetryInterval * numRetries;

  zkAcl = RMZKUtils.getZKAcls(conf);
  zkAuths = RMZKUtils.getZKAuths(conf);

  zkRootNodePath = getNodePath(znodeWorkingPath, ROOT_ZNODE_NAME);
  rmAppRoot = getNodePath(zkRootNodePath, RM_APP_ROOT);

  /* Initialize fencing related paths, acls, and ops */
  fencingNodePath = getNodePath(zkRootNodePath, FENCING_LOCK);
  createFencingNodePathOp = Op.create(fencingNodePath, new byte[0], zkAcl,
      CreateMode.PERSISTENT);
  deleteFencingNodePathOp = Op.delete(fencingNodePath, -1);
  if (HAUtil.isHAEnabled(conf)) {
    String zkRootNodeAclConf = HAUtil.getConfValueForRMInstance
        (YarnConfiguration.ZK_RM_STATE_STORE_ROOT_NODE_ACL, conf);
    if (zkRootNodeAclConf != null) {
      zkRootNodeAclConf = ZKUtil.resolveConfIndirection(zkRootNodeAclConf);
      try {
        zkRootNodeAcl = ZKUtil.parseACLs(zkRootNodeAclConf);
      } catch (ZKUtil.BadAclFormatException bafe) {
        LOG.error("Invalid format for " +
            YarnConfiguration.ZK_RM_STATE_STORE_ROOT_NODE_ACL);
        throw bafe;
      }
    } else {
      useDefaultFencingScheme = true;
      zkRootNodeAcl = constructZkRootNodeACL(conf, zkAcl);
    }
  }

  rmDTSecretManagerRoot =
      getNodePath(zkRootNodePath, RM_DT_SECRET_MANAGER_ROOT);
  dtMasterKeysRootPath = getNodePath(rmDTSecretManagerRoot,
      RM_DT_MASTER_KEYS_ROOT_ZNODE_NAME);
  delegationTokensRootPath = getNodePath(rmDTSecretManagerRoot,
      RM_DELEGATION_TOKENS_ROOT_ZNODE_NAME);
  dtSequenceNumberPath = getNodePath(rmDTSecretManagerRoot,
      RM_DT_SEQUENTIAL_NUMBER_ZNODE_NAME);
  amrmTokenSecretManagerRoot =
      getNodePath(zkRootNodePath, AMRMTOKEN_SECRET_MANAGER_ROOT);
}
 
Example 6
Source File: ZKRMStateStore.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public synchronized void initInternal(Configuration conf) throws Exception {
  zkHostPort = conf.get(YarnConfiguration.RM_ZK_ADDRESS);
  if (zkHostPort == null) {
    throw new YarnRuntimeException("No server address specified for " +
        "zookeeper state store for Resource Manager recovery. " +
        YarnConfiguration.RM_ZK_ADDRESS + " is not configured.");
  }
  numRetries =
      conf.getInt(YarnConfiguration.RM_ZK_NUM_RETRIES,
          YarnConfiguration.DEFAULT_ZK_RM_NUM_RETRIES);
  znodeWorkingPath =
      conf.get(YarnConfiguration.ZK_RM_STATE_STORE_PARENT_PATH,
          YarnConfiguration.DEFAULT_ZK_RM_STATE_STORE_PARENT_PATH);
  zkSessionTimeout =
      conf.getInt(YarnConfiguration.RM_ZK_TIMEOUT_MS,
          YarnConfiguration.DEFAULT_RM_ZK_TIMEOUT_MS);

  if (HAUtil.isHAEnabled(conf)) {
    zkRetryInterval = zkSessionTimeout / numRetries;
  } else {
    zkRetryInterval =
        conf.getLong(YarnConfiguration.RM_ZK_RETRY_INTERVAL_MS,
            YarnConfiguration.DEFAULT_RM_ZK_RETRY_INTERVAL_MS);
  }
  zkResyncWaitTime = zkRetryInterval * numRetries;

  zkAcl = RMZKUtils.getZKAcls(conf);
  zkAuths = RMZKUtils.getZKAuths(conf);

  zkRootNodePath = getNodePath(znodeWorkingPath, ROOT_ZNODE_NAME);
  rmAppRoot = getNodePath(zkRootNodePath, RM_APP_ROOT);

  /* Initialize fencing related paths, acls, and ops */
  fencingNodePath = getNodePath(zkRootNodePath, FENCING_LOCK);
  createFencingNodePathOp = Op.create(fencingNodePath, new byte[0], zkAcl,
      CreateMode.PERSISTENT);
  deleteFencingNodePathOp = Op.delete(fencingNodePath, -1);
  if (HAUtil.isHAEnabled(conf)) {
    String zkRootNodeAclConf = HAUtil.getConfValueForRMInstance
        (YarnConfiguration.ZK_RM_STATE_STORE_ROOT_NODE_ACL, conf);
    if (zkRootNodeAclConf != null) {
      zkRootNodeAclConf = ZKUtil.resolveConfIndirection(zkRootNodeAclConf);
      try {
        zkRootNodeAcl = ZKUtil.parseACLs(zkRootNodeAclConf);
      } catch (ZKUtil.BadAclFormatException bafe) {
        LOG.error("Invalid format for " +
            YarnConfiguration.ZK_RM_STATE_STORE_ROOT_NODE_ACL);
        throw bafe;
      }
    } else {
      useDefaultFencingScheme = true;
      zkRootNodeAcl = constructZkRootNodeACL(conf, zkAcl);
    }
  }

  rmDTSecretManagerRoot =
      getNodePath(zkRootNodePath, RM_DT_SECRET_MANAGER_ROOT);
  dtMasterKeysRootPath = getNodePath(rmDTSecretManagerRoot,
      RM_DT_MASTER_KEYS_ROOT_ZNODE_NAME);
  delegationTokensRootPath = getNodePath(rmDTSecretManagerRoot,
      RM_DELEGATION_TOKENS_ROOT_ZNODE_NAME);
  dtSequenceNumberPath = getNodePath(rmDTSecretManagerRoot,
      RM_DT_SEQUENTIAL_NUMBER_ZNODE_NAME);
  amrmTokenSecretManagerRoot =
      getNodePath(zkRootNodePath, AMRMTOKEN_SECRET_MANAGER_ROOT);
}