如何在滑动window中获取当前window时间?

How to get current window time in sliding window?

我正在使用 storm 实现的滑动 window:

From Here

这是我的拓扑:

 public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();

    builder.setSpout("rabbitSpout", new RabbitMQSpout());
    builder.setBolt("filterBolt", new FilteringBolt()).shuffleGrouping("rabbitSpout");

    builder.setBolt("HourStatisticsBolt", new SlidingWindowStatisticsBolt()
            .withWindow(new BaseWindowedBolt.Duration(60, TimeUnit.MINUTES),
                    new BaseWindowedBolt.Duration(10, TimeUnit.SECONDS))
            .withTimestampField("timestamp")).shuffleGrouping("filterBolt");

在我的 SlidingWindowStatisticsBolt 的执行方法中,我想获取 windows 开始或结束的时间戳。在我的螺栓中,如何获得 windows 长度和滑动持续时间?

由于您使用的是事件时间 (withTimestampField),因此 windows 是根据周期性水印计算的。现在 window start/end 时间没有暴露在 TupleWindow 中。

在storm最新的master分支中,TupleWindow has a getTimestamp method which returns the window end timestamp and works for both processing and event time based windows. This will be available in the future release of storm (2.0 release). If you would like this to be back ported and made available in the next 1.x release you can file a JIRA here