Time深度解析
1. 概述
Flink在流处理程序中支持不同的时间概念。
首先需要理解三种time的含义:
- Processing time: Processing time refers to the system time of the machine that is executing the respective operation. 处理事件时的时间,处理简单,结果不确定
- Event time: Event time is the time that each individual event occurred on its producing device. 事件产生的时间,处理复杂,结果确定可以重现
- Ingestion time: Ingestion time is the time that events enter Flink. 事件进入Flink的时间
1.1设置一个时间特征
首先定义你的流处理程序是已哪一种时间为标志的。
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setStreamTimeCharacteristic(TimeCharacteristic.ProcessingTime);
// env.setStreamTimeCharacteristic(TimeCharacteristic.IngestionTime);
// env.setStreamTimeCharacteristic(TimeCharacteristic.