flink和sentinel中计算当前时间所属的时间窗口算法

flink中:

org.apache.flink.streaming.api.windowing.windows.TimeWindow

public static long getWindowStartWithOffset(long timestamp, long offset, long windowSize) {
//转载请标明链接:https://blog.csdn.net/wabiaozia/article/details/116399314       
 return timestamp - (timestamp - offset + windowSize) % windowSize;
    }

 

sentinel中也类似

protected long calculateWindowStart(/*@Valid*/ long timeMillis) {
//转载请标明链接:https://blog.csdn.net/wabiaozia/article/details/116399314
    return timeMillis - timeMillis % windowLengthInMs;
}

 

 

 

你可能感兴趣的:(java·未分类,·算法实现·,flink,flink,sentinel,window,算法)