You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@oozie.apache.org by St...@us.sogeti.com on 2012/06/21 18:19:37 UTC

question on how Java class from workflow action reads properties

If I have a workflow Java action similar as follows, setting configuration properties:
    <action name='some_task'>
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <configuration>
                <property>
                    <name>mapred.job.queue.name</name>
                    <value>${queueName}</value>
                </property>
                <property>
                    <name>user</name>
                    <value>${user}</value>
                </property>
                <property>
                    <name>oozieServer</name>
                    <value>${oozieServer}</value>
                </property>
                <property>
                    <name>configLocation</name>
                    <value>${configLocation}</value>

 
In the Java class specified in the action, how do I read those configuration properties? I found they don't get passed as system/command line properties.
 
Thanks.
 
 
 
 
Steve 
Sogeti USA
3636 N. Central Ave.
#810
Phoenix, AZ 85012
www.us.sogeti.com <http://www.us.sogeti.com/>  
 

Re: question on how Java class from workflow action reads properties

Posted by Alejandro Abdelnur <tu...@cloudera.com>.
Steve,

the JVM runs out of the cluster node, and files are localized to that node.
Thus you should use the Java File API not the Hadoop FileSystem API.

hope this helps.

thx

On Fri, Jun 22, 2012 at 12:21 PM, <St...@us.sogeti.com> wrote:

> Yes I was. Isn't the Java class running on a JVM in the HDFS?
>
> Steve Charles
>
>
> ________________________________
>
> From: Mona Chitnis [mailto:chitnis@yahoo-inc.com]
> Sent: Fri 6/22/2012 11:45 AM
> To: oozie-users@incubator.apache.org
> Subject: Re: question on how Java class from workflow action reads
> properties
>
>
>
> Steve,
>
> Yes the property will point to a local file in the your Java application's
> working directory. It is not on HDFS. Are you using the Hadoop FileSystem
> API to open this file?
>
>
> --
> Mona Chitnis
>
>
>
>
> On 6/22/12 10:08 AM, "Steve.Charles@us.sogeti.com"
> <St...@us.sogeti.com> wrote:
>
> >Alejandro,
> >Thanks. So are the configuration properties passed to the Java class in
> >the workflow supposed to be in an xml file specified by
> >'oozie.action.conf.xml '? And that xml file will exist on the HDFS when
> >the Java class runs?
> >If so, in my Java class did:
> >String oozieProps = System.getProperty("oozie.action.conf.xml");
> >
> >It did return a path to an XML, but when it tried to open/read the file,
> >it got an IO exception that it did not exist.
> >Steve
> >
> >
> >
> >
> >________________________________
> >
> >From: Alejandro Abdelnur [mailto:tucu@cloudera.com]
> >Sent: Thu 6/21/2012 9:41 AM
> >To: oozie-users@incubator.apache.org
> >Subject: Re: question on how Java class from workflow action reads
> >properties
> >
> >
> >
> >Hi Steve,
> >
> >From Mona's Java Cookbook doc which is not live yet:
> >
> >-----
> >
> >        Within your Java Main class, you can query for the following
> >system
> >properties pertaining to your Oozie job.
> >
> >        * oozie.job.id : Workflow ID
> >
> >        * oozie.action.id : Action ID
> >
> >        * oozie.action.conf.xml : local path to the resolved action
> >configuration
> >
> >        * oozie.action.output.properties : Action properties output as a
> >Java Properties file
> >
> >-----
> >
> >HTH
> >
> >Thx
> >
> >Alejandro
> >
> >
> >
> >On Thu, Jun 21, 2012 at 9:19 AM, <St...@us.sogeti.com> wrote:
> >
> >> If I have a workflow Java action similar as follows, setting
> >>configuration
> >> properties:
> >>    <action name='some_task'>
> >>        <java>
> >>            <job-tracker>${jobTracker}</job-tracker>
> >>            <name-node>${nameNode}</name-node>
> >>            <configuration>
> >>                <property>
> >>                    <name>mapred.job.queue.name</name>
> >>                    <value>${queueName}</value>
> >>                </property>
> >>                <property>
> >>                    <name>user</name>
> >>                    <value>${user}</value>
> >>                </property>
> >>                <property>
> >>                    <name>oozieServer</name>
> >>                    <value>${oozieServer}</value>
> >>                </property>
> >>                <property>
> >>                    <name>configLocation</name>
> >>                    <value>${configLocation}</value>
> >>
> >>
> >> In the Java class specified in the action, how do I read those
> >> configuration properties? I found they don't get passed as
> >>system/command
> >> line properties.
> >>
> >> Thanks.
> >>
> >>
> >>
> >>
> >> Steve
> >> Sogeti USA
> >> 3636 N. Central Ave.
> >> #810
> >> Phoenix, AZ 85012
> >> www.us.sogeti.com <http://www.us.sogeti.com/>
> >>
> >>
> >
> >
> >--
> >Alejandro
> >
> >
>
>
>
>
>


-- 
Alejandro

RE: question on how Java class from workflow action reads properties

Posted by St...@us.sogeti.com.
Yes I was. Isn't the Java class running on a JVM in the HDFS? 
 
