You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@beam.apache.org by Yihua Fang <fa...@gmail.com> on 2017/10/12 01:04:12 UTC

Timer align vs offset

What does timer.align do and what is the difference between align and
offset?  The comment says: "Aligns the target timestamp used by {@link
#setRelative()} to the next boundary of {@code period}".

For example, if we say
`timer.align(Duration.standardMinutes(1)).setRelative()`,  does the timer
set to the next minutes like from 10:35:32 to 10:36:00? (HH::MM:SS) Also,
does align cause the timer to fire off at every edge or just once? If at
every edge, then how can we cancel the timer?

Thanks
Eric

Re: Timer align vs offset

Posted by Yihua Fang <fa...@gmail.com>.
Got it. Thanks.

Eric
On Wed, Oct 11, 2017 at 6:37 PM Kenneth Knowles <kl...@google.com> wrote:

> Hello!
>
> When you say `timer.align(standardMinutes(1)).setRelative()` the timer
> will be set to the next minute boundary after the current time, just as you
> describe. It will only be set once, so you don't need to cancel it, but you
> will need to set it again in your @OnTimer if you want it to repeat.
>
> Kenn
>
> On Wed, Oct 11, 2017 at 6:04 PM, Yihua Fang <fa...@gmail.com>
> wrote:
>
>> What does timer.align do and what is the difference between align and
>> offset?  The comment says: "Aligns the target timestamp used by {@link
>> #setRelative()} to the next boundary of {@code period}".
>>
>> For example, if we say
>> `timer.align(Duration.standardMinutes(1)).setRelative()`,  does the timer
>> set to the next minutes like from 10:35:32 to 10:36:00? (HH::MM:SS) Also,
>> does align cause the timer to fire off at every edge or just once? If at
>> every edge, then how can we cancel the timer?
>>
>> Thanks
>> Eric
>>
>
>

Re: Timer align vs offset

Posted by Kenneth Knowles <kl...@google.com>.
Hello!

When you say `timer.align(standardMinutes(1)).setRelative()` the timer will
be set to the next minute boundary after the current time, just as you
describe. It will only be set once, so you don't need to cancel it, but you
will need to set it again in your @OnTimer if you want it to repeat.

Kenn

On Wed, Oct 11, 2017 at 6:04 PM, Yihua Fang <fa...@gmail.com>
wrote:

> What does timer.align do and what is the difference between align and
> offset?  The comment says: "Aligns the target timestamp used by {@link
> #setRelative()} to the next boundary of {@code period}".
>
> For example, if we say `timer.align(Duration.standardMinutes(1)).setRelative()`,
>  does the timer set to the next minutes like from 10:35:32 to 10:36:00?
> (HH::MM:SS) Also, does align cause the timer to fire off at every edge or
> just once? If at every edge, then how can we cancel the timer?
>
> Thanks
> Eric
>