milk
12/10/2024, 6:49 AMsourceStream.assignTimestampsAndWatermarks(
WatermarkStrategy.MyObjectforBoundedOutOfOrderness(Duration.ofSeconds(300))
.withTimestampAssigner(new SerializableTimestampAssignerMyObject() {
@Override
public long extractTimestamp(MyObject element, long recordTimestamp) {
var timestamp = new Timestamp(element.getTimestamp());
return timestamp.getTime();
}
}).withIdleness(Duration.ofSeconds(10)));
Problem 1:
When I process logs using the following code, logs that should belong to different windows is assigned to the same window. Specifically, logs that are far apart in time (e.g., with a time interval of over 30 minutes) have the same session window start time (window().getStart()). This phenomenon occurs frequently but not for all logs. Why does this incorrect assignment happen?
dataStream
.keyBy(new keySelector1())
.window(EventTimeSessionWindows.withGap(Duration.ofSeconds(300)))
.trigger(PurgingTrigger.of(ContinuousEventTimeTrigger.of(Duration.ofSeconds(60))))
.process(new processFunc1())
.keyBy(new keySelector2())
.process(new processFunc2());
Problem 2:
Due to the large volume of logs, I want to process data at shorter intervals to prevent excessive memory usage. When I use the code from the previous problem, the program runs stably over time. However, when I modify the code to use the following (changing ContinuousEventTimeTrigger to ContinuousProcessTimeTrigger), the program crashes. I observed that the JVM heap quickly fills up, and then the program cannot continue running. I tried increasing the memory and reducing the trigger interval, but it didn’t help. Why does changing the TimeTrigger cause such an issue?
dataStream
.keyBy(new keySelector1())
.window(EventTimeSessionWindows.withGap(Duration.ofSeconds(300)))
.trigger(PurgingTrigger.of(ContinuousProcessTimeTrigger.of(Duration.ofSeconds(60))))
.process(new processFunc1())
.keyBy(new keySelector2())
.process(new processFunc2());