You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Caizhi Weng <ts...@gmail.com> on 2020/05/08 06:47:28 UTC

What's the best practice to determine whether a job has finished or not?

Hi dear Flink community,

I would like to determine whether a job has finished (no matter
successfully or exceptionally) in my code.

I used to think that JobClient#getJobStatus is a good idea, but I found
that it behaves quite differently under different executing environments.
For example, under a standalone session cluster it will return the FINISHED
status for a finished job, while under a yarn per job cluster it will throw
a ApplicationNotFound exception. I'm afraid that there might be other
behaviors for other environments.

So what's the best practice to determine whether a job has finished or not?
Note that I'm not waiting for the job to finish. If the job hasn't finished
I would like to know it and do something else.

Re: What's the best practice to determine whether a job has finished or not?

Posted by Till Rohrmann <tr...@apache.org>.
For that attached YARN per-job mode, the cluster should wait until the
result of the job has been fetched. Can't this be used to report the final
status of the job?

Cheers,
Till

On Tue, May 12, 2020 at 9:52 AM Aljoscha Krettek <al...@apache.org>
wrote:

> Hi,
>
> The problem is that the JobClient is talking to the wrong system. In YARN
> per-job mode the cluster will only run as long as the job runs so there
> will be no-one there to respond with the job status after the job is
> finished.
>
> I think the solution is that the JobClient should talk to the right
> system, in the YARN example it should talk directly to YARN for figuring
> out the job status (and maybe for other things as well).
>
> Best,
> Aljoscha
>
> On Fri, May 8, 2020, at 15:05, Kurt Young wrote:
> > +dev <de...@flink.apache.org>
> >
> > Best,
> > Kurt
> >
> >
> > On Fri, May 8, 2020 at 3:35 PM Caizhi Weng <ts...@gmail.com> wrote:
> >
> > > Hi Jeff,
> > >
> > > Thanks for the response. However I'm using executeAsync so that I can
> run
> > > the job asynchronously and get a JobClient to monitor the job.
> JobListener
> > > only works for synchronous execute method. Is there other way to
> achieve
> > > this?
> > >
> > > Jeff Zhang <zj...@gmail.com> 于2020年5月8日周五 下午3:29写道:
> > >
> > >> I use JobListener#onJobExecuted to be notified that the flink job is
> > >> done.
> > >> It is pretty reliable for me, the only exception is the client
> process is
> > >> down.
> > >>
> > >> BTW, the reason you see ApplicationNotFound exception is that yarn app
> > >> is terminated which means the flink cluster is shutdown. While for
> > >> standalone mode, the flink cluster is always up.
> > >>
> > >>
> > >> Caizhi Weng <ts...@gmail.com> 于2020年5月8日周五 下午2:47写道:
> > >>
> > >>> Hi dear Flink community,
> > >>>
> > >>> I would like to determine whether a job has finished (no matter
> > >>> successfully or exceptionally) in my code.
> > >>>
> > >>> I used to think that JobClient#getJobStatus is a good idea, but I
> found
> > >>> that it behaves quite differently under different executing
> environments.
> > >>> For example, under a standalone session cluster it will return the
> FINISHED
> > >>> status for a finished job, while under a yarn per job cluster it
> will throw
> > >>> a ApplicationNotFound exception. I'm afraid that there might be other
> > >>> behaviors for other environments.
> > >>>
> > >>> So what's the best practice to determine whether a job has finished
> or
> > >>> not? Note that I'm not waiting for the job to finish. If the job
> hasn't
> > >>> finished I would like to know it and do something else.
> > >>>
> > >>
> > >>
> > >> --
> > >> Best Regards
> > >>
> > >> Jeff Zhang
> > >>
> > >
> >
>

Re: What's the best practice to determine whether a job has finished or not?

Posted by Aljoscha Krettek <al...@apache.org>.
Hi,

The problem is that the JobClient is talking to the wrong system. In YARN per-job mode the cluster will only run as long as the job runs so there will be no-one there to respond with the job status after the job is finished.

I think the solution is that the JobClient should talk to the right system, in the YARN example it should talk directly to YARN for figuring out the job status (and maybe for other things as well).

Best,
Aljoscha