Steve Charles
 

________________________________

From: Mona Chitnis [mailto:chitnis@yahoo-inc.com]
Sent: Fri 6/22/2012 11:45 AM
To: oozie-users@incubator.apache.org
Subject: Re: question on how Java class from workflow action reads properties



Steve,

Yes the property will point to a local file in the your Java application's
working directory. It is not on HDFS. Are you using the Hadoop FileSystem
API to open this file?


--
Mona Chitnis




On 6/22/12 10:08 AM, "Steve.Charles@us.sogeti.com"
<St...@us.sogeti.com> wrote:

>Alejandro,
>Thanks. So are the configuration properties passed to the Java class in
>the workflow supposed to be in an xml file specified by
>'oozie.action.conf.xml '? And that xml file will exist on the HDFS when
>the Java class runs?
>If so, in my Java class did:
>String oozieProps = System.getProperty("oozie.action.conf.xml");
>
>It did return a path to an XML, but when it tried to open/read the file,
>it got an IO exception that it did not exist.
>Steve
>
>
>
>
>________________________________
>
>From: Alejandro Abdelnur [mailto:tucu@cloudera.com]
>Sent: Thu 6/21/2012 9:41 AM
>To: oozie-users@incubator.apache.org
>Subject: Re: question on how Java class from workflow action reads
>properties
>
>
>
>Hi Steve,
>
>From Mona's Java Cookbook doc which is not live yet:
>
>-----
>
>        Within your Java Main class, you can query for the following
>system
>properties pertaining to your Oozie job.
>
>        * oozie.job.id : Workflow ID
>
>        * oozie.action.id : Action ID
>
>        * oozie.action.conf.xml : local path to the resolved action
>configuration
>
>        * oozie.action.output.properties : Action properties output as a
>Java Properties file
>
>-----
>
>HTH
>
>Thx
>
>Alejandro
>
>
>
>On Thu, Jun 21, 2012 at 9:19 AM, <St...@us.sogeti.com> wrote:
>
>> If I have a workflow Java action similar as follows, setting
>>configuration
>> properties:
>>    <action name='some_task'>
>>        <java>
>>            <job-tracker>${jobTracker}</job-tracker>
>>            <name-node>${nameNode}</name-node>
>>            <configuration>
>>                <property>
>>                    <name>mapred.job.queue.name</name>
>>                    <value>${queueName}</value>
>>                </property>
>>                <property>
>>                    <name>user</name>
>>                    <value>${user}</value>
>>                </property>
>>                <property>
>>                    <name>oozieServer</name>
>>                    <value>${oozieServer}</value>
>>                </property>
>>                <property>
>>                    <name>configLocation</name>
>>                    <value>${configLocation}</value>
>>
>>
>> In the Java class specified in the action, how do I read those
>> configuration properties? I found they don't get passed as
>>system/command
>> line properties.
>>
>> Thanks.
>>
>>
>>
>>
>> Steve
>> Sogeti USA
>> 3636 N. Central Ave.
>> #810
>> Phoenix, AZ 85012
>> www.us.sogeti.com <http://www.us.sogeti.com/>
>>
>>
>
>
>--
>Alejandro
>
>





Re: question on how Java class from workflow action reads properties

Posted by Mona Chitnis <ch...@yahoo-inc.com>.
Steve,

Yes the property will point to a local file in the your Java application's
working directory. It is not on HDFS. Are you using the Hadoop FileSystem
API to open this file?


--
Mona Chitnis




On 6/22/12 10:08 AM, "Steve.Charles@us.sogeti.com"
<St...@us.sogeti.com> wrote:

>Alejandro,
>Thanks. So are the configuration properties passed to the Java class in
>the workflow supposed to be in an xml file specified by
>'oozie.action.conf.xml '? And that xml file will exist on the HDFS when
>the Java class runs?
>If so, in my Java class did:
>String oozieProps = System.getProperty("oozie.action.conf.xml");
>
>It did return a path to an XML, but when it tried to open/read the file,
>it got an IO exception that it did not exist.
>Steve
> 
> 
>
>
>________________________________
>
>From: Alejandro Abdelnur [mailto:tucu@cloudera.com]
>Sent: Thu 6/21/2012 9:41 AM
>To: oozie-users@incubator.apache.org
>Subject: Re: question on how Java class from workflow action reads
>properties
>
>
>
>Hi Steve,
>
>From Mona's Java Cookbook doc which is not live yet:
>
>-----
>
>        Within your Java Main class, you can query for the following
>system
>properties pertaining to your Oozie job.
>
>        * oozie.job.id : Workflow ID
>
>        * oozie.action.id : Action ID
>
>        * oozie.action.conf.xml : local path to the resolved action
>configuration
>
>        * oozie.action.output.properties : Action properties output as a
>Java Properties file
>
>-----
>
>HTH
>
>Thx
>
>Alejandro
>
>
>
>On Thu, Jun 21, 2012 at 9:19 AM, <St...@us.sogeti.com> wrote:
>
>> If I have a workflow Java action similar as follows, setting
>>configuration
>> properties:
>>    <action name='some_task'>
>>        <java>
>>            <job-tracker>${jobTracker}</job-tracker>
>>            <name-node>${nameNode}</name-node>
>>            <configuration>
>>                <property>
>>                    <name>mapred.job.queue.name</name>
>>                    <value>${queueName}</value>
>>                </property>
>>                <property>
>>                    <name>user</name>
>>                    <value>${user}</value>
>>                </property>
>>                <property>
>>                    <name>oozieServer</name>
>>                    <value>${oozieServer}</value>
>>                </property>
>>                <property>
>>                    <name>configLocation</name>
>>                    <value>${configLocation}</value>
>>
>>
>> In the Java class specified in the action, how do I read those
>> configuration properties? I found they don't get passed as
>>system/command
>> line properties.
>>
>> Thanks.
>>
>>
>>
>>
>> Steve
>> Sogeti USA
>> 3636 N. Central Ave.
>> #810
>> Phoenix, AZ 85012
>> www.us.sogeti.com <http://www.us.sogeti.com/>
>>
>>
>
>
>--
>Alejandro
>
>


