Java Code Examples for org.apache.hadoop.util.ZKUtil#resolveConfIndirection()

The following examples show how to use org.apache.hadoop.util.ZKUtil#resolveConfIndirection() . 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: RMZKUtils.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Utility method to fetch ZK auth info from the configuration
 */
public static List<ZKUtil.ZKAuthInfo> getZKAuths(Configuration conf)
    throws Exception {
  String zkAuthConf = conf.get(YarnConfiguration.RM_ZK_AUTH);
  try {
    zkAuthConf = ZKUtil.resolveConfIndirection(zkAuthConf);
    if (zkAuthConf != null) {
      return ZKUtil.parseAuth(zkAuthConf);
    } else {
      return Collections.emptyList();
    }
  } catch (Exception e) {
    LOG.error("Couldn't read Auth based on " + YarnConfiguration.RM_ZK_AUTH);
    throw e;
  }
}
 
Example 2
Source File: RMZKUtils.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Utility method to fetch ZK auth info from the configuration
 */
public static List<ZKUtil.ZKAuthInfo> getZKAuths(Configuration conf)
    throws Exception {
  String zkAuthConf = conf.get(YarnConfiguration.RM_ZK_AUTH);
  try {
    zkAuthConf = ZKUtil.resolveConfIndirection(zkAuthConf);
    if (zkAuthConf != null) {
      return ZKUtil.parseAuth(zkAuthConf);
    } else {
      return Collections.emptyList();
    }
  } catch (Exception e) {
    LOG.error("Couldn't read Auth based on " + YarnConfiguration.RM_ZK_AUTH);
    throw e;
  }
}
 
Example 3
Source File: ZookeeperAclBuilder.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public static List<ZKUtil.ZKAuthInfo> getZKAuths() throws Exception {
    // Parse Auths from configuration.
    String zkAuthConf = KylinConfig.getInstanceFromEnv().getZKAuths();
    try {
        zkAuthConf = ZKUtil.resolveConfIndirection(zkAuthConf);
        if (zkAuthConf != null) {
            return ZKUtil.parseAuth(zkAuthConf);
        } else {
            return Collections.emptyList();
        }
    } catch (Exception e) {
        logger.error("Couldn't read Auth based on 'kylin.env.zookeeper.zk-auth' in kylin.properties");
        throw e;
    }
}
 
Example 4
Source File: ZookeeperAclBuilder.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public static List<ACL> getZKAcls() throws Exception {
    // Parse ACLs from configuration.
    String zkAclConf = KylinConfig.getInstanceFromEnv().getZKAcls();
    try {
        zkAclConf = ZKUtil.resolveConfIndirection(zkAclConf);
        return ZKUtil.parseACLs(zkAclConf);
    } catch (Exception e) {
        logger.error("Couldn't read ACLs based on 'kylin.env.zookeeper.zk-acl' in kylin.properties");
        throw e;
    }
}
 
Example 5
Source File: RMZKUtils.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Utility method to fetch the ZK ACLs from the configuration
 */
public static List<ACL> getZKAcls(Configuration conf) throws Exception {
  // Parse authentication from configuration.
  String zkAclConf =
      conf.get(YarnConfiguration.RM_ZK_ACL,
          YarnConfiguration.DEFAULT_RM_ZK_ACL);
  try {
    zkAclConf = ZKUtil.resolveConfIndirection(zkAclConf);
    return ZKUtil.parseACLs(zkAclConf);
  } catch (Exception e) {
    LOG.error("Couldn't read ACLs based on " + YarnConfiguration.RM_ZK_ACL);
    throw e;
  }
}
 
Example 6
Source File: ZKFailoverController.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void initZK() throws HadoopIllegalArgumentException, IOException,
    KeeperException {
  zkQuorum = conf.get(ZK_QUORUM_KEY);
  int zkTimeout = conf.getInt(ZK_SESSION_TIMEOUT_KEY,
      ZK_SESSION_TIMEOUT_DEFAULT);
  // Parse ACLs from configuration.
  String zkAclConf = conf.get(ZK_ACL_KEY, ZK_ACL_DEFAULT);
  zkAclConf = ZKUtil.resolveConfIndirection(zkAclConf);
  List<ACL> zkAcls = ZKUtil.parseACLs(zkAclConf);
  if (zkAcls.isEmpty()) {
    zkAcls = Ids.CREATOR_ALL_ACL;
  }
  
  // Parse authentication from configuration.
  String zkAuthConf = conf.get(ZK_AUTH_KEY);
  zkAuthConf = ZKUtil.resolveConfIndirection(zkAuthConf);
  List<ZKAuthInfo> zkAuths;
  if (zkAuthConf != null) {
    zkAuths = ZKUtil.parseAuth(zkAuthConf);
  } else {
    zkAuths = Collections.emptyList();
  }

  // Sanity check configuration.
  Preconditions.checkArgument(zkQuorum != null,
      "Missing required configuration '%s' for ZooKeeper quorum",
      ZK_QUORUM_KEY);
  Preconditions.checkArgument(zkTimeout > 0,
      "Invalid ZK session timeout %s", zkTimeout);
  
  int maxRetryNum = conf.getInt(
      CommonConfigurationKeys.HA_FC_ELECTOR_ZK_OP_RETRIES_KEY,
      CommonConfigurationKeys.HA_FC_ELECTOR_ZK_OP_RETRIES_DEFAULT);
  elector = new ActiveStandbyElector(zkQuorum,
      zkTimeout, getParentZnode(), zkAcls, zkAuths,
      new ElectorCallbacks(), maxRetryNum);
}
 
