Hello. Quesiton - is it possible to stagger tumbli...
# troubleshooting
a
Hello. Quesiton - is it possible to stagger tumbling window fire across keys. I have ~64M keyed windows on a 60-min tumbling window. All fire at once when watermark advances. I want to try to spread this out. To be clear β€” I need aligned window boundaries (same hour for all keys). I just want to stagger when the results are emitted, not the window boundaries themselves. Wrote a custom trigger that delays firing with a random processing-time timer:
Copy code
public class JitteredEventTimeTrigger extends Trigger<Object, TimeWindow> {
      private final long maxJitterMillis;

      @Override
      public TriggerResult onElement(Object element, long timestamp, TimeWindow window, TriggerContext ctx) {
          ctx.registerEventTimeTimer(window.maxTimestamp());
          return TriggerResult.CONTINUE;
      }

      @Override
      public TriggerResult onEventTime(long time, TimeWindow window, TriggerContext ctx) {
          long jitter = ThreadLocalRandom.current().nextLong(maxJitterMillis);
          ctx.registerProcessingTimeTimer(ctx.getCurrentProcessingTime() + jitter);
          return TriggerResult.CONTINUE;
      }

      @Override
      public TriggerResult onProcessingTime(long time, TimeWindow window, TriggerContext ctx) {
          return TriggerResult.FIRE;
      }

      @Override
      public void clear(TimeWindow window, TriggerContext ctx) {
          ctx.deleteEventTimeTimer(window.maxTimestamp());
      }
  }
Not seeing any output. I think WindowOperator https://github.com/apache/flink/blob/master/flink-runtime/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/WindowOperator.java#L485-L487 might be cleaning up window state at maxTimestamp + allowedLateness(0) in the same onEventTime call - before my processing-time timer gets a chance to fire. Can anyone confirm? Flink 2.2 running on AWS Managed Flink