Flink中的DataStream任务用于实现data streams的转换,data stream可以来自不同的数据源,比如消息队列,socket,文件等。
Ref
1 | https://ci.apache.org/projects/flink/flink-docs-stable/zh/dev/datastream_api.html |
使用DataStream API需要使用stream env
1 | StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); |
DataStream支持的Data Source有:File-based,Socket-based,Collection-based,Custom
1.File-based
1 | readTextFile(path) - Reads text files, i.e. files that respect the TextInputFormat specification, line-by-line and returns them as Strings. |
2.Socket-based