gpt4 book ai didi

java - 无法从 oozie.action.conf.xml 检索属性

转载 作者:可可西里 更新时间:2023-11-01 16:31:41 27 4
gpt4 key购买 nike

我正在尝试访问通过 oozie java 操作配置设置的属性,但我没有得到我正在寻找的值,想知道我是否可以获得任何帮助?

我的工作流程

...........
<action name="ref-record-load">
<java>
<configuration>
<property>
<name>oozie.launcher.mapred.child.java.opts</name>
<value>-Xmx4g -XX:MaxPermSize=256m</value>
</property>
<property>
<name>load.type</name>
<value>full</value>
</property>
</configuration>
.............

我正在尝试通过以下方式从我的代码中访问此属性

        oozieConfigFile = System.getProperty("oozie.action.conf.xml");
final FileInputStream inputStream = new FileInputStream(oozieConfigFile);
final Properties oozieConfigProperties = new Properties();
oozieConfigProperties.loadFromXML(inputStream);
loadType = oozieConfigProperties.getProperty("load.type");

但我没有在 loadType 中看到任何值。我尝试访问该属性的方式有问题吗?

请帮忙

最佳答案

xml 文件在那里。但是它无法通过 loadFromXML() 加载。尝试使用 hadoop 配置类:

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
...
Configuration conf = new Configuration(false);
conf.addResource(new Path(System.getProperty("oozie.action.conf.xml")));
String loadType = conf.get("load.type")
...

它应该可以工作。

关于java - 无法从 oozie.action.conf.xml 检索属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28969637/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com