Flink多并行度水印测试
数据来源为kafka,一共4个分区,此时为了直观分析,将flink的并发度设置为3;依次发送数据,分析多并行度情况下flink的水印情况;
设置flink并发度为3,flink窗口大小为3秒,水印延迟为100秒
先上代码:
//获取运行环境
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
//设置使用eventtime,默认是使用processtime
env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
//设置并行度为3,默认并行度是当前机器的cpu数量
env.setParallelism(3);
String topic = "test01";
Properties prop = new Properties();
prop.setProperty("bootstrap.servers","vm01:9092");
prop.setProperty("group.id","con1");
FlinkKafkaConsumer010<String> myConsumer = new FlinkKafkaConsumer010<>(topic, new SimpleStringSchema(), prop);
myConsumer.setStartFromGroupOffsets();//默认消费策略
DataStreamSource<String> text &#