Example 7
Source File: RMZKUtils.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Utility method to fetch the ZK ACLs from the configuration
 */
public static List<ACL> getZKAcls(Configuration conf) throws Exception {
  // Parse authentication from configuration.
  String zkAclConf =
      conf.get(YarnConfiguration.RM_ZK_ACL,
          YarnConfiguration.DEFAULT_RM_ZK_ACL);
  try {
    zkAclConf = ZKUtil.resolveConfIndirection(zkAclConf);
    return ZKUtil.parseACLs(zkAclConf);
  } catch (Exception e) {
    LOG.error("Couldn't read ACLs based on " + YarnConfiguration.RM_ZK_ACL);
    throw e;
  }
}
 
Example 8
Source File: ZKFailoverController.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void initZK() throws HadoopIllegalArgumentException, IOException,
    KeeperException {
  zkQuorum = conf.get(ZK_QUORUM_KEY);
  int zkTimeout = conf.getInt(ZK_SESSION_TIMEOUT_KEY,
      ZK_SESSION_TIMEOUT_DEFAULT);
  // Parse ACLs from configuration.
  String zkAclConf = conf.get(ZK_ACL_KEY, ZK_ACL_DEFAULT);
  zkAclConf = ZKUtil.resolveConfIndirection(zkAclConf);
  List<ACL> zkAcls = ZKUtil.parseACLs(zkAclConf);
  if (zkAcls.isEmpty()) {
    zkAcls = Ids.CREATOR_ALL_ACL;
  }
  
  // Parse authentication from configuration.
  String zkAuthConf = conf.get(ZK_AUTH_KEY);
  zkAuthConf = ZKUtil.resolveConfIndirection(zkAuthConf);
  List<ZKAuthInfo> zkAuths;
  if (zkAuthConf != null) {
    zkAuths = ZKUtil.parseAuth(zkAuthConf);
  } else {
    zkAuths = Collections.emptyList();
  }

  // Sanity check configuration.
  Preconditions.checkArgument(zkQuorum != null,
      "Missing required configuration '%s' for ZooKeeper quorum",
      ZK_QUORUM_KEY);
  Preconditions.checkArgument(zkTimeout > 0,
      "Invalid ZK session timeout %s", zkTimeout);
  
  int maxRetryNum = conf.getInt(
      CommonConfigurationKeys.HA_FC_ELECTOR_ZK_OP_RETRIES_KEY,
      CommonConfigurationKeys.HA_FC_ELECTOR_ZK_OP_RETRIES_DEFAULT);
  elector = new ActiveStandbyElector(zkQuorum,
      zkTimeout, getParentZnode(), zkAcls, zkAuths,
      new ElectorCallbacks(), maxRetryNum);
}
 
Example 9
Source File: ZookeeperAclBuilder.java    From kylin with Apache License 2.0 5 votes vote down vote up
public static List<ZKUtil.ZKAuthInfo> getZKAuths() throws Exception {
    // Parse Auths from configuration.
    String zkAuthConf = KylinConfig.getInstanceFromEnv().getZKAuths();
    try {
        zkAuthConf = ZKUtil.resolveConfIndirection(zkAuthConf);
        if (zkAuthConf != null) {
            return ZKUtil.parseAuth(zkAuthConf);
        } else {
            return Collections.emptyList();
        }
    } catch (Exception e) {
        logger.error("Couldn't read Auth based on 'kylin.env.zookeeper.zk-auth' in kylin.properties");
        throw e;
    }
}
 
Example 10
Source File: ZookeeperAclBuilder.java    From kylin with Apache License 2.0 5 votes vote down vote up
public static List<ACL> getZKAcls() throws Exception {
    // Parse ACLs from configuration.
    String zkAclConf = KylinConfig.getInstanceFromEnv().getZKAcls();
    try {
        zkAclConf = ZKUtil.resolveConfIndirection(zkAclConf);
        return ZKUtil.parseACLs(zkAclConf);
    } catch (Exception e) {
        logger.error("Couldn't read ACLs based on 'kylin.env.zookeeper.zk-acl' in kylin.properties");
        throw e;
    }
}
 
Example 11
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 12
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);
}