You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@oozie.apache.org by Kashif Hussain <ka...@gmail.com> on 2017/04/08 19:00:05 UTC

OOzie java api

Hi,

I want to run a java action once every day.I have created a coordinator
which executes the workflow containing the action 4 times every day.
Normal scenario would be that the workflow runs successfully in first
run.In the next runs it will run only if the previous run on the same day
failed.
I am writing a java action for performing this.The java program needs to
get the previous workflow of the coordinator to take the decision to
execute the next java action(which contains logic).

How can I achieve this ? What classes and methods can I use ?
I tried to go through the documentation of the api but it is very short. I
am still confused.Please help.

Regards,
Kashif

Re: OOzie java api

Posted by goun na <go...@gmail.com>.
Kashif Hussain,

If you are working on the same job and the next three schedules are just
for recovery, you can schedule it once a day by setting retry options in
workflow.
User-retry for workflow actions are available since Oozie 3.1 with the
following syntax.

<workflow-app xmlns="uri:oozie:workflow:0.3" name="wf-name">
<action name="a" retry-max="2" retry-interval="1">
</action>

- Goun

2017-04-09 14:31 GMT+09:00 Per Ullberg <pe...@klarna.com>:

> I think we use all three approaches in different workflows. :)
>
> Pick whatever works for you. If you care about testability, then java is
> the most testable, and fs action the least.
>
> If you care about readability and LOC, the fs action is the best one...
>
> Regards
> /pelle
>
> On Sun 9 Apr 2017 at 00:31 Kashif Hussain <ka...@gmail.com> wrote:
>
> > Great.That's a clean way to achieve what i want.
> > One more thing. Are you creating this file though java action or shell
> > action or fs action ?
> >
> > On Sun, Apr 9, 2017 at 1:19 AM, Per Ullberg <pe...@klarna.com>
> > wrote:
> >
> > > Hi,
> > >
> > > This is how we do it:
> > >
> > > Let the successful workflow create an empty file with a deterministic
> > path
> > > based on today's date. Like /some_root/${YEAR}${MONTH}${DAY}/_SUCCESS
> > >
> > > Then you use a decision node in your workflow that looks for the file
> > using
> > > fs:exists. If it's there, then don't execute further, if it's not
> there,
> > > then run your actions.
> > >
> > > /pelle
> > >
> > >
> > > On Sat 8 Apr 2017 at 21:00 Kashif Hussain <ka...@gmail.com> wrote:
> > >
> > > > Hi,
> > > >
> > > > I want to run a java action once every day.I have created a
> coordinator
> > > > which executes the workflow containing the action 4 times every day.
> > > > Normal scenario would be that the workflow runs successfully in first
> > > > run.In the next runs it will run only if the previous run on the same
> > day
> > > > failed.
> > > > I am writing a java action for performing this.The java program needs
> > to
> > > > get the previous workflow of the coordinator to take the decision to
> > > > execute the next java action(which contains logic).
> > > >
> > > > How can I achieve this ? What classes and methods can I use ?
> > > > I tried to go through the documentation of the api but it is very
> > short.
> > > I
> > > > am still confused.Please help.
> > > >
> > > > Regards,
> > > > Kashif
> > > >
> > > --
> > >
> > > *Per Ullberg*
> > > Data Vault Tech Lead
> > > Odin Uppsala
> > > +46 701612693 <javascript:void(0);>
> > >
> > > Klarna AB (publ)
> > > Sveavägen 46, 111 34 Stockholm
> > > Tel: +46 8 120 120 00 <javascript:void(0);>
> > > Reg no: 556737-0431
> > > klarna.com
> > >
> >
> --
>
> *Per Ullberg*
> Data Vault Tech Lead
> Odin Uppsala
> +46 701612693 <javascript:void(0);>
>
> Klarna AB (publ)
> Sveavägen 46, 111 34 Stockholm
> Tel: +46 8 120 120 00 <javascript:void(0);>
> Reg no: 556737-0431
> klarna.com
>

Re: OOzie java api

Posted by Per Ullberg <pe...@klarna.com>.
I think we use all three approaches in different workflows. :)

Pick whatever works for you. If you care about testability, then java is
the most testable, and fs action the least.

If you care about readability and LOC, the fs action is the best one...

Regards
/pelle

On Sun 9 Apr 2017 at 00:31 Kashif Hussain <ka...@gmail.com> wrote:

