com.alibaba.datax.common.util.Configuration.getKeys()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(179)

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

Configuration.getKeys介绍

[英]获取Configuration下所有叶子节点的key

对于

{"a": {"b": {"c": [0,1,2,3]}}, "x": "y"}

下属的key包括: a.b.c[0],a.b.c[1],a.b.c[2],a.b.c[3],x
[中]

代码示例

代码示例来源:origin: ECNU-1X/DataX-Masking

public DFSUtil(Configuration taskConfig) {
  hadoopConf = new org.apache.hadoop.conf.Configuration();
  //io.file.buffer.size 性能参数
  //http://blog.csdn.net/yangjl38/article/details/7583374
  Configuration hadoopSiteParams = taskConfig.getConfiguration(Key.HADOOP_CONFIG);
  JSONObject hadoopSiteParamsAsJsonObject = JSON.parseObject(taskConfig.getString(Key.HADOOP_CONFIG));
  if (null != hadoopSiteParams) {
    Set<String> paramKeys = hadoopSiteParams.getKeys();
    for (String each : paramKeys) {
      hadoopConf.set(each, hadoopSiteParamsAsJsonObject.getString(each));
    }
  }
  hadoopConf.set(HDFS_DEFAULTFS_KEY, taskConfig.getString(Key.DEFAULT_FS));
  //是否有Kerberos认证
  this.haveKerberos = taskConfig.getBool(Key.HAVE_KERBEROS, false);
  if (haveKerberos) {
    this.kerberosKeytabFilePath = taskConfig.getString(Key.KERBEROS_KEYTAB_FILE_PATH);
    this.kerberosPrincipal = taskConfig.getString(Key.KERBEROS_PRINCIPAL);
    this.hadoopConf.set(HADOOP_SECURITY_AUTHENTICATION_KEY, "kerberos");
  }
  this.kerberosAuthentication(this.kerberosPrincipal, this.kerberosKeytabFilePath);
  LOG.info(String.format("hadoopConfig details:%s", JSON.toJSONString(this.hadoopConf)));
}

代码示例来源:origin: ECNU-1X/DataX-Masking

public static Configuration filterSensitiveConfiguration(Configuration configuration){
  Set<String> keys = configuration.getKeys();
  for (final String key : keys) {
    boolean isSensitive = StringUtils.endsWithIgnoreCase(key, "password")
        || StringUtils.endsWithIgnoreCase(key, "accessKey");
    if (isSensitive && configuration.get(key) instanceof String) {
      configuration.set(key, configuration.getString(key).replaceAll(".", "*"));
    }
  }
  return configuration;
}

代码示例来源:origin: ECNU-1X/DataX-Masking

JSONObject hadoopSiteParamsAsJsonObject = JSON.parseObject(taskConfig.getString(Key.HADOOP_CONFIG));
if (null != hadoopSiteParams) {
  Set<String> paramKeys = hadoopSiteParams.getKeys();
  for (String each : paramKeys) {
    hadoopConf.set(each, hadoopSiteParamsAsJsonObject.getString(each));

代码示例来源:origin: ECNU-1X/DataX-Masking

for (String key : config.getKeys()) {
  int lastPathIndex = key.lastIndexOf(".") + 1;
  String lastPathKey = key.substring(lastPathIndex);

代码示例来源:origin: ECNU-1X/DataX-Masking

/**
 * 合并其他Configuration,并修改两者冲突的KV配置
 * 
 * @param another
 *            合并加入的第三方Configuration
 * @param updateWhenConflict
 *            当合并双方出现KV冲突时候,选择更新当前KV,或者忽略该KV
 * @return 返回合并后对象
 */
public Configuration merge(final Configuration another,
    boolean updateWhenConflict) {
  Set<String> keys = another.getKeys();
  for (final String key : keys) {
    // 如果使用更新策略,凡是another存在的key,均需要更新
    if (updateWhenConflict) {
      this.set(key, another.get(key));
      continue;
    }
    // 使用忽略策略,只有another Configuration存在但是当前Configuration不存在的key,才需要更新
    boolean isCurrentExists = this.get(key) != null;
    if (isCurrentExists) {
      continue;
    }
    this.set(key, another.get(key));
  }
  return this;
}

相关文章