flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Till Rohrmann <trohrm...@apache.org>
Subject Re: Emit message at start and end of event time session window
Date Tue, 18 Feb 2020 13:50:23 GMT
Hi Manas,

you can implement something like this with a bit of trigger magic. What you
need to do is to define your own trigger implementation which keeps state
to remember whether it has triggered the "started window" message or not.
In the stateful window function you would need to do something similar. The
first call could trigger the output of "window started" and any subsequent
call will trigger the evaluation of the window. It would have been a bit
easier if the trigger and the window process function could share its
internal state. Unfortunately, this is not possible at the moment.

I've drafted a potential solution which you can find here [1].

[1] https://gist.github.com/tillrohrmann/5251f6d62e256b60947eea7b553519ef


On Mon, Feb 17, 2020 at 8:09 AM Manas Kale <manaskale96@gmail.com> wrote:

> Hi,
> I want to achieve the following using event time session windows:
>    1. When the window.getStart() and last event timestamp in the window
>    is greater than MIN_WINDOW_SIZE milliseconds, I want to emit a message
>    "Window started @ timestamp".
>    2. When the session window ends, i.e. the watermark passes
>    lasteventTimestamp + inactivityPeriod, I want to emit a message "Window
>    ended @ timestamp".
>  It is guaranteed that all events are on time and no lateness is allowed.
> I am having difficulty implementing both 1 and 2 simultaneously.
> I am able to implement point 1 using a custom trigger, which checks if
> (lastEventTimestamp - window.getStart()) > MIN_WINDOW_SIZE and triggers a
> customProcessWindowFunction().
> However, with this architecture I can't detect the end of the window.
> Is my approach correct or is there a completely different method to
> achieve this?
> Thanks,
> Manas Kale

View raw message