On Fri, May 8, 2020, at 15:05, Kurt Young wrote:
> +dev <de...@flink.apache.org>
> 
> Best,
> Kurt
> 
> 
> On Fri, May 8, 2020 at 3:35 PM Caizhi Weng <ts...@gmail.com> wrote:
> 
> > Hi Jeff,
> >
> > Thanks for the response. However I'm using executeAsync so that I can run
> > the job asynchronously and get a JobClient to monitor the job. JobListener
> > only works for synchronous execute method. Is there other way to achieve
> > this?
> >
> > Jeff Zhang <zj...@gmail.com> 于2020年5月8日周五 下午3:29写道:
> >
> >> I use JobListener#onJobExecuted to be notified that the flink job is
> >> done.
> >> It is pretty reliable for me, the only exception is the client process is
> >> down.
> >>
> >> BTW, the reason you see ApplicationNotFound exception is that yarn app
> >> is terminated which means the flink cluster is shutdown. While for
> >> standalone mode, the flink cluster is always up.
> >>
> >>
> >> Caizhi Weng <ts...@gmail.com> 于2020年5月8日周五 下午2:47写道:
> >>
> >>> Hi dear Flink community,
> >>>
> >>> I would like to determine whether a job has finished (no matter
> >>> successfully or exceptionally) in my code.
> >>>
> >>> I used to think that JobClient#getJobStatus is a good idea, but I found
> >>> that it behaves quite differently under different executing environments.
> >>> For example, under a standalone session cluster it will return the FINISHED
> >>> status for a finished job, while under a yarn per job cluster it will throw
> >>> a ApplicationNotFound exception. I'm afraid that there might be other
> >>> behaviors for other environments.
> >>>
> >>> So what's the best practice to determine whether a job has finished or
> >>> not? Note that I'm not waiting for the job to finish. If the job hasn't
> >>> finished I would like to know it and do something else.
> >>>
> >>
> >>
> >> --
> >> Best Regards
> >>
> >> Jeff Zhang
> >>
> >
>

Re: What's the best practice to determine whether a job has finished or not?

Posted by Kurt Young <yk...@gmail.com>.
+dev <de...@flink.apache.org>

Best,
Kurt


On Fri, May 8, 2020 at 3:35 PM Caizhi Weng <ts...@gmail.com> wrote:

> Hi Jeff,
>
> Thanks for the response. However I'm using executeAsync so that I can run
> the job asynchronously and get a JobClient to monitor the job. JobListener
> only works for synchronous execute method. Is there other way to achieve
> this?
>
> Jeff Zhang <zj...@gmail.com> 于2020年5月8日周五 下午3:29写道:
>
>> I use JobListener#onJobExecuted to be notified that the flink job is
>> done.
>> It is pretty reliable for me, the only exception is the client process is
>> down.
>>
>> BTW, the reason you see ApplicationNotFound exception is that yarn app
>> is terminated which means the flink cluster is shutdown. While for
>> standalone mode, the flink cluster is always up.
>>
>>
>> Caizhi Weng <ts...@gmail.com> 于2020年5月8日周五 下午2:47写道:
>>
>>> Hi dear Flink community,
>>>
>>> I would like to determine whether a job has finished (no matter
>>> successfully or exceptionally) in my code.
>>>
>>> I used to think that JobClient#getJobStatus is a good idea, but I found
>>> that it behaves quite differently under different executing environments.
>>> For example, under a standalone session cluster it will return the FINISHED
>>> status for a finished job, while under a yarn per job cluster it will throw
>>> a ApplicationNotFound exception. I'm afraid that there might be other
>>> behaviors for other environments.
>>>
>>> So what's the best practice to determine whether a job has finished or
>>> not? Note that I'm not waiting for the job to finish. If the job hasn't
>>> finished I would like to know it and do something else.
>>>
>>
>>
>> --
>> Best Regards
>>
>> Jeff Zhang
>>
>

Re: What's the best practice to determine whether a job has finished or not?

Posted by Kurt Young <yk...@gmail.com>.
+dev <de...@flink.apache.org>

Best,
Kurt


On Fri, May 8, 2020 at 3:35 PM Caizhi Weng <ts...@gmail.com> wrote:

