You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Si-li Liu <un...@gmail.com> on 2020/07/20 11:38:06 UTC

How to get flink JobId in runtime

Hi

I want to retrieve flink JobId in runtime, for example, during
RichFunction's open method. Is there anyway to do it?

I checked the methods in RuntimeContext and ExecutionConfig, seems I can't
get this information from them.

Thanks!

-- 
Best regards

Sili Liu

Re: How to get flink JobId in runtime

Posted by Yangze Guo <ka...@gmail.com>.
Hi Si-li,

Just a reminder that it is not the right way to get JobId because the
`StreamTask` is actually an internal class. For more discussion about
it, please refer to [1] and [2]. You could get JobId through this way
at the moment. Please keep in mind that it is not a stable contract.

[1] https://issues.apache.org/jira/browse/FLINK-17862
[2] http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/How-do-I-get-the-IP-of-the-master-and-slave-files-programmatically-in-Flink-td35299.html

Best,
Yangze Guo

On Tue, Jul 21, 2020 at 4:42 PM Si-li Liu <un...@gmail.com> wrote:
>
> I figure out another way, wrapper my function in a custom StreamOperator that extends AbstractUdfStreamOperator, then I can use this.getContainingTask.getEnvironment.getJobId
>
> Congxian Qiu <qc...@gmail.com> 于2020年7月21日周二 上午11:49写道:
>>
>> Hi Sili
>>
>>     I'm not sure if there are other ways to get this value properly. Maybe you can try `RuntimeContext.getMetricGroup().getAllVariables().get("<job_id>")`.
>>
>> Best,
>> Congxian
>>
>>
>> Si-li Liu <un...@gmail.com> 于2020年7月20日周一 下午7:38写道:
>>>
>>> Hi
>>>
>>> I want to retrieve flink JobId in runtime, for example, during RichFunction's open method. Is there anyway to do it?
>>>
>>> I checked the methods in RuntimeContext and ExecutionConfig, seems I can't get this information from them.
>>>
>>> Thanks!
>>>
>>> --
>>> Best regards
>>>
>>> Sili Liu
>
>
>
> --
> Best regards
>
> Sili Liu

Re: How to get flink JobId in runtime

Posted by Si-li Liu <un...@gmail.com>.
I figure out another way, wrapper my function in a custom StreamOperator
that extends AbstractUdfStreamOperator, then I can use
this.getContainingTask.getEnvironment.getJobId

Congxian Qiu <qc...@gmail.com> 于2020年7月21日周二 上午11:49写道:

> Hi Sili
>
>     I'm not sure if there are other ways to get this value properly. Maybe
> you can try
> `RuntimeContext.getMetricGroup().getAllVariables().get("<job_id>")`.
>
> Best,
> Congxian
>
>
> Si-li Liu <un...@gmail.com> 于2020年7月20日周一 下午7:38写道:
>
>> Hi
>>
>> I want to retrieve flink JobId in runtime, for example, during
>> RichFunction's open method. Is there anyway to do it?
>>
>> I checked the methods in RuntimeContext and ExecutionConfig, seems I
>> can't get this information from them.
>>
>> Thanks!
>>
>> --
>> Best regards
>>
>> Sili Liu
>>
>

-- 
Best regards

Sili Liu

Re: How to get flink JobId in runtime

Posted by Congxian Qiu <qc...@gmail.com>.
Hi Sili

    I'm not sure if there are other ways to get this value properly. Maybe
you can try
`RuntimeContext.getMetricGroup().getAllVariables().get("<job_id>")`.

Best,
Congxian


Si-li Liu <un...@gmail.com> 于2020年7月20日周一 下午7:38写道:

> Hi
>
> I want to retrieve flink JobId in runtime, for example, during
> RichFunction's open method. Is there anyway to do it?
>
> I checked the methods in RuntimeContext and ExecutionConfig, seems I can't
> get this information from them.
>
> Thanks!
>
> --
> Best regards
>
> Sili Liu
>