Java Code Examples for org.apache.hadoop.yarn.conf.HAUtil#getConfValueForRMInstance()

The following examples show how to use org.apache.hadoop.yarn.conf.HAUtil#getConfValueForRMInstance() . 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: ZKRMStateStore.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Given the {@link Configuration} and {@link ACL}s used (zkAcl) for
 * ZooKeeper access, construct the {@link ACL}s for the store's root node.
 * In the constructed {@link ACL}, all the users allowed by zkAcl are given
 * rwa access, while the current RM has exclude create-delete access.
 *
 * To be called only when HA is enabled and the configuration doesn't set ACL
 * for the root node.
 */
@VisibleForTesting
@Private
@Unstable
protected List<ACL> constructZkRootNodeACL(
    Configuration conf, List<ACL> sourceACLs) throws NoSuchAlgorithmException {
  List<ACL> zkRootNodeAcl = new ArrayList<ACL>();
  for (ACL acl : sourceACLs) {
    zkRootNodeAcl.add(new ACL(
        ZKUtil.removeSpecificPerms(acl.getPerms(), CREATE_DELETE_PERMS),
        acl.getId()));
  }

  zkRootNodeUsername = HAUtil.getConfValueForRMInstance(
      YarnConfiguration.RM_ADDRESS,
      YarnConfiguration.DEFAULT_RM_ADDRESS, conf);
  Id rmId = new Id(zkRootNodeAuthScheme,
      DigestAuthenticationProvider.generateDigest(
          zkRootNodeUsername + ":" + zkRootNodePassword));
  zkRootNodeAcl.add(new ACL(CREATE_DELETE_PERMS, rmId));
  return zkRootNodeAcl;
}
 
Example 2
Source File: ZKRMStateStore.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Given the {@link Configuration} and {@link ACL}s used (zkAcl) for
 * ZooKeeper access, construct the {@link ACL}s for the store's root node.
 * In the constructed {@link ACL}, all the users allowed by zkAcl are given
 * rwa access, while the current RM has exclude create-delete access.
 *
 * To be called only when HA is enabled and the configuration doesn't set ACL
 * for the root node.
 */
@VisibleForTesting
@Private
@Unstable
protected List<ACL> constructZkRootNodeACL(
    Configuration conf, List<ACL> sourceACLs) throws NoSuchAlgorithmException {
  List<ACL> zkRootNodeAcl = new ArrayList<ACL>();
  for (ACL acl : sourceACLs) {
    zkRootNodeAcl.add(new ACL(
        ZKUtil.removeSpecificPerms(acl.getPerms(), CREATE_DELETE_PERMS),
        acl.getId()));
  }

  zkRootNodeUsername = HAUtil.getConfValueForRMInstance(
      YarnConfiguration.RM_ADDRESS,
      YarnConfiguration.DEFAULT_RM_ADDRESS, conf);
  Id rmId = new Id(zkRootNodeAuthScheme,
      DigestAuthenticationProvider.generateDigest(
          zkRootNodeUsername + ":" + zkRootNodePassword));
  zkRootNodeAcl.add(new ACL(CREATE_DELETE_PERMS, rmId));
  return zkRootNodeAcl;
}
 
Example 3
Source File: HadoopConfExtractor.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public static String extractJobHistoryUrl(String yarnWebapp, Configuration conf) {
    Pattern pattern = Pattern.compile("(http[s]*://)([^:]*):([^/])*.*");
    Matcher m = pattern.matcher(yarnWebapp);
    Preconditions.checkArgument(m.matches(), "Yarn master URL" + yarnWebapp + " not right.");
    String defaultHistoryUrl = m.group(2) + ":19888";
    return m.group(1) + HAUtil.getConfValueForRMInstance(MR_JOB_HISTORY_URL_CONF_KEY, defaultHistoryUrl, conf);
}
 
Example 4
Source File: HadoopConfExtractor.java    From kylin with Apache License 2.0 5 votes vote down vote up
public static String extractJobHistoryUrl(String yarnWebapp, Configuration conf) {
    Pattern pattern = Pattern.compile("(http[s]*://)([^:]*):([^/])*.*");
    Matcher m = pattern.matcher(yarnWebapp);
    Preconditions.checkArgument(m.matches(), "Yarn master URL" + yarnWebapp + " not right.");
    String defaultHistoryUrl = m.group(2) + ":19888";
    return m.group(1) + HAUtil.getConfValueForRMInstance(MR_JOB_HISTORY_URL_CONF_KEY, defaultHistoryUrl, conf);
}
 
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);
}