> Great.That's a clean way to achieve what i want.
> One more thing. Are you creating this file though java action or shell
> action or fs action ?
>
> On Sun, Apr 9, 2017 at 1:19 AM, Per Ullberg <pe...@klarna.com>
> wrote:
>
> > Hi,
> >
> > This is how we do it:
> >
> > Let the successful workflow create an empty file with a deterministic
> path
> > based on today's date. Like /some_root/${YEAR}${MONTH}${DAY}/_SUCCESS
> >
> > Then you use a decision node in your workflow that looks for the file
> using
> > fs:exists. If it's there, then don't execute further, if it's not there,
> > then run your actions.
> >
> > /pelle
> >
> >
> > On Sat 8 Apr 2017 at 21:00 Kashif Hussain <ka...@gmail.com> wrote:
> >
> > > Hi,
> > >
> > > I want to run a java action once every day.I have created a coordinator
> > > which executes the workflow containing the action 4 times every day.
> > > Normal scenario would be that the workflow runs successfully in first
> > > run.In the next runs it will run only if the previous run on the same
> day
> > > failed.
> > > I am writing a java action for performing this.The java program needs
> to
> > > get the previous workflow of the coordinator to take the decision to
> > > execute the next java action(which contains logic).
> > >
> > > How can I achieve this ? What classes and methods can I use ?
> > > I tried to go through the documentation of the api but it is very
> short.
> > I
> > > am still confused.Please help.
> > >
> > > Regards,
> > > Kashif
> > >
> > --
> >
> > *Per Ullberg*
> > Data Vault Tech Lead
> > Odin Uppsala
> > +46 701612693 <javascript:void(0);>
> >
> > Klarna AB (publ)
> > Sveavägen 46, 111 34 Stockholm
> > Tel: +46 8 120 120 00 <javascript:void(0);>
> > Reg no: 556737-0431
> > klarna.com
> >
>
-- 

*Per Ullberg*
Data Vault Tech Lead
Odin Uppsala
+46 701612693 <javascript:void(0);>

Klarna AB (publ)
Sveavägen 46, 111 34 Stockholm
Tel: +46 8 120 120 00 <javascript:void(0);>
Reg no: 556737-0431
klarna.com

Re: OOzie java api

Posted by Kashif Hussain <ka...@gmail.com>.
Great.That's a clean way to achieve what i want.
One more thing. Are you creating this file though java action or shell
action or fs action ?

On Sun, Apr 9, 2017 at 1:19 AM, Per Ullberg <pe...@klarna.com> wrote:

> Hi,
>
> This is how we do it:
>
> Let the successful workflow create an empty file with a deterministic path
> based on today's date. Like /some_root/${YEAR}${MONTH}${DAY}/_SUCCESS
>
> Then you use a decision node in your workflow that looks for the file using
> fs:exists. If it's there, then don't execute further, if it's not there,
> then run your actions.
>
> /pelle
>
>
> On Sat 8 Apr 2017 at 21:00 Kashif Hussain <ka...@gmail.com> wrote:
>
> > Hi,
> >
> > I want to run a java action once every day.I have created a coordinator
> > which executes the workflow containing the action 4 times every day.
> > Normal scenario would be that the workflow runs successfully in first
> > run.In the next runs it will run only if the previous run on the same day
> > failed.
> > I am writing a java action for performing this.The java program needs to
> > get the previous workflow of the coordinator to take the decision to
> > execute the next java action(which contains logic).
> >
> > How can I achieve this ? What classes and methods can I use ?
> > I tried to go through the documentation of the api but it is very short.
> I
> > am still confused.Please help.
> >
> > Regards,
> > Kashif
> >
> --
>
> *Per Ullberg*
> Data Vault Tech Lead
> Odin Uppsala
> +46 701612693 <javascript:void(0);>
>
> Klarna AB (publ)
> Sveavägen 46, 111 34 Stockholm
> Tel: +46 8 120 120 00 <javascript:void(0);>
> Reg no: 556737-0431
> klarna.com
>

Re: OOzie java api

Posted by Per Ullberg <pe...@klarna.com>.
Hi,

This is how we do it:

Let the successful workflow create an empty file with a deterministic path
based on today's date. Like /some_root/${YEAR}${MONTH}${DAY}/_SUCCESS

Then you use a decision node in your workflow that looks for the file using
fs:exists. If it's there, then don't execute further, if it's not there,
then run your actions.

/pelle


On Sat 8 Apr 2017 at 21:00 Kashif Hussain <ka...@gmail.com> wrote:

> Hi,
>
> I want to run a java action once every day.I have created a coordinator
> which executes the workflow containing the action 4 times every day.
> Normal scenario would be that the workflow runs successfully in first
> run.In the next runs it will run only if the previous run on the same day
> failed.
> I am writing a java action for performing this.The java program needs to
> get the previous workflow of the coordinator to take the decision to
> execute the next java action(which contains logic).
>
> How can I achieve this ? What classes and methods can I use ?
> I tried to go through the documentation of the api but it is very short. I
> am still confused.Please help.
>
> Regards,
> Kashif
>
-- 

*Per Ullberg*
Data Vault Tech Lead
Odin Uppsala
+46 701612693 <javascript:void(0);>

Klarna AB (publ)
Sveavägen 46, 111 34 Stockholm
Tel: +46 8 120 120 00 <javascript:void(0);>
Reg no: 556737-0431
klarna.com