> Hi Jeff,
>
> Thanks for the response. However I'm using executeAsync so that I can run
> the job asynchronously and get a JobClient to monitor the job. JobListener
> only works for synchronous execute method. Is there other way to achieve
> this?
>
> Jeff Zhang <zj...@gmail.com> 于2020年5月8日周五 下午3:29写道:
>
>> I use JobListener#onJobExecuted to be notified that the flink job is
>> done.
>> It is pretty reliable for me, the only exception is the client process is
>> down.
>>
>> BTW, the reason you see ApplicationNotFound exception is that yarn app
>> is terminated which means the flink cluster is shutdown. While for
>> standalone mode, the flink cluster is always up.
>>
>>
>> Caizhi Weng <ts...@gmail.com> 于2020年5月8日周五 下午2:47写道:
>>
>>> Hi dear Flink community,
>>>
>>> I would like to determine whether a job has finished (no matter
>>> successfully or exceptionally) in my code.
>>>
>>> I used to think that JobClient#getJobStatus is a good idea, but I found
>>> that it behaves quite differently under different executing environments.
>>> For example, under a standalone session cluster it will return the FINISHED
>>> status for a finished job, while under a yarn per job cluster it will throw
>>> a ApplicationNotFound exception. I'm afraid that there might be other
>>> behaviors for other environments.
>>>
>>> So what's the best practice to determine whether a job has finished or
>>> not? Note that I'm not waiting for the job to finish. If the job hasn't
>>> finished I would like to know it and do something else.
>>>
>>
>>
>> --
>> Best Regards
>>
>> Jeff Zhang
>>
>

Re: What's the best practice to determine whether a job has finished or not?

Posted by Caizhi Weng <ts...@gmail.com>.
Hi Jeff,

Thanks for the response. However I'm using executeAsync so that I can run
the job asynchronously and get a JobClient to monitor the job. JobListener
only works for synchronous execute method. Is there other way to achieve
this?

Jeff Zhang <zj...@gmail.com> 于2020年5月8日周五 下午3:29写道:

> I use JobListener#onJobExecuted to be notified that the flink job is done.
> It is pretty reliable for me, the only exception is the client process is
> down.
>
> BTW, the reason you see ApplicationNotFound exception is that yarn app is
> terminated which means the flink cluster is shutdown. While for standalone
> mode, the flink cluster is always up.
>
>
> Caizhi Weng <ts...@gmail.com> 于2020年5月8日周五 下午2:47写道:
>
>> Hi dear Flink community,
>>
>> I would like to determine whether a job has finished (no matter
>> successfully or exceptionally) in my code.
>>
>> I used to think that JobClient#getJobStatus is a good idea, but I found
>> that it behaves quite differently under different executing environments.
>> For example, under a standalone session cluster it will return the FINISHED
>> status for a finished job, while under a yarn per job cluster it will throw
>> a ApplicationNotFound exception. I'm afraid that there might be other
>> behaviors for other environments.
>>
>> So what's the best practice to determine whether a job has finished or
>> not? Note that I'm not waiting for the job to finish. If the job hasn't
>> finished I would like to know it and do something else.
>>
>
>
> --
> Best Regards
>
> Jeff Zhang
>

Re: What's the best practice to determine whether a job has finished or not?

Posted by Jeff Zhang <zj...@gmail.com>.
I use JobListener#onJobExecuted to be notified that the flink job is done.
It is pretty reliable for me, the only exception is the client process is
down.

BTW, the reason you see ApplicationNotFound exception is that yarn app is
terminated which means the flink cluster is shutdown. While for standalone
mode, the flink cluster is always up.


Caizhi Weng <ts...@gmail.com> 于2020年5月8日周五 下午2:47写道:

> Hi dear Flink community,
>
> I would like to determine whether a job has finished (no matter
> successfully or exceptionally) in my code.
>
> I used to think that JobClient#getJobStatus is a good idea, but I found
> that it behaves quite differently under different executing environments.
> For example, under a standalone session cluster it will return the FINISHED
> status for a finished job, while under a yarn per job cluster it will throw
> a ApplicationNotFound exception. I'm afraid that there might be other
> behaviors for other environments.
>
> So what's the best practice to determine whether a job has finished or
> not? Note that I'm not waiting for the job to finish. If the job hasn't
> finished I would like to know it and do something else.
>


-- 
Best Regards

Jeff Zhang