You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@beam.apache.org by Boyuan Zhang <bo...@google.com> on 2020/09/02 18:00:37 UTC

Clear Timer in Java SDK

Hi team,

I'm looking for something similar to timer.clear() from Python SDK[1] in
Java SDK but it seems like we haven't exposed clearing timer API from Java
Timer. Does Java SDK have another way to clear a timer or we just haven't
worked on this API?

[1]
https://github.com/apache/beam/blob/master/sdks/python/apache_beam/runners/worker/bundle_processor.py#L660-L671

Re: Clear Timer in Java SDK

Posted by Reza Rokni <re...@google.com>.
Another trick, which is more boilerplate I am afraid, would be to use
another ValueState object which you can set and read in OnTimer to indicate
if this timer is now 'inactive'.

Infinite future would also work if you're in a Global window, but could end
up with a bunch of these hanging around per key.



On Fri, Sep 4, 2020 at 9:56 AM Boyuan Zhang <bo...@google.com> wrote:

> Thanks, Luke!
>
> Do we want to support the API in Java SDK? And what's the common approach
> for now in Java SDK to "kind of" clear a timer, like setting the
> fireTimestamp to infinity future?
>
> On Thu, Sep 3, 2020 at 3:43 PM Luke Cwik <lc...@google.com> wrote:
>
>> Java SDK hasn't exposed the ability to remove timers.
>>
>> On Wed, Sep 2, 2020 at 11:00 AM Boyuan Zhang <bo...@google.com> wrote:
>>
>>> Hi team,
>>>
>>> I'm looking for something similar to timer.clear() from Python SDK[1] in
>>> Java SDK but it seems like we haven't exposed clearing timer API from Java
>>> Timer. Does Java SDK have another way to clear a timer or we just haven't
>>> worked on this API?
>>>
>>> [1]
>>> https://github.com/apache/beam/blob/master/sdks/python/apache_beam/runners/worker/bundle_processor.py#L660-L671
>>>
>>

Re: Clear Timer in Java SDK

Posted by Reuven Lax <re...@google.com>.
Seems like we should support this, and in fact TimerInternals already has a
deleteTimer method.

On Thu, Sep 3, 2020 at 6:56 PM Boyuan Zhang <bo...@google.com> wrote:

> Thanks, Luke!
>
> Do we want to support the API in Java SDK? And what's the common approach
> for now in Java SDK to "kind of" clear a timer, like setting the
> fireTimestamp to infinity future?
>
> On Thu, Sep 3, 2020 at 3:43 PM Luke Cwik <lc...@google.com> wrote:
>
>> Java SDK hasn't exposed the ability to remove timers.
>>
>> On Wed, Sep 2, 2020 at 11:00 AM Boyuan Zhang <bo...@google.com> wrote:
>>
>>> Hi team,
>>>
>>> I'm looking for something similar to timer.clear() from Python SDK[1] in
>>> Java SDK but it seems like we haven't exposed clearing timer API from Java
>>> Timer. Does Java SDK have another way to clear a timer or we just haven't
>>> worked on this API?
>>>
>>> [1]
>>> https://github.com/apache/beam/blob/master/sdks/python/apache_beam/runners/worker/bundle_processor.py#L660-L671
>>>
>>

Re: Clear Timer in Java SDK

Posted by Boyuan Zhang <bo...@google.com>.
Thanks, Luke!

Do we want to support the API in Java SDK? And what's the common approach
for now in Java SDK to "kind of" clear a timer, like setting the
fireTimestamp to infinity future?

On Thu, Sep 3, 2020 at 3:43 PM Luke Cwik <lc...@google.com> wrote:

> Java SDK hasn't exposed the ability to remove timers.
>
> On Wed, Sep 2, 2020 at 11:00 AM Boyuan Zhang <bo...@google.com> wrote:
>
>> Hi team,
>>
>> I'm looking for something similar to timer.clear() from Python SDK[1] in
>> Java SDK but it seems like we haven't exposed clearing timer API from Java
>> Timer. Does Java SDK have another way to clear a timer or we just haven't
>> worked on this API?
>>
>> [1]
>> https://github.com/apache/beam/blob/master/sdks/python/apache_beam/runners/worker/bundle_processor.py#L660-L671
>>
>

Re: Clear Timer in Java SDK

Posted by Luke Cwik <lc...@google.com>.
Java SDK hasn't exposed the ability to remove timers.

On Wed, Sep 2, 2020 at 11:00 AM Boyuan Zhang <bo...@google.com> wrote:

> Hi team,
>
> I'm looking for something similar to timer.clear() from Python SDK[1] in
> Java SDK but it seems like we haven't exposed clearing timer API from Java
> Timer. Does Java SDK have another way to clear a timer or we just haven't
> worked on this API?
>
> [1]
> https://github.com/apache/beam/blob/master/sdks/python/apache_beam/runners/worker/bundle_processor.py#L660-L671
>