如何在Dataflow中的固定时间段后触发数据?

时间:2016-09-03 09:16:08

标签: java google-cloud-platform google-cloud-dataflow

我有一个流数据流作业,它从PubSub读取具有固有时间戳的数据。数据必须累积30分钟(基于事件时间),然后触发管道。以下是我的代码段

PCollection<String> pubsubData =
p.apply(PubsubIO.Read.timestampLabel(TIMESTAMP_ATTRIBUTE).topic(options.getTopic()));

pubsubData
 .apply(ParDo.named("ParseAction").of(new ParseEventFn()))
 .apply(Window.named("ActionWindow")
     .<Data>into(FixedWindows.of(
         HALF_HOUR))
     .triggering(
       AfterWatermark.pastEndOfWindow()
       .withEarlyFirings(AfterProcessingTime.pastFirstElementInPane()
             .plusDelayOf(ONE_MINUTE))
       .withLateFirings(AfterProcessingTime.pastFirstElementInPane()
             .plusDelayOf(ONE_MINUTE)))
     .withAllowedLateness(Duration.standardMinutes(options.getAllowedLateness()))
     .discardingFiredPanes())
 .apply("ProcessData", new ProcessData());

使用上面的代码,数据在完成30分钟的事件时间之前到达ProcessData类。如果我在没有触发器的情况下使用下面的代码,即使30分钟后数据也不会到达ProcessData类。

pubsubData
.apply(ParDo.named("ParseDayUserAction").of(new ParseEventFn("day")))
.apply(Window.named("UserActionDayWindow").    
<ActionData>into(FixedWindows.of(HALF_HOUR))
  .discardingFiredPanes())
.apply("ProcessData", new ProcessData());

我在这里做错了吗?

0 个答案:

没有答案