大資料:Windows下配置flink的Stream
對於開發人員來說,最希望的是需要在windows中進行測試,然後把除錯好的程式放在叢集中執行。下面寫一個Socket,上面是監控本地的一個執行埠,來實時的提取資料。獲取視訊中文件資料及完整視訊的夥伴請加QQ群:947967114
下面是一段程式碼:
import org.apache.flink.api.java.utils.ParameterToolimportorg.apache.flink.streaming.api.scala._importorg.apache.flink.streaming.api.windowing.time.Timeobject SocketWindowWordCount { def main(args: Array[String]): Unit = { val port:Int=try{ ParameterTool.fromArgs
這個程式有幾個需要注意的。第一個org.apache.flink.streaming.api.windowing.time.Time是這個時間包的使用。第二個是org.apache.flink.streaming.api.scala._,不要直接引入org.apache.flink.streaming.api.scala.StreamExecutionEnvironment。
![](https://upload-images.jianshu.io/upload_images/15065970-dbff7c855f9a9852.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/771/format/webp)
配置windows的nc埠,在網上下載nc.exe(https://eternallybored.org/misc/netcat/)
選擇版本:解壓放在一個指定的目錄上。然後在cmd環境中進入到這個目錄。獲取視訊中文件資料及完整視訊的夥伴請加QQ群:947967114
![](https://upload-images.jianshu.io/upload_images/15065970-09b606ccb45d92fd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/626/format/webp)
使用命令開始nc制定埠為9000(nc -L -p 9000 -v)
![](https://upload-images.jianshu.io/upload_images/15065970-0c269e57c82cf79b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/631/format/webp)
在IDEA中設定輸入引數:
![](https://upload-images.jianshu.io/upload_images/15065970-0cae59f12c68834b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/947/format/webp)
指定埠--port 9000,然後執行
![](https://upload-images.jianshu.io/upload_images/15065970-200af519744fb73b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
Cmd埠中輸入資料,在flink中可以看到實時的雲運算結果:
![](https://upload-images.jianshu.io/upload_images/15065970-3c7d24b2ed6d95c0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
至此,flink在windows中的一個stream配置完成。獲取視訊中文件資料及完整視訊的夥伴請加QQ群:947967114