Apache flink ApacheFlink 1.0.0。与事件时间相关的迁移问题

Apache flink ApacheFlink 1.0.0。与事件时间相关的迁移问题,apache-flink,flink-streaming,Apache Flink,Flink Streaming,我尝试将一些简单的任务迁移到Flink 1.0.0版本,但失败了,出现以下异常: java.lang.RuntimeException: Record has Long.MIN_VALUE timestamp (= no timestamp marker). Is the time characteristic set to 'ProcessingTime', or did you forget to call 'DataStream.assignTimestampsAndWatermarks(

我尝试将一些简单的任务迁移到Flink 1.0.0版本,但失败了,出现以下异常:

java.lang.RuntimeException: Record has Long.MIN_VALUE timestamp (= no timestamp marker). Is the time characteristic set to 'ProcessingTime', or did you forget to call 'DataStream.assignTimestampsAndWatermarks(...)'?
代码由两个通过Kafka主题连接的独立任务组成,其中一个任务是简单消息生成器,另一个任务是简单消息消费者,它使用timeWindowAll计算每分钟消息到达率

同样,类似的代码在0.10.2版本中运行时没有任何问题,但现在看起来系统错误地解释了一些事件时间戳,如Long.MIN_值,这导致任务失败

问题是,我是做错了什么,还是它是一些将在未来版本中修复的bug

主要任务是:

公共类Test1\u 0\u 0{
//事件时间与当前系统时间之间的最大时滞
静态最终时间maxTimeLag=时间(3,时间单位秒);
公共静态void main(字符串[]args)引发异常{
//设置执行环境
最终StreamExecutionEnvironment env=StreamExecutionEnvironment
.getExecutionEnvironment();
//设置事件时间使用情况
环境setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
环境设置超时(1);
//属性初始化
属性=新属性();
setProperty(“bootstrap.servers”,“localhost:9092”);
setProperty(“zookeeper.connect”,“localhost:2181”);
properties.setProperty(“group.id”、“test”);
//用命令行提供的属性覆盖默认属性
ParameterTool ParameterTool=ParameterTool.fromArgs(args);
对于(Map.Entry e:parameterTool.toMap().entrySet()){
setProperty(e.getKey(),e.getValue());
}
//setProperty(“auto.offset.reset”、“minimable”);
System.out.println(“属性:“+Properties”);
数据流=环境
.addSource(新的FlinkKafkaConsumer09(“测试”,新的MessageSDSchema(),属性)).filter(message->message!=null);
//对rebalance()的调用导致数据重新分区,以便所有计算机都接收消息
//(例如,当Kafka分区的数量小于Flink并行实例的数量时)。
流。再平衡()
.assignTimestampsAndWatermarks(新的MessageTimestampExtractor(maxTimeLag));
//统计信息
stream.timeWindowAll(Time.minutes(1)).apply(新建AllWindowFunction()){
@凌驾
public void apply(TimeWindow TimeWindow、Iterable值、收集器)引发异常{
整数计数=0;
if(values.iterator().hasNext()){
用于(消息值:值){
计数++;
}
collector.collect(“最后一分钟到达:+count”);
}
}
}).print();
//执行程序
环境执行(“消息计数”);
}
}
时间戳提取器:

public类MessageTimestampExtractor实现具有周期性水印的赋值器,可序列化{
私有静态最终长serialVersionUID=752647295622776147L;
//当前处理时间与事件时间戳之间的最大延迟
长最大时间间隔=0升;
长currentWatermarkTimestamp=0L;
public MessageTimestampExtractor(){
}
public MessageTimestampExtractor(Time maxTimeLag){
this.maxTimeLag=maxTimeLag.tomillesons();
}
/**
*为元素指定时间戳,以自历元起的毫秒为单位。
*
*向该方法传递先前分配的元素时间戳。
*该前一时间戳可能已由前一个赋值人赋值,
*如果元素之前没有带时间戳,则此值为
*{@code Long.MIN_VALUE}。
*
*@param message将时间戳分配给的元素。
*@param previouselement timestamp元素的上一个内部时间戳,
*或者,如果尚未分配时间戳,则为负值。
*@返回新的时间戳。
*/
@凌驾
公共长提取时间戳(消息消息,长前元素时间戳){
长时间戳=message.getTimestamp();
currentWatermarkTimestamp=Math.max(时间戳,currentWatermarkTimestamp);
返回时间戳;
}
/**
*返回当前水印。此方法由
*系统检索当前水印。该方法可能会返回null
*指示没有可用的新水印。
*
*仅当返回的水印为非空且更大时,才会发出该水印
*比以前发出的水印。如果当前水印仍然是
*与前一个相同,此后事件时间没有任何进展
*此方法的上一次调用。
*
*如果此方法返回的值小于先前返回的水印,
*然后,实现无法正确处理事件流时间戳。
*在这种情况下,将不会发出返回的水印(以保留
*升序水印),违规行为将被记录并注册到度量中。
*
*调用此方法和生成水印的时间间隔
*取决于{@link ExecutionConfig#getAutoWatermarkInterval()}。
*
*@see org.apache.flink.streaming.api.watermark.watermark
*@请参阅ExecutionConfig#getAutoWatermarkInterval()
*/
@凌驾
公共水印getCurrentWatermark(){

if(currentWatermarkTimestamp问题在于调用
assignTimestamp和Watermarks
返回一个新的
DataStream
,该数据流使用时间戳提取器。因此,您必须使用返回的