Praveen Reddy Katta
Praveen Reddy Katta

Reputation: 303

Unable to retrieve a property from oozie.action.conf.xml

I am trying to access a property that is set through oozie java action configuration but I am not getting the value I was looking for, wondering if I can get any help on this?

My workflow

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

and I am trying to access this property from my code in the following way

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

But I don't see any value populated in loadType. Is there something wrong in the way I am trying to access the property?

Please help

Upvotes: 0

Views: 1577

Answers (1)

Paul H.
Paul H.

Reputation: 1074

The xml file is there. However it couldn't be loaded by loadFromXML(). Try use hadoop configuraion class:

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

It should work.

Upvotes: 2

Related Questions