Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache storm 风暴滑动窗口进近_Apache Storm_Sliding Window - Fatal编程技术网

Apache storm 风暴滑动窗口进近

Apache storm 风暴滑动窗口进近,apache-storm,sliding-window,Apache Storm,Sliding Window,目前,我试图寻找风暴的消息处理。我觉得滑动窗口功能很有趣,并尝试让它工作 但是,即使我将时间间隔设置为5秒,窗口后面的计算也要频繁得多。似乎每个新消息都会执行tuple窗口的execute方法 builder.setBolt("messageCountBolt", new MessageCountBolt() .withWindow( new BaseW

目前,我试图寻找风暴的消息处理。我觉得滑动窗口功能很有趣,并尝试让它工作

但是,即使我将时间间隔设置为5秒,窗口后面的计算也要频繁得多。似乎每个新消息都会执行tuple窗口的execute方法

builder.setBolt("messageCountBolt",
                new MessageCountBolt()
                        .withWindow(
                                new BaseWindowedBolt.Duration(20, TimeUnit.SECONDS),
                                new BaseWindowedBolt.Duration(5, TimeUnit.SECONDS))
                        .withMessageIdField("id")
                        .withTimestampField("timeStamp")
                        .withLag(new BaseWindowedBolt.Duration(5, TimeUnit.SECONDS)),
                1).globalGrouping("spout");

有人知道为什么?我希望计算在5秒内等待所有消息。

您必须使用
withTumblingWindow
而不是
withWindow


withWindow
对每个输入元组执行,并传递包含最后一条输入消息的输入批。但是
withTumblingWindow
将在一批中聚合所有输入消息,并在一批中传递整个消息。

我认为原因是您使用的是SlidingWindow,它为该窗口中的每个入口和出口生成输出。 如果您只希望在窗口的末尾有一个输出,那么最好使用批处理窗口或滚动窗口。 总结如下:

  • 滑动窗口:在给定的时间窗口内保留每个事件,在添加或删除新事件时生成输出
  • 批处理窗口:也称为滚动窗口,它们仅在时间窗口结束时产生输出

我认为正确的方法是在Storm上使用Trident,因为每一条新消息都会触发对plain Storm中execute方法的调用。