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

rryofs0p  于 2021-05-30  发布在  Hadoop
关注(0)|答案(1)|浏览(389)

我正在尝试访问一个通过oozie java action配置设置的属性,但是我没有得到我想要的值,不知道是否可以在这方面得到任何帮助?
我的工作流程

...........
<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中没有任何值填充。我试图进入酒店的方式有什么问题吗?
请帮忙

nmpmafwu

nmpmafwu1#

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")
...

应该有用。

相关问题