Java method to create a job in Oozie.

private void submitDispatcherJobForTenantToOozie(String tenantId)
throws OozieClientException {

    // get a OozieClient for local Oozie
    OozieClient wc = new
OozieClient(PropertyValuesProvider.getInstance().getPropValue("oozieURL"));

    // create a workflow job configuration and set the workflow application path
    Properties conf = wc.createConfiguration();
    conf.setProperty(OozieClient.APP_PATH, PropertyValuesProvider.getInstance().
            getPropValue("dispatcherTenantManagerAppPath"));

    // setting workflow parameters
    conf.setProperty("jobTracker", "sandbox.hortonworks.com:8050");
    conf.setProperty("nameNode", "hdfs://sandbox.hortonworks.com:8020");
    conf.setProperty("queueName", "default");
    conf.setProperty("appRoot", "email-dispatcher-tenant-manager-1.0");

    //set tenantId and retention period
    conf.setProperty("tenantId", tenantId);

    // submit and start the workflow job
    String jobId = wc.run(conf);
}


Workfolw.xml of child job:


<workflow-app xmlns="uri:oozie:workflow:0.2" name="java-main-wf">
    <start to="java-node"/>
    <action name="java-node">
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <configuration>
                <property>
                    <name>mapred.job.queue.name</name>
                    <value>${queueName}</value>
                </property>
            </configuration>
            <main-class>com.MainClass</main-class>
        </java>
        <ok to="end"/>
        <error to="fail"/>
    </action>
    <kill name="fail">
        <message>Java failed, error
message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>
    <end name="end"/>
</workflow-app>



On Wed, Jan 13, 2016 at 6:00 PM, Hanmay Udgiri <[email protected]>
wrote:

> Can u share the workflow.xml or the java code?
> On 13-Jan-2016 17:34, "Asanka Sanjaya Herath" <[email protected]> wrote:
>
> > Hi Hanmayya,
> >
> > I followed the given link but it failed to spawn new Oozie jobs. But
> when I
> > run the same program directly using yarn jar command It spawns the jobs
> in
> > Oozie. The yarn log is not giving any errors too.
> >
> > On Wed, Jan 13, 2016 at 11:42 AM, Asanka Sanjaya Herath <
> > [email protected]>
> > wrote:
> >
> > > Hi Hanmayya,
> > >
> > > Thank you for the response. I'll follow the given link and update
> status.
> > >
> > > ​
> > >> Do you want to execute multiple Oozie workflows from the Java class?​
> > >
> > >
> > > No I want to execute set of instances of one Oozie workflow.
> > >
> > >
> > > On Wed, Jan 13, 2016 at 10:43 AM, Hanmay Udgiri <
> > [email protected]
> > > > wrote:
> > >
> > >> You can use OozieClient Java class.
> > >>
> > >>
> > >>
> >
> http://www.hadooped.blogspot.in/2013/06/apache-oozie-part-8-java-api-for.html
> > >>
> > >> Do you want to execute multiple Oozie workflows from the Java class?
> > >>
> > >> Thanks
> > >> Hanmayya
> > >>
> > >> On Wed, Jan 13, 2016 at 9:57 AM, Asanka Sanjaya Herath <
> > >> [email protected]>
> > >> wrote:
> > >>
> > >> > Hi,
> > >> >
> > >> > I'm writing a simple Java Oozie job. That job is supposed to spawn
> new
> > >> > Oozie jobs or directly submit new jobs to Hadoop. Is there a way to
> > >> achieve
> > >> > this using Oozie API?
> > >> >
> > >> > --
> > >> > Thanks,
> > >> > Regards,
> > >> > ASH
> > >> >
> > >>
> > >>
> > >>
> > >> --
> > >> Thanks and Regards
> > >> Hanmayya Udgiri
> > >>
> > >
> > >
> > >
> > > --
> > > Thanks,
> > > Regards,
> > > ASH
> > >
> >
> >
> >
> > --
> > Thanks,
> > Regards,
> > ASH
> >
>



-- 
Thanks,
Regards,
ASH

Reply via email to