Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Run oozie wf with java api parameters

Run oozie wf with java api parameters

New Contributor

Hi All,

 

I'm trying to run oozie workflow with java api, first I have a hive script on hdfs and my wf points to it. I'd like to run it with parameters from Java API.

Here is my code below

 String oozieJobHDFSPath = "hdfs://rpdc/user/hue/oozie/workspaces/hue-oozie-1471864349.89";

    String jobIdOstatki = null;
    OozieClient cl = new OozieClient(OOZIE_URL);
    Properties prop = cl.createConfiguration();


prop.setProperty(cl.APP_PATH, oozieJobHDFSPath );
    prop.setProperty("jobTracker", "10.2.62.178:8050");
    prop.setProperty("queueName", "test");
    prop.setProperty("nameNode", "hdfs://rpdc");
    prop.setProperty("user.name", "hdfs");
    prop.setProperty("oozie.use.system.libpath", "true");
    prop.setProperty("security_enabled", "false");
    prop.setProperty("security.passwords.encryption.enabled", "false");
    prop.setProperty("oozie.action.max.output.data", "8192");


    prop.setProperty("oozie.action.external.stats.param.targetBalancesDB", "test_tmp");
    prop.setProperty("oozie.action.external.stats.param.date", "2016-01-01");
    prop.setProperty("oozie.action.external.stats.param.dictsDB", "test_auto_dicts");


try {
            System.out.println("Getting Job ID Ostatki status");
            jobIdOstatki = cl.run(prop);

while (cl.getJobInfo(jobIdOstatki).getStatus() == WorkflowJob.Status.RUNNING) {
                //System.out.println("Job " +  cl.getJobLog(jobIdOstatki).toString());
                }
}


But I have in action script different picture...

 

<workflow-app name="TestBalancesNew" xmlns="uri:oozie:workflow:0.5">
    <start to="hive-c7a4"/>
    <kill name="Kill">
        <message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>
    <action name="hive-c7a4" cred="hcat">
        <hive xmlns="uri:oozie:hive-action:0.2">
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <script>/user/das/das-etl-1.0.18-SNAPSHOT/scripts/hive/balances/00_balance_data_init.sql</script>
        </hive>
        <ok to="End"/>
        <error to="Kill"/>
    </action>
    <end name="End"/>
</workflow-app>

I can't see any parameters here. How I could pass them through to hive action?

 

Thanks in advance for your help.

2 REPLIES 2

Re: Run oozie wf with java api parameters

Master Guru
Could you clarify further on what the error you observe is? Are you not seeing your ${var} property variables being substituted with the passed properties when invoked via the OozieClient API?

Re: Run oozie wf with java api parameters

New Contributor

Thanks for response, I have already found the solution. I did not provided the params inside the workflow.xml

 

Now it seems works fine for me.

 

Grigory.

Don't have an account?
Coming from Hortonworks? Activate your account here