RE: question on how Java class from workflow action reads properties

Posted by St...@us.sogeti.com.
Alejandro,
Thanks. So are the configuration properties passed to the Java class in the workflow supposed to be in an xml file specified by 'oozie.action.conf.xml '? And that xml file will exist on the HDFS when the Java class runs?
If so, in my Java class did:
String oozieProps = System.getProperty("oozie.action.conf.xml");

It did return a path to an XML, but when it tried to open/read the file, it got an IO exception that it did not exist.
Steve
 
 


________________________________

From: Alejandro Abdelnur [mailto:tucu@cloudera.com]
Sent: Thu 6/21/2012 9:41 AM
To: oozie-users@incubator.apache.org
Subject: Re: question on how Java class from workflow action reads properties



Hi Steve,

>From Mona's Java Cookbook doc which is not live yet:

-----

        Within your Java Main class, you can query for the following system
properties pertaining to your Oozie job.

        * oozie.job.id : Workflow ID

        * oozie.action.id : Action ID

        * oozie.action.conf.xml : local path to the resolved action
configuration

        * oozie.action.output.properties : Action properties output as a
Java Properties file

-----

HTH

Thx

Alejandro



On Thu, Jun 21, 2012 at 9:19 AM, <St...@us.sogeti.com> wrote:

> If I have a workflow Java action similar as follows, setting configuration
> properties:
>    <action name='some_task'>
>        <java>
>            <job-tracker>${jobTracker}</job-tracker>
>            <name-node>${nameNode}</name-node>
>            <configuration>
>                <property>
>                    <name>mapred.job.queue.name</name>
>                    <value>${queueName}</value>
>                </property>
>                <property>
>                    <name>user</name>
>                    <value>${user}</value>
>                </property>
>                <property>
>                    <name>oozieServer</name>
>                    <value>${oozieServer}</value>
>                </property>
>                <property>
>                    <name>configLocation</name>
>                    <value>${configLocation}</value>
>
>
> In the Java class specified in the action, how do I read those
> configuration properties? I found they don't get passed as system/command
> line properties.
>
> Thanks.
>
>
>
>
> Steve
> Sogeti USA
> 3636 N. Central Ave.
> #810
> Phoenix, AZ 85012
> www.us.sogeti.com <http://www.us.sogeti.com/>
>
>


--
Alejandro



Re: question on how Java class from workflow action reads properties

Posted by Alejandro Abdelnur <tu...@cloudera.com>.
Hi Steve,

>From Mona's Java Cookbook doc which is not live yet:

-----

        Within your Java Main class, you can query for the following system
properties pertaining to your Oozie job.

        * oozie.job.id : Workflow ID

        * oozie.action.id : Action ID

        * oozie.action.conf.xml : local path to the resolved action
configuration

        * oozie.action.output.properties : Action properties output as a
Java Properties file

-----

HTH

Thx

Alejandro



On Thu, Jun 21, 2012 at 9:19 AM, <St...@us.sogeti.com> wrote:

> If I have a workflow Java action similar as follows, setting configuration
> properties:
>    <action name='some_task'>
>        <java>
>            <job-tracker>${jobTracker}</job-tracker>
>            <name-node>${nameNode}</name-node>
>            <configuration>
>                <property>
>                    <name>mapred.job.queue.name</name>
>                    <value>${queueName}</value>
>                </property>
>                <property>
>                    <name>user</name>
>                    <value>${user}</value>
>                </property>
>                <property>
>                    <name>oozieServer</name>
>                    <value>${oozieServer}</value>
>                </property>
>                <property>
>                    <name>configLocation</name>
>                    <value>${configLocation}</value>
>
>
> In the Java class specified in the action, how do I read those
> configuration properties? I found they don't get passed as system/command
> line properties.
>
> Thanks.
>
>
>
>
> Steve
> Sogeti USA
> 3636 N. Central Ave.
> #810
> Phoenix, AZ 85012
> www.us.sogeti.com <http://www.us.sogeti.com/>
>
>


-- 
Alejandro