本文整理汇总了Java中org.apache.hadoop.conf.Configuration.getValByRegex方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.getValByRegex方法的具体用法?Java Configuration.getValByRegex怎么用?Java Configuration.getValByRegex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.conf.Configuration
的用法示例。
在下文中一共展示了Configuration.getValByRegex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expandEnv
import org.apache.hadoop.conf.Configuration; //导入方法依赖的package包/类
private static void expandEnv(Configuration conf) {
Map<String, String> kvs = conf.getValByRegex("angel.*");
Pattern pattern = Pattern.compile("\\$\\{[\\p{Alnum}\\p{Punct}]+?\\}");
for (Map.Entry<String, String> kv : kvs.entrySet()) {
String value = kv.getValue();
Matcher matcher = pattern.matcher(value);
List<String> keys = new ArrayList<String>();
while (matcher.find()) {
String matchedStr = matcher.group();
keys.add(matchedStr.substring(2, matchedStr.length() - 1));
}
int size = keys.size();
for (int i = 0; i < size; i++) {
String envValue = System.getenv(keys.get(i));
if (envValue == null) {
LOG.warn("env " + keys.get(i) + " is null, please check.");
continue;
}
value = value.replaceAll("\\$\\{" + keys.get(i) + "\\}", envValue);
}
conf.set(kv.getKey(), value);
}
// Add default fs(local fs) for lib jars.
String libJars = conf.get(AngelConf.ANGEL_JOB_LIBJARS);
if (libJars != null) {
StringBuilder sb = new StringBuilder();
String[] jars = libJars.split(",");
for (int i = 0; i < jars.length; i++) {
if (new Path(jars[i]).isAbsoluteAndSchemeAuthorityNull()) {
sb.append("file://").append(jars[i]);
if (i != jars.length - 1) {
sb.append(",");
}
} else {
sb.append(jars[i]);
if (i != jars.length - 1) {
sb.append(",");
}
}
}
conf.set(AngelConf.ANGEL_JOB_LIBJARS, sb.toString());
LOG.info("jars loaded: " + sb.toString